ResponseProcessor implements Runnable { @Override public void run() { process.appendResponse( response ); try { process.getCallback().onResponse( response, process.getResult() ); if ( process.isDone() ) { processor.remove( request ); process.stop(); } } catch ( Exception e ) { LOG.error( "Error notifying callback", e ); } } ResponseProcessor( final Response response, final CommandProcess process, final CommandProcessor processor,
                              final Request request ); @Override void run();  }
@Test public void testRun() throws Exception { responseProcessor.run(); verify( commandProcess ).appendResponse( response ); verify( commandProcess ).getCallback(); verify( callback ).onResponse( eq( response ), any( CommandResult.class ) ); verify( commandProcess ).isDone(); verify( commandProcessor ).remove( any( Request.class ) ); verify( commandProcess ).stop(); RuntimeException exception = mock( RuntimeException.class ); doThrow( exception ).when( commandProcess ).isDone(); responseProcessor.run(); verify( exception ).printStackTrace( any( PrintStream.class ) ); }