BlockingCommandCallback implements CommandCallback { @Override public void onResponse( final Response response, final CommandResult commandResult ) { if ( callback != null ) { callback.onResponse( response, commandResult ); } this.commandResult = commandResult; if ( commandResult.hasCompleted() || commandResult.hasTimedOut() ) { completionSemaphore.release(); } } BlockingCommandCallback( CommandCallback callback ); @Override void onResponse( final Response response, final CommandResult commandResult ); Semaphore getCompletionSemaphore(); CommandResult getCommandResult();  }
@Test public void testOnResponse() throws Exception { blockingCommandCallback.completionSemaphore = completionSemaphore; blockingCommandCallback.onResponse( response, commandResult ); verify( completionSemaphore ).release(); verify( callback ).onResponse( response, commandResult ); }