CommandResponseListener extends RequestListener implements Disposable { public void addCallback( UUID commandId, CommandCallback callback, int timeout, final Semaphore semaphore ) { if ( callback != null ) { callbacks.put( commandId, callback, timeout * 1000L + Timeouts.COMMAND_REQUEST_MESSAGE_TIMEOUT * 2 * 1000, new CommandResponseExpiryCallback( semaphore ) ); } } CommandResponseListener(); @Override void dispose(); void addCallback( UUID commandId, CommandCallback callback, int timeout, final Semaphore semaphore ); @Override Object onRequest( final Payload payload );  }
@Test public void testAddCallback() throws Exception { commandResponseListener.addCallback( COMMAND_ID, callback, ( int ) TIMEOUT, semaphore ); verify( callbacks ).put( eq( COMMAND_ID ), eq( callback ), eq( TIMEOUT * 1000 + Timeouts.COMMAND_REQUEST_MESSAGE_TIMEOUT * 2 * 1000 ), isA( EntryExpiryCallback.class ) ); }