MountedFileSystem implements SharedFileSystem { @Override public Single<UUID> store(UUID id, Buffer buffer) { String path = baseDir + "/" + Objects.requireNonNull(id); FileSystem fileSystem = rxJavaVertx.fileSystem(); return fileSystem.existsObservable(path).toSingle().flatMap(found -> { if (found.booleanValue()) { throw new IllegalArgumentException("Specified ID is already used: " + id); } return fileSystem.writeFileObservable(path, buffer).toSingle() .doOnSuccess(v -> { log.info("successfully stored file at {}, its size is {}", path, buffer.length()); }) .map(v -> id); }); } @Inject  MountedFileSystem(@Named("mountedDir") String baseDir, Vertx vertx); @Override Single<File> load(UUID id); @Override Single<UUID> store(UUID id, Buffer buffer); @Override Single<UUID> delete(UUID id);  }
@Test public void testStore(TestContext context) { Async async = context.async(); UUID id = UUID.randomUUID(); Buffer buffer = Buffer.buffer("buffer"); fileSystem.store(id, buffer).subscribe(onNext -> { context.assertEquals(id, onNext); async.complete(); }, context::fail); }