MongoUtil { public Future<List<T>> getAll(Class<T> clazz) { final String q = "{}"; JsonObject jq = new JsonObject(q); return cli.find(collection, jq).compose(resl -> { List<T> ml = new LinkedList<>(); for (JsonObject jo : resl) { decode(jo); T env = Json.decodeValue(jo.encode(), clazz); ml.add(env); } return Future.succeededFuture(ml); }); } MongoUtil(String collection, MongoClient cli); Future<Boolean> delete(String id); Future<Void> init(boolean reset); Future<Void> add(T env, String id); Future<Void> insert(T md, String id); Future<List<T>> getAll(Class<T> clazz); void encode(JsonObject j, String id); void decode(JsonObject j);  }
@Test public void testGetAll(TestContext context) { MongoClient cli = new FakeMongoClient(); MongoUtil<DeploymentDescriptor> util = new MongoUtil<>("collection", cli); util.getAll(DeploymentDescriptor.class).onComplete(res -> { context.assertTrue(res.failed()); context.assertEquals("find failed", res.cause().getMessage()); }); }