Skip to content

Commit

Permalink
refactor(test): moved lucene tests to the new query engine
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Nov 13, 2024
1 parent 99e18fc commit d3ff351
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.executor.OResult;
import com.orientechnologies.orient.core.sql.executor.OResultSet;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import java.io.File;
import java.util.List;
import org.junit.After;
Expand Down Expand Up @@ -63,10 +63,8 @@ public void testDeleteLuceneIndex1() {

db = dbPool.acquire();
// @maggiolo00 Remove the next three lines and the test will not fail anymore
OSQLSynchQuery<ODocument> query =
new OSQLSynchQuery<ODocument>(
"select from test where [latitude,longitude] WITHIN [[50.0,8.0],[51.0,9.0]]");
List<ODocument> result = db.command(query).execute();
String query = "select from test where [latitude,longitude] WITHIN [[50.0,8.0],[51.0,9.0]]";
List<OResult> result = db.command(query).stream().toList();
Assert.assertEquals(insertcount, result.size());
db.close();
dbPool.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.orientechnologies.orient.core.metadata.schema.OClass;
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.spatial.collections.OSpatialCompositeKey;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -52,10 +51,12 @@ public void boundingBoxTest() {
db.save(document);

List<?> query =
db.query(
new OSQLSynchQuery<ODocument>(
db
.query(
"SELECT FROM Point WHERE [latitude, longitude] WITHIN"
+ " [[42.26531323615103,-83.71986351411135],[42.29239784478525,-83.7662120858887]]"));
+ " [[42.26531323615103,-83.71986351411135],[42.29239784478525,-83.7662120858887]]")
.stream()
.toList();

Assert.assertEquals(query.size(), 1);
}
Expand All @@ -79,10 +80,12 @@ public void boundingBoxTestTxRollBack() {
db.save(document);

List<?> query =
db.query(
new OSQLSynchQuery<ODocument>(
db
.query(
"SELECT FROM Point WHERE [latitude, longitude] WITHIN"
+ " [[42.26531323615103,-83.71986351411135],[42.29239784478525,-83.7662120858887]]"));
+ " [[42.26531323615103,-83.71986351411135],[42.29239784478525,-83.7662120858887]]")
.stream()
.toList();

Assert.assertEquals(1, query.size());

Expand Down Expand Up @@ -121,10 +124,12 @@ public void boundingBoxTestTxRollBack() {
db.rollback();

query =
db.query(
new OSQLSynchQuery<ODocument>(
db
.query(
"SELECT FROM Point WHERE [latitude, longitude] WITHIN"
+ " [[42.26531323615103,-83.71986351411135],[42.29239784478525,-83.7662120858887]]"));
+ " [[42.26531323615103,-83.71986351411135],[42.29239784478525,-83.7662120858887]]")
.stream()
.toList();

Assert.assertEquals(0, query.size());
}
Expand All @@ -150,10 +155,12 @@ public void boundingBoxTestTxCommit() {
db.commit();

List<?> query =
db.query(
new OSQLSynchQuery<ODocument>(
db
.query(
"SELECT FROM Point WHERE [latitude, longitude] WITHIN"
+ " [[42.26531323615103,-83.71986351411135],[42.29239784478525,-83.7662120858887]]"));
+ " [[42.26531323615103,-83.71986351411135],[42.29239784478525,-83.7662120858887]]")
.stream()
.toList();

Assert.assertEquals(1, query.size());

Expand Down Expand Up @@ -196,10 +203,12 @@ public void boundingBoxTestTxCommit() {
db.delete(document);

query =
db.query(
new OSQLSynchQuery<ODocument>(
db
.query(
"SELECT FROM Point WHERE [latitude, longitude] WITHIN"
+ " [[42.26531323615103,-83.71986351411135],[42.29239784478525,-83.7662120858887]]"));
+ " [[42.26531323615103,-83.71986351411135],[42.29239784478525,-83.7662120858887]]")
.stream()
.toList();

Assert.assertEquals(0, query.size());

Expand All @@ -212,10 +221,12 @@ public void boundingBoxTestTxCommit() {
db.rollback();

query =
db.query(
new OSQLSynchQuery<ODocument>(
db
.query(
"SELECT FROM Point WHERE [latitude, longitude] WITHIN"
+ " [[42.26531323615103,-83.71986351411135],[42.29239784478525,-83.7662120858887]]"));
+ " [[42.26531323615103,-83.71986351411135],[42.29239784478525,-83.7662120858887]]")
.stream()
.toList();

Assert.assertEquals(1, query.size());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
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.executor.OResult;
import com.orientechnologies.orient.core.sql.executor.OResultSet;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
Expand Down Expand Up @@ -128,13 +128,13 @@ protected void queryOldNear() {
String query =
"select *,$distance from Place where [latitude,longitude,$spatial] NEAR"
+ " [41.893056,12.482778,{\"maxDistance\": 2}]";
List<ODocument> docs = db.query(new OSQLSynchQuery<ODocument>(query));
List<OResult> docs = db.query(query).stream().toList();

Assert.assertEquals(1, docs.size());

// Assert.assertEquals(1.6229442709302933, docs.get(0).field("$distance"));

assertThat(docs.get(0).<Double>field("$distance")).isEqualTo(1.6229442709302933);
assertThat(docs.get(0).<Double>getProperty("$distance")).isEqualTo(1.6230287806012604);
}

@Test
Expand Down

0 comments on commit d3ff351

Please sign in to comment.