Skip to content

Commit

Permalink
It is possible to run the query on mongo and internally by adding / r…
Browse files Browse the repository at this point in the history
…emoving the adapter for each query
  • Loading branch information
murermader committed Aug 27, 2024
1 parent 337924e commit d50f158
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions dbms/src/test/java/org/polypheny/db/mql/MqlGeoFunctionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@ public class MqlGeoFunctionsTest extends MqlTestTemplate {

@BeforeAll
public static void init() {
createMongoDbAdapter();
namespaces.add( namespace );
namespaces.add( namespaceMongo );
}


public static void createMongoDbAdapter() {
public static void addMongoDbAdapter() {
try ( JdbcConnection polyphenyDbConnection = new JdbcConnection( true ) ) {
Connection connection = polyphenyDbConnection.getConnection();
try ( Statement statement = connection.createStatement() ) {
Expand All @@ -69,22 +68,31 @@ public static void createMongoDbAdapter() {
}


@BeforeEach
public void beforeEach() {
// Clear both collections before each test
for ( String ns : namespaces ) {
execute( "db.%s.deleteMany({})".formatted( ns ), ns );
public static void removeMongoDbAdapter() {
try ( JdbcConnection polyphenyDbConnection = new JdbcConnection( true ) ) {
Connection connection = polyphenyDbConnection.getConnection();
try ( Statement statement = connection.createStatement() ) {
TestHelper.executeSQL( statement, "DROP NAMESPACE \"%s\"".formatted( namespaceMongo ) );
TestHelper.dropAdapter( mongoAdapterName, statement );
}
} catch ( SQLException e ) {
throw new RuntimeException( e );
}
}

private void executeOnMongoAndInternally(){

}

@Test
public void docGeoIntersectsTest() {
ArrayList<DocResult> results = new ArrayList<>();

for ( String ns : namespaces ) {
// TODO: We are using MongoDB twice...
initDatabase( ns );
if ( ns.equals( namespaceMongo ) ) {
addMongoDbAdapter();
}

String insertDocuments = """
db.%s.insertMany([
{
Expand Down Expand Up @@ -121,6 +129,10 @@ public void docGeoIntersectsTest() {
""".formatted( ns );
result = execute( geoIntersects, ns );
results.add( result );

if ( ns.equals( namespaceMongo ) ) {
removeMongoDbAdapter();
}
}

compareResults( results.get( 0 ), results.get( 1 ) );
Expand Down

0 comments on commit d50f158

Please sign in to comment.