use of com.mongodb.client.gridfs.GridFSFindIterable in project georocket by georocket.
the class MongoDBStoreTest method validateAfterStoreAdd.
@Override
protected void validateAfterStoreAdd(TestContext context, Vertx vertx, String path, Handler<AsyncResult<Void>> handler) {
vertx.executeBlocking(f -> {
try (MongoClient client = new MongoClient(mongoConnector.serverAddress)) {
MongoDatabase db = client.getDatabase(MongoDBTestConnector.MONGODB_DBNAME);
GridFSBucket gridFS = GridFSBuckets.create(db);
GridFSFindIterable files = gridFS.find();
GridFSFile file = files.first();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
gridFS.downloadToStream(file.getFilename(), baos);
String contents = new String(baos.toByteArray(), StandardCharsets.UTF_8);
context.assertEquals(CHUNK_CONTENT, contents);
}
f.complete();
}, handler);
}
Aggregations