Skip to content

Commit

Permalink
Extended docGeoWithinTest to test operand $geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
murermader committed Aug 23, 2024
1 parent 0f73eac commit 8ecea7f
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions dbms/src/test/java/org/polypheny/db/mql/MqlGeoFunctionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class MqlGeoFunctionsTest extends MqlTestTemplate {
@BeforeAll
public static void init() {
createMongoDbAdapter();
log.info("Created Mongo adapter successfully.");
log.info( "Created Mongo adapter successfully." );
}


Expand All @@ -54,13 +54,14 @@ public static void createMongoDbAdapter() {
Connection connection = polyphenyDbConnection.getConnection();
try ( Statement statement = connection.createStatement() ) {
TestHelper.addMongodb( mongoAdapterName, statement );
initDatabase(namespaceMongo);
initDatabase( namespaceMongo );
}
} catch ( SQLException e ) {
throw new RuntimeException( e );
}
}


@BeforeEach
public void beforeEach() {
// TODO: I get an error here, if the collection already exists in MongoDB.
Expand Down Expand Up @@ -96,7 +97,8 @@ public void docGeoWithinTest() {
""".formatted( collectionName );
execute( insertDocuments );

String geoWithin = """
DocResult result;
String geoWithinBox = """
db.%s.find({
legacy: {
$geoWithin: {
Expand All @@ -108,7 +110,22 @@ public void docGeoWithinTest() {
}
})
""".formatted( collectionName );
DocResult result = execute( geoWithin );
result = execute( geoWithinBox );
assertEquals( result.data.length, 2 );

String geoWithinGeometry = """
db.%s.find({
legacy: {
$geoWithin: {
$geometry: {
type: "Polygon",
coordinates: [[ [0,0], [0,1], [1,1], [1,0], [0,0] ]]
}
}
}
})
""".formatted( collectionName );
result = execute( geoWithinGeometry );
assertEquals( result.data.length, 2 );
}

Expand Down

0 comments on commit 8ecea7f

Please sign in to comment.