Search in sources :

Example 1 with Datastore

use of org.hypertrace.core.documentstore.Datastore in project document-store by hypertrace.

the class MongoQueryExecutorIntegrationTest method init.

@BeforeAll
public static void init() throws IOException {
    mongo = new GenericContainer<>(DockerImageName.parse("mongo:4.4.0")).withExposedPorts(27017).waitingFor(Wait.forListeningPort());
    mongo.start();
    DatastoreProvider.register("MONGO", MongoDatastore.class);
    Map<String, String> mongoConfig = new HashMap<>();
    mongoConfig.putIfAbsent("host", "localhost");
    mongoConfig.putIfAbsent("port", mongo.getMappedPort(27017).toString());
    Config config = ConfigFactory.parseMap(mongoConfig);
    Datastore datastore = DatastoreProvider.getDatastore("Mongo", config);
    datastore.deleteCollection(COLLECTION_NAME);
    datastore.createCollection(COLLECTION_NAME, null);
    collection = datastore.getCollection(COLLECTION_NAME);
    Map<Key, Document> documents = createDocumentsFromResource("mongo/collection_data.json");
    collection.bulkUpsert(documents);
}
Also used : Datastore(org.hypertrace.core.documentstore.Datastore) HashMap(java.util.HashMap) Config(com.typesafe.config.Config) Document(org.hypertrace.core.documentstore.Document) Key(org.hypertrace.core.documentstore.Key) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

Config (com.typesafe.config.Config)1 HashMap (java.util.HashMap)1 Datastore (org.hypertrace.core.documentstore.Datastore)1 Document (org.hypertrace.core.documentstore.Document)1 Key (org.hypertrace.core.documentstore.Key)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1