@Test public void testExecute_testException() throws Exception { AgentStatusCommand cmd = new AgentStatusCommand(); AgentMessagingInterface am1 = Mockito.mock( AgentMessagingInterface.class ); Mockito.doThrow( new RuntimeException( "for test" )).when( am1 ).agentStatus(); cmd.agents = Arrays.asList( am1 ); Assert.assertNull( cmd.execute()); Mockito.verify( am1, Mockito.only()).agentStatus(); }
@Override public Object execute() throws Exception { if( this.agents != null ) { for( AgentMessagingInterface agent : this.agents ) { try { System.out.println( agent.agentStatus()); System.out.println( "" ); } catch( Exception e ) { this.logger.warning( "An error occurred while giving agent status. " + e.getMessage()); Utils.logException( this.logger, e ); } } } return null; }
AgentStatusCommand implements Action { @Override public Object execute() throws Exception { if( this.agents != null ) { for( AgentMessagingInterface agent : this.agents ) { try { System.out.println( agent.agentStatus()); System.out.println( "" ); } catch( Exception e ) { this.logger.warning( "An error occurred while giving agent status. " + e.getMessage()); Utils.logException( this.logger, e ); } } } return null; } }
AgentStatusCommand implements Action { @Override public Object execute() throws Exception { if( this.agents != null ) { for( AgentMessagingInterface agent : this.agents ) { try { System.out.println( agent.agentStatus()); System.out.println( "" ); } catch( Exception e ) { this.logger.warning( "An error occurred while giving agent status. " + e.getMessage()); Utils.logException( this.logger, e ); } } } return null; }  }
AgentStatusCommand implements Action { @Override public Object execute() throws Exception { if( this.agents != null ) { for( AgentMessagingInterface agent : this.agents ) { try { System.out.println( agent.agentStatus()); System.out.println( "" ); } catch( Exception e ) { this.logger.warning( "An error occurred while giving agent status. " + e.getMessage()); Utils.logException( this.logger, e ); } } } return null; }  @Override Object execute(); }
AgentStatusCommand implements Action { @Override public Object execute() throws Exception { if( this.agents != null ) { for( AgentMessagingInterface agent : this.agents ) { try { System.out.println( agent.agentStatus()); System.out.println( "" ); } catch( Exception e ) { this.logger.warning( "An error occurred while giving agent status. " + e.getMessage()); Utils.logException( this.logger, e ); } } } return null; }  @Override Object execute();  }