@Test public void testSearchNotExistId(TestContext context) { ThumbnailMetadataRegistry registry = new ThumbnailMetadataRegistryOnPostgres(client); UUID videoId = UUID.randomUUID(); Async async = context.async(); registry.search(videoId).count().subscribe(count -> { context.assertEquals(0, count); }, context::fail, async::complete); }
@Override public Observable<ThumbnailMetadata> search(UUID videoId) { return asyncSQLClient.getConnectionObservable() .flatMap(con -> { return con.queryWithParamsObservable(SQL_TO_SELECT, new JsonArray().add(videoId.toString())) .doAfterTerminate(con::close); }) .flatMapIterable(ResultSet::getRows) .map(ThumbnailMetadata::valueOf); }
ThumbnailMetadataRegistryOnPostgres implements ThumbnailMetadataRegistry { @Override public Observable<ThumbnailMetadata> search(UUID videoId) { return asyncSQLClient.getConnectionObservable() .flatMap(con -> { return con.queryWithParamsObservable(SQL_TO_SELECT, new JsonArray().add(videoId.toString())) .doAfterTerminate(con::close); }) .flatMapIterable(ResultSet::getRows) .map(ThumbnailMetadata::valueOf); } }
ThumbnailMetadataRegistryOnPostgres implements ThumbnailMetadataRegistry { @Override public Observable<ThumbnailMetadata> search(UUID videoId) { return asyncSQLClient.getConnectionObservable() .flatMap(con -> { return con.queryWithParamsObservable(SQL_TO_SELECT, new JsonArray().add(videoId.toString())) .doAfterTerminate(con::close); }) .flatMapIterable(ResultSet::getRows) .map(ThumbnailMetadata::valueOf); }  }
ThumbnailMetadataRegistryOnPostgres implements ThumbnailMetadataRegistry { @Override public Observable<ThumbnailMetadata> search(UUID videoId) { return asyncSQLClient.getConnectionObservable() .flatMap(con -> { return con.queryWithParamsObservable(SQL_TO_SELECT, new JsonArray().add(videoId.toString())) .doAfterTerminate(con::close); }) .flatMapIterable(ResultSet::getRows) .map(ThumbnailMetadata::valueOf); }  @Override Single<ThumbnailMetadata> store(ThumbnailMetadata metadata); @Override Observable<ThumbnailMetadata> search(UUID videoId); }
ThumbnailMetadataRegistryOnPostgres implements ThumbnailMetadataRegistry { @Override public Observable<ThumbnailMetadata> search(UUID videoId) { return asyncSQLClient.getConnectionObservable() .flatMap(con -> { return con.queryWithParamsObservable(SQL_TO_SELECT, new JsonArray().add(videoId.toString())) .doAfterTerminate(con::close); }) .flatMapIterable(ResultSet::getRows) .map(ThumbnailMetadata::valueOf); }  @Override Single<ThumbnailMetadata> store(ThumbnailMetadata metadata); @Override Observable<ThumbnailMetadata> search(UUID videoId);  }