MongoUtil { public Future<Void> insert(T md, String id) { String s = Json.encodePrettily(md); JsonObject document = new JsonObject(s); encode(document, id); return cli.insert(collection, document).mapEmpty(); } 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 testInsert(TestContext context) { MongoClient cli = new FakeMongoClient(); MongoUtil<DeploymentDescriptor> util = new MongoUtil<>("collection", cli); util.insert(new DeploymentDescriptor(), "1").onComplete(res -> { context.assertTrue(res.failed()); context.assertEquals("insert failed", res.cause().getMessage()); }); }