CommandProcessor implements RestProcessor { CommandResult getResult( UUID commandId ) throws CommandException { Preconditions.checkNotNull( commandId ); CommandProcess commandProcess = commands.get( commandId ); if ( commandProcess != null ) { return commandProcess.waitResult(); } else { throw new CommandException( String.format( "Command process not found by id: %s", commandId ) ); } } 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 testGetResult() throws Exception { try { commandProcessor.getResult( COMMAND_ID ); fail( "Expected CommandException" ); } catch ( CommandException e ) { } when( commands.get( COMMAND_ID ) ).thenReturn( process ); commandProcessor.getResult( COMMAND_ID ); verify( process ).waitResult(); }