RunResponseHandler implements ResponseHandler { @Override public void onSuccess( Map<String,Value> metadata ) { queryKeys = metadataExtractor.extractQueryKeys( metadata ); resultAvailableAfter = metadataExtractor.extractResultAvailableAfter( metadata ); queryId = metadataExtractor.extractQueryId( metadata ); completeRunFuture( null ); } RunResponseHandler( MetadataExtractor metadataExtractor );  RunResponseHandler( CompletableFuture<Throwable> runCompletedFuture, MetadataExtractor metadataExtractor ); @Override void onSuccess( Map<String,Value> metadata ); @Override void onFailure( Throwable error ); @Override void onRecord( Value[] fields ); QueryKeys queryKeys(); long resultAvailableAfter(); long queryId(); CompletableFuture<Throwable> runFuture();  }
@Test void shouldNotifyCompletionFutureOnSuccess() throws Exception { CompletableFuture<Throwable> runCompletedFuture = new CompletableFuture<>(); RunResponseHandler handler = newHandler( runCompletedFuture ); assertFalse( runCompletedFuture.isDone() ); handler.onSuccess( emptyMap() ); assertTrue( runCompletedFuture.isDone() ); assertNull( runCompletedFuture.get() ); }