@Test public void testWithNonExistingPath(TestContext tc) { Async async = tc.async(); store = factory.create(vertx, new JsonObject().put("path", "src/test/missing") .put("filesets", new JsonArray().add(new JsonObject().put("pattern", "*.json")))); store.get().onComplete(ar -> { assertThat(ar.succeeded()).isTrue(); assertThat(ar.result()).isEqualTo(Buffer.buffer("{}")); async.complete(); }); }
@Override public Future<Buffer> get() { return vertx.<List<File>>executeBlocking(promise -> { try { promise.complete(FileSet.traverse(path).stream().sorted().collect(Collectors.toList())); } catch (Throwable e) { promise.fail(e); } }).flatMap(files -> { List<Future> futures = new ArrayList<>(); for (FileSet set : filesets) { Promise<JsonObject> promise = vertx.promise(); set.buildConfiguration(files, json -> { if (json.failed()) { promise.fail(json.cause()); } else { promise.complete(json.result()); } }); futures.add(promise.future()); } return CompositeFuture.all(futures); }).map(compositeFuture -> { JsonObject json = new JsonObject(); compositeFuture.<JsonObject>list().forEach(config -> json.mergeIn(config, true)); return json.toBuffer(); }); }
DirectoryConfigStore implements ConfigStore { @Override public Future<Buffer> get() { return vertx.<List<File>>executeBlocking(promise -> { try { promise.complete(FileSet.traverse(path).stream().sorted().collect(Collectors.toList())); } catch (Throwable e) { promise.fail(e); } }).flatMap(files -> { List<Future> futures = new ArrayList<>(); for (FileSet set : filesets) { Promise<JsonObject> promise = vertx.promise(); set.buildConfiguration(files, json -> { if (json.failed()) { promise.fail(json.cause()); } else { promise.complete(json.result()); } }); futures.add(promise.future()); } return CompositeFuture.all(futures); }).map(compositeFuture -> { JsonObject json = new JsonObject(); compositeFuture.<JsonObject>list().forEach(config -> json.mergeIn(config, true)); return json.toBuffer(); }); } }
DirectoryConfigStore implements ConfigStore { @Override public Future<Buffer> get() { return vertx.<List<File>>executeBlocking(promise -> { try { promise.complete(FileSet.traverse(path).stream().sorted().collect(Collectors.toList())); } catch (Throwable e) { promise.fail(e); } }).flatMap(files -> { List<Future> futures = new ArrayList<>(); for (FileSet set : filesets) { Promise<JsonObject> promise = vertx.promise(); set.buildConfiguration(files, json -> { if (json.failed()) { promise.fail(json.cause()); } else { promise.complete(json.result()); } }); futures.add(promise.future()); } return CompositeFuture.all(futures); }).map(compositeFuture -> { JsonObject json = new JsonObject(); compositeFuture.<JsonObject>list().forEach(config -> json.mergeIn(config, true)); return json.toBuffer(); }); } DirectoryConfigStore(Vertx vertx, JsonObject configuration); }
DirectoryConfigStore implements ConfigStore { @Override public Future<Buffer> get() { return vertx.<List<File>>executeBlocking(promise -> { try { promise.complete(FileSet.traverse(path).stream().sorted().collect(Collectors.toList())); } catch (Throwable e) { promise.fail(e); } }).flatMap(files -> { List<Future> futures = new ArrayList<>(); for (FileSet set : filesets) { Promise<JsonObject> promise = vertx.promise(); set.buildConfiguration(files, json -> { if (json.failed()) { promise.fail(json.cause()); } else { promise.complete(json.result()); } }); futures.add(promise.future()); } return CompositeFuture.all(futures); }).map(compositeFuture -> { JsonObject json = new JsonObject(); compositeFuture.<JsonObject>list().forEach(config -> json.mergeIn(config, true)); return json.toBuffer(); }); } DirectoryConfigStore(Vertx vertx, JsonObject configuration); @Override Future<Buffer> get(); @Override Future<Void> close(); }
DirectoryConfigStore implements ConfigStore { @Override public Future<Buffer> get() { return vertx.<List<File>>executeBlocking(promise -> { try { promise.complete(FileSet.traverse(path).stream().sorted().collect(Collectors.toList())); } catch (Throwable e) { promise.fail(e); } }).flatMap(files -> { List<Future> futures = new ArrayList<>(); for (FileSet set : filesets) { Promise<JsonObject> promise = vertx.promise(); set.buildConfiguration(files, json -> { if (json.failed()) { promise.fail(json.cause()); } else { promise.complete(json.result()); } }); futures.add(promise.future()); } return CompositeFuture.all(futures); }).map(compositeFuture -> { JsonObject json = new JsonObject(); compositeFuture.<JsonObject>list().forEach(config -> json.mergeIn(config, true)); return json.toBuffer(); }); } DirectoryConfigStore(Vertx vertx, JsonObject configuration); @Override Future<Buffer> get(); @Override Future<Void> close();  }