### Question:
LineageGraphCompletionService implements CompletionService<Graph> { public void waitTillEmpty() throws InterruptedException, ExecutionException { Future<Graph> result; while ( queue.size() > 0 ) { result = poll( 200, TimeUnit.MILLISECONDS ); if ( result != null && !result.isCancelled() ) { try { Graph graph = result.get(); log.debug( "Process Finished --> " + graph ); } catch ( ExecutionException e ) { log.warn( e.getMessage(), e ); } } } } private  LineageGraphCompletionService(); static LineageGraphCompletionService getInstance(); @Override Future<Graph> submit( Callable<Graph> task ); @Override Future<Graph> submit( Runnable task, Graph result ); @Override Future<Graph> take(); @Override Future<Graph> poll(); @Override Future<Graph> poll( long timeout, TimeUnit unit ); void waitTillEmpty();  }### Answer:
@Test public void testWaitTillEmpty() throws Exception { mcs.submit( new Callable<Graph>() { @Override public Graph call() throws Exception { Thread.sleep( 400 ); return GRAPH; } } ); mcs.submit( new Callable<Graph>() { @Override public Graph call() throws Exception { throw new ExecutionException( new Exception( "Exception" ) ); } } ); mcs.submit( new Callable<Graph>() { @Override public Graph call() throws Exception { Thread.sleep( 200 ); return GRAPH; } } ); mcs.waitTillEmpty(); assertNull( mcs.poll() ); }