@Test public void testLoad(TestContext context) { Async async = context.async(); UUID id = UUID.randomUUID(); Buffer buffer = Buffer.buffer("buffer"); fileSystem.store(id, buffer).toObservable().flatMap(v -> { return fileSystem.load(id).toObservable(); }) .subscribe(file -> { try { context.assertEquals("buffer", Files.lines(file.toPath(), StandardCharsets.UTF_8).findFirst().get()); } catch (IOException e) { throw new UncheckedIOException(e); } }, context::fail, () -> { async.complete(); }); }
@Override public Single<File> load(UUID id) { String path = baseDir + "/" + Objects.requireNonNull(id); File file = new File(path); if (!file.exists()) { return Single.error(new IllegalArgumentException("File not found with fileId " + id)); } return Single.just(file); }
MountedFileSystem implements SharedFileSystem { @Override public Single<File> load(UUID id) { String path = baseDir + "/" + Objects.requireNonNull(id); File file = new File(path); if (!file.exists()) { return Single.error(new IllegalArgumentException("File not found with fileId " + id)); } return Single.just(file); } }
MountedFileSystem implements SharedFileSystem { @Override public Single<File> load(UUID id) { String path = baseDir + "/" + Objects.requireNonNull(id); File file = new File(path); if (!file.exists()) { return Single.error(new IllegalArgumentException("File not found with fileId " + id)); } return Single.just(file); } @Inject  MountedFileSystem(@Named("mountedDir") String baseDir, Vertx vertx); }
MountedFileSystem implements SharedFileSystem { @Override public Single<File> load(UUID id) { String path = baseDir + "/" + Objects.requireNonNull(id); File file = new File(path); if (!file.exists()) { return Single.error(new IllegalArgumentException("File not found with fileId " + id)); } return Single.just(file); } @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); }
MountedFileSystem implements SharedFileSystem { @Override public Single<File> load(UUID id) { String path = baseDir + "/" + Objects.requireNonNull(id); File file = new File(path); if (!file.exists()) { return Single.error(new IllegalArgumentException("File not found with fileId " + id)); } return Single.just(file); } @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);  }