From 9edc16425071837aeb296d805e4d17147c546e65 Mon Sep 17 00:00:00 2001 From: Tglman Date: Tue, 12 Nov 2024 20:46:07 +0000 Subject: [PATCH] refactor(test): migrate tests to the new query engine --- .../spatial/LuceneSpatialLineStringTest.java | 10 +++++----- .../spatial/LuceneSpatialMultiLineStringTest.java | 5 ++--- .../spatial/LuceneSpatialMultiPolygonTest.java | 6 +++--- .../spatial/LuceneSpatialPointTest.java | 2 +- .../spatial/LuceneSpatialPolygonTest.java | 6 +++--- .../spatial/LuceneTransactionGeoQueryTest.java | 12 ++++++------ 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialLineStringTest.java b/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialLineStringTest.java index c87cf71de34..239394f29e6 100644 --- a/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialLineStringTest.java +++ b/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialLineStringTest.java @@ -21,7 +21,7 @@ import com.orientechnologies.orient.core.metadata.schema.OSchema; import com.orientechnologies.orient.core.metadata.schema.OType; import com.orientechnologies.orient.core.record.impl.ODocument; -import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; +import com.orientechnologies.orient.core.sql.executor.OResult; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -103,17 +103,17 @@ protected void queryLineString() { String query = "select * from Place where location && { 'shape' : { 'type' : 'OLineString' , 'coordinates'" + " : [[1,2],[4,6]]} } "; - List docs = db.query(new OSQLSynchQuery(query)); + List docs = db.query(query).stream().toList(); Assert.assertEquals(docs.size(), 1); query = "select * from Place where location && 'LINESTRING(1 2, 4 6)' "; - docs = db.query(new OSQLSynchQuery(query)); + docs = db.query(query).stream().toList(); Assert.assertEquals(docs.size(), 1); query = "select * from Place where location && ST_GeomFromText('LINESTRING(1 2, 4 6)') "; - docs = db.query(new OSQLSynchQuery(query)); + docs = db.query(query).stream().toList(); Assert.assertEquals(docs.size(), 1); @@ -122,7 +122,7 @@ protected void queryLineString() { + " 61.40723633876356,-149.2657470703125 61.40723633876356,-149.2657470703125" + " 61.05562700886678,-150.205078125 61.05562700886678,-150.205078125" + " 61.40723633876356))' "; - docs = db.query(new OSQLSynchQuery(query)); + docs = db.query(query).stream().toList(); Assert.assertEquals(docs.size(), 1); } diff --git a/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialMultiLineStringTest.java b/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialMultiLineStringTest.java index 7c9fb9f5ba1..cbd577dad25 100644 --- a/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialMultiLineStringTest.java +++ b/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialMultiLineStringTest.java @@ -19,8 +19,7 @@ import com.orientechnologies.orient.core.metadata.schema.OClass; import com.orientechnologies.orient.core.metadata.schema.OSchema; import com.orientechnologies.orient.core.metadata.schema.OType; -import com.orientechnologies.orient.core.record.impl.ODocument; -import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; +import com.orientechnologies.orient.core.sql.executor.OResult; import java.util.List; import org.junit.Assert; import org.junit.Before; @@ -247,7 +246,7 @@ public void testWithIndex() { protected void testQueryMultiLineString() { String query = "select * from Place where location && 'POINT(-157.9159477 21.3433168)' "; - List docs = db.query(new OSQLSynchQuery(query)); + List docs = db.query(query).stream().toList(); Assert.assertEquals(docs.size(), 1); } diff --git a/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialMultiPolygonTest.java b/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialMultiPolygonTest.java index b9ddff1bb43..2bfd52f2705 100644 --- a/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialMultiPolygonTest.java +++ b/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialMultiPolygonTest.java @@ -21,7 +21,7 @@ import com.orientechnologies.orient.core.metadata.schema.OSchema; import com.orientechnologies.orient.core.metadata.schema.OType; import com.orientechnologies.orient.core.record.impl.ODocument; -import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; +import com.orientechnologies.orient.core.sql.executor.OResult; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -158,7 +158,7 @@ protected void queryMultiPolygon() { + " 62.27814559876582,-160.77392578125 61.53316997618228,-162.53173828125" + " 61.4597705702975,-162.861328125 61.762728830472696,-163.14697265625" + " 62.12443624549497,-162.5537109375 62.11416112594049))' "; - List docs = db.query(new OSQLSynchQuery(query)); + List docs = db.query(query).stream().toList(); Assert.assertEquals(docs.size(), 1); @@ -206,7 +206,7 @@ protected void queryMultiPolygon() { + " 19.25929414046391,-156.0113525390625 19.54943746814108,-156.192626953125" + " 19.766703551716972,-155.950927734375 19.921712747556207,-155.9344482421875" + " 20.13847031245115,-155.928955078125 20.25704380463238)))' "; - docs = db.query(new OSQLSynchQuery(query)); + docs = db.query(query).stream().toList(); Assert.assertEquals(docs.size(), 1); } diff --git a/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialPointTest.java b/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialPointTest.java index 4bea89cb2ba..3d7e14bade6 100755 --- a/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialPointTest.java +++ b/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialPointTest.java @@ -113,7 +113,7 @@ protected void queryPoint() { + " 21.996535232496047,-160.1099395751953 21.94304553343818,-160.169677734375" + " 21.89399562866819,-160.21087646484375 21.844928843026818,-160.21018981933594" + " 21.787556698550834)' "; - List old = db.query(new OSQLSynchQuery(query)); + List old = db.query(query).stream().toList(); Assert.assertEquals(1, old.size()); } diff --git a/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialPolygonTest.java b/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialPolygonTest.java index e8627b804ae..7f3e620cf92 100644 --- a/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialPolygonTest.java +++ b/lucene/src/test/java/com/orientechnologies/spatial/LuceneSpatialPolygonTest.java @@ -21,7 +21,7 @@ import com.orientechnologies.orient.core.metadata.schema.OSchema; import com.orientechnologies.orient.core.metadata.schema.OType; import com.orientechnologies.orient.core.record.impl.ODocument; -import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; +import com.orientechnologies.orient.core.sql.executor.OResult; import java.io.IOException; import java.io.InputStream; import java.util.List; @@ -57,12 +57,12 @@ public void testPolygonWithoutIndex() throws IOException { protected void queryPolygon() { String query = "select * from Place where location && 'POINT(13.383333 52.516667)'"; - List docs = db.query(new OSQLSynchQuery(query)); + List docs = db.query(query).stream().toList(); Assert.assertEquals(docs.size(), 1); query = "select * from Place where location && 'POINT(12.5 41.9)'"; - docs = db.query(new OSQLSynchQuery(query)); + docs = db.query(query).stream().toList(); Assert.assertEquals(docs.size(), 0); } diff --git a/lucene/src/test/java/com/orientechnologies/spatial/LuceneTransactionGeoQueryTest.java b/lucene/src/test/java/com/orientechnologies/spatial/LuceneTransactionGeoQueryTest.java index 70301847a5d..f91d31b0747 100644 --- a/lucene/src/test/java/com/orientechnologies/spatial/LuceneTransactionGeoQueryTest.java +++ b/lucene/src/test/java/com/orientechnologies/spatial/LuceneTransactionGeoQueryTest.java @@ -23,7 +23,7 @@ import com.orientechnologies.orient.core.metadata.schema.OSchema; import com.orientechnologies.orient.core.metadata.schema.OType; import com.orientechnologies.orient.core.record.impl.ODocument; -import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; +import com.orientechnologies.orient.core.sql.executor.OResult; import java.util.ArrayList; import java.util.List; import org.junit.Assert; @@ -65,7 +65,7 @@ public void testPointTransactionRollBack() { + " 21.996535232496047,-160.1099395751953 21.94304553343818,-160.169677734375" + " 21.89399562866819,-160.21087646484375 21.844928843026818,-160.21018981933594" + " 21.787556698550834)' "; - List docs = db.query(new OSQLSynchQuery(query)); + List docs = db.query(query).stream().toList(); Assert.assertEquals(1, docs.size()); Assert.assertEquals(3, idx.getInternal().size()); db.rollback(); @@ -75,7 +75,7 @@ public void testPointTransactionRollBack() { + " 21.996535232496047,-160.1099395751953 21.94304553343818,-160.169677734375" + " 21.89399562866819,-160.21087646484375 21.844928843026818,-160.21018981933594" + " 21.787556698550834)' "; - docs = db.query(new OSQLSynchQuery(query)); + docs = db.query(query).stream().toList(); Assert.assertEquals(0, docs.size()); Assert.assertEquals(0, idx.getInternal().size()); } @@ -109,7 +109,7 @@ public void testPointTransactionUpdate() { + " 21.996535232496047,-160.1099395751953 21.94304553343818,-160.169677734375" + " 21.89399562866819,-160.21087646484375 21.844928843026818,-160.21018981933594" + " 21.787556698550834)' "; - List docs = db.query(new OSQLSynchQuery(query)); + List docs = db.query(query).stream().toList(); Assert.assertEquals(0, docs.size()); Assert.assertEquals(1, idx.getInternal().size()); @@ -122,7 +122,7 @@ public void testPointTransactionUpdate() { + " 21.996535232496047,-160.1099395751953 21.94304553343818,-160.169677734375" + " 21.89399562866819,-160.21087646484375 21.844928843026818,-160.21018981933594" + " 21.787556698550834)' "; - docs = db.query(new OSQLSynchQuery(query)); + docs = db.query(query).stream().toList(); Assert.assertEquals(1, docs.size()); Assert.assertEquals(1, idx.getInternal().size()); @@ -133,7 +133,7 @@ public void testPointTransactionUpdate() { + " 21.996535232496047,-160.1099395751953 21.94304553343818,-160.169677734375" + " 21.89399562866819,-160.21087646484375 21.844928843026818,-160.21018981933594" + " 21.787556698550834)' "; - docs = db.query(new OSQLSynchQuery(query)); + docs = db.query(query).stream().toList(); Assert.assertEquals(1, docs.size()); Assert.assertEquals(1, idx.getInternal().size()); }