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