FileMetadataRegistryOnPostgres implements FileMetadataRegistry { @Override public Single<FileMetadata> update(FileMetadata metadata) { return postgreSQLClient.getConnectionObservable() .flatMap(con -> { JsonArray params = new JsonArray() .add(metadata.getName()) .add(metadata.getMimeType().toString()) .add(metadata.getContentLength()) .add(metadata.getGenerated()) .add(metadata.getFileId().toString()); return con.updateWithParamsObservable("UPDATE file_metadata SET name = ?, mime_type = ?, content_length = ?, generated = ? WHERE id = ?", params) .doAfterTerminate(con::close); }).toSingle().map(ur -> { return metadata; }); }  @Override Observable<FileMetadata> iterate(); @Override Single<FileMetadata> store(FileMetadata metadata); @Override Single<FileMetadata> update(FileMetadata metadata); @Override Single<FileMetadata> load(UUID fileId); @Override Single<UUID> delete(UUID fileId);  }
@Test public void testUpdate(TestContext context) { UUID fileId = UUID.randomUUID(); Async async = context.async(2); FileMetadata metadata = new FileMetadata(fileId, "name", MimeType.valueOf("text/plain"), 6, Instant.now()); registry.store(metadata).flatMap(v -> { return registry.update(new FileMetadata(fileId, "updated", MimeType.valueOf("text/plain"), 6, Instant.now())); }).flatMap(updated -> { return registry.load(fileId); }).subscribe(loaded -> { context.assertNotEquals(metadata, loaded); context.assertEquals(loaded.getName(), "updated"); async.complete(); }, context::fail); }