Skip to content

Commit

Permalink
added correct syntax to specific store during collection deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
datomo committed Aug 29, 2024
1 parent 87d612e commit 74c4ea9
Showing 1 changed file with 24 additions and 27 deletions.
51 changes: 24 additions & 27 deletions dbms/src/test/java/org/polypheny/db/mql/MqlGeoFunctionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,26 @@

package org.polypheny.db.mql;

import static org.junit.jupiter.api.Assertions.assertEquals;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.polypheny.db.TestHelper;
import org.polypheny.db.TestHelper.JdbcConnection;
import org.polypheny.db.webui.models.results.DocResult;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Map;
import java.util.Objects;

import static org.junit.jupiter.api.Assertions.assertEquals;

@SuppressWarnings("SqlNoDataSourceInspection")
@Tag("adapter")
@Slf4j
Expand All @@ -45,6 +44,9 @@ public class MqlGeoFunctionsTest extends MqlTestTemplate {
final static String namespaceMongo = "test_mongo";
final static String collectionName = "doc";
final static String mongoAdapterName = "mongo";
final static String mongoCollection = "mongo";
final static String defaultCollection = "default";
final static List<String> collections = List.of( defaultCollection, mongoCollection );
final static ArrayList<String> namespaces = new ArrayList<>();


Expand All @@ -53,6 +55,13 @@ public static void init() {
namespaces.add( namespace );
namespaces.add( namespaceMongo );
addMongoDbAdapter();

for ( String collection : collections ) {
String createCollection = """
db.createCollection(%s).store(%s)
""".formatted( collection, collection.equals( "mongo" ) ? mongoAdapterName : "hsqldb" );
execute( createCollection, namespace );
}
}


Expand Down Expand Up @@ -86,19 +95,7 @@ public static void removeMongoDbAdapter() {
public void docGeoIntersectsTest() {
ArrayList<DocResult> results = new ArrayList<>();

for ( String ns : namespaces ) {
String createCollection = """
db.createCollection(%s)
""".formatted( ns );
execute( createCollection, ns );

if ( ns.equals( namespaceMongo ) ) {
execute( String.format( "db.%s.addPlacement(\"%s\")", ns, mongoAdapterName ) );
execute( String.format( "db.%s.deletePlacement(\"%s\")", ns, "hsqldb" ) );
} else {
execute( String.format( "db.%s.addPlacement(\"%s\")", ns, "hsqldb" ) );
execute( String.format( "db.%s.deletePlacement(\"%s\")", ns, mongoAdapterName ) );
}
for ( String collection : collections ) {

String insertDocuments = """
db.%s.insertMany([
Expand All @@ -118,8 +115,8 @@ public void docGeoIntersectsTest() {
legacy: [2,2]
}
])
""".formatted( ns );
execute( insertDocuments, ns );
""".formatted( collection );
execute( insertDocuments, namespace );

DocResult result;
String geoIntersects = """
Expand All @@ -133,8 +130,8 @@ public void docGeoIntersectsTest() {
}
}
})
""".formatted( ns );
result = execute( geoIntersects, ns );
""".formatted( collection );
result = execute( geoIntersects, namespace );
results.add( result );
}

Expand Down

0 comments on commit 74c4ea9

Please sign in to comment.