CommandProcessor implements RestProcessor { @Override public void handleHeartbeat( final HeartBeat heartBeat ) { LOG.debug( String.format( "Heartbeat:%n%s", jsonUtil.to( heartBeat ) ) ); for ( final HeartbeatListener listener : listeners ) { notifierPool.submit( new Runnable() { @Override public void run() { try { listener.onHeartbeat( heartBeat ); } catch ( Exception e ) { LOG.error( "Error in handleHeartbeat", e ); } } } ); } } CommandProcessor( final HostRegistry hostRegistry, final IdentityManager identityManager ); void addListener( HeartbeatListener listener ); void removeListener( HeartbeatListener listener ); void dispose(); @Override void handleHeartbeat( final HeartBeat heartBeat ); @Override Set<String> getRequests( final String hostId ); @Override void handleResponse( final Response response );  }
@Test public void testHandleHeartbeat() throws Exception { commandProcessor.listeners = Sets.newHashSet( heartbeatListener ); commandProcessor.handleHeartbeat( heartBeat ); verify( notifierPool ).submit( isA( Runnable.class ) ); }