CommandResponseListener extends RequestListener implements Disposable { @Override public Object onRequest( final Payload payload ) { final CommandResponse commandResponse = payload.getMessage( CommandResponse.class ); if ( commandResponse != null ) { CommandCallback callback = callbacks.get( commandResponse.getRequestId() ); if ( callback != null ) { callback.onResponse( commandResponse.getResponse(), commandResponse.getCommandResult() ); } } else { LOG.warn( "Null response" ); } return null; } CommandResponseListener(); @Override void dispose(); void addCallback( UUID commandId, CommandCallback callback, int timeout, final Semaphore semaphore ); @Override Object onRequest( final Payload payload );  }
@Test public void testOnRequest() throws Exception { commandResponseListener.onRequest( payload ); verify( callback ).onResponse( any( Response.class ), any( CommandResult.class ) ); when( payload.getMessage( CommandResponse.class ) ).thenReturn( null ); commandResponseListener.onRequest( payload ); verify( callback ).onResponse( any( Response.class ), any( CommandResult.class ) ); }