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);
}