MongoUtil { public Future<Boolean> delete(String id) { JsonObject jq = new JsonObject().put("_id", id); return cli.removeDocument(collection, jq).compose(res -> { if (res.getRemovedCount() == 0) { return Future.succeededFuture(Boolean.FALSE); } else { return Future.succeededFuture(Boolean.TRUE); } }); } 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 testDelete(TestContext context) { MongoClient cli = new FakeMongoClient(); MongoUtil<String> util = new MongoUtil<>("collection", cli); util.delete("1").onComplete(res -> { context.assertTrue(res.failed()); context.assertEquals("removeDocument failed", res.cause().getMessage()); }); }
@Test public void testDelete404(TestContext context) { MongoClient cli = new FakeMongoClient(); MongoUtil<String> util = new MongoUtil<>("collection", cli); util.delete("404").onComplete(res -> { context.assertTrue(res.succeeded()); context.assertEquals(Boolean.FALSE, res.result()); }); }