@Test public void testExecute_noAgent() throws Exception { CancelRecipeCommand cmd = new CancelRecipeCommand(); ByteArrayOutputStream os = new ByteArrayOutputStream(); cmd.out = new PrintStream( os, true, "UTF-8" ); cmd.execute(); Assert.assertTrue( os.toString( "UTF-8" ).contains( "No agent found" )); }
@Override public Object execute() throws Exception { if(this.agents != null) { boolean single = (this.agents.size() == 1); for(AgentMessagingInterface agent : this.agents) { this.out.println("Found agent with appname=" + agent.getApplicationName()); if(single) { if(this.scopedInstancePath == null || this.scopedInstancePath.equals(agent.getScopedInstancePath())) { this.out.println("Single agent eligible to cancel recipe"); cancelRecipe(agent.getApplicationName(), agent.getScopedInstancePath()); } } else if(Objects.equals(agent.getApplicationName(), this.applicationName)) { if(this.scopedInstancePath == null || this.scopedInstancePath.equals(agent.getScopedInstancePath())) { this.out.println("Agent is eligible to cancel recipe"); cancelRecipe(this.applicationName, this.scopedInstancePath); } } } } else { this.out.println("No agent found, command not applicable"); } return null; }
CancelRecipeCommand implements Action { @Override public Object execute() throws Exception { if(this.agents != null) { boolean single = (this.agents.size() == 1); for(AgentMessagingInterface agent : this.agents) { this.out.println("Found agent with appname=" + agent.getApplicationName()); if(single) { if(this.scopedInstancePath == null || this.scopedInstancePath.equals(agent.getScopedInstancePath())) { this.out.println("Single agent eligible to cancel recipe"); cancelRecipe(agent.getApplicationName(), agent.getScopedInstancePath()); } } else if(Objects.equals(agent.getApplicationName(), this.applicationName)) { if(this.scopedInstancePath == null || this.scopedInstancePath.equals(agent.getScopedInstancePath())) { this.out.println("Agent is eligible to cancel recipe"); cancelRecipe(this.applicationName, this.scopedInstancePath); } } } } else { this.out.println("No agent found, command not applicable"); } return null; } }
CancelRecipeCommand implements Action { @Override public Object execute() throws Exception { if(this.agents != null) { boolean single = (this.agents.size() == 1); for(AgentMessagingInterface agent : this.agents) { this.out.println("Found agent with appname=" + agent.getApplicationName()); if(single) { if(this.scopedInstancePath == null || this.scopedInstancePath.equals(agent.getScopedInstancePath())) { this.out.println("Single agent eligible to cancel recipe"); cancelRecipe(agent.getApplicationName(), agent.getScopedInstancePath()); } } else if(Objects.equals(agent.getApplicationName(), this.applicationName)) { if(this.scopedInstancePath == null || this.scopedInstancePath.equals(agent.getScopedInstancePath())) { this.out.println("Agent is eligible to cancel recipe"); cancelRecipe(this.applicationName, this.scopedInstancePath); } } } } else { this.out.println("No agent found, command not applicable"); } return null; }  }
CancelRecipeCommand implements Action { @Override public Object execute() throws Exception { if(this.agents != null) { boolean single = (this.agents.size() == 1); for(AgentMessagingInterface agent : this.agents) { this.out.println("Found agent with appname=" + agent.getApplicationName()); if(single) { if(this.scopedInstancePath == null || this.scopedInstancePath.equals(agent.getScopedInstancePath())) { this.out.println("Single agent eligible to cancel recipe"); cancelRecipe(agent.getApplicationName(), agent.getScopedInstancePath()); } } else if(Objects.equals(agent.getApplicationName(), this.applicationName)) { if(this.scopedInstancePath == null || this.scopedInstancePath.equals(agent.getScopedInstancePath())) { this.out.println("Agent is eligible to cancel recipe"); cancelRecipe(this.applicationName, this.scopedInstancePath); } } } } else { this.out.println("No agent found, command not applicable"); } return null; }  @Override Object execute(); }
CancelRecipeCommand implements Action { @Override public Object execute() throws Exception { if(this.agents != null) { boolean single = (this.agents.size() == 1); for(AgentMessagingInterface agent : this.agents) { this.out.println("Found agent with appname=" + agent.getApplicationName()); if(single) { if(this.scopedInstancePath == null || this.scopedInstancePath.equals(agent.getScopedInstancePath())) { this.out.println("Single agent eligible to cancel recipe"); cancelRecipe(agent.getApplicationName(), agent.getScopedInstancePath()); } } else if(Objects.equals(agent.getApplicationName(), this.applicationName)) { if(this.scopedInstancePath == null || this.scopedInstancePath.equals(agent.getScopedInstancePath())) { this.out.println("Agent is eligible to cancel recipe"); cancelRecipe(this.applicationName, this.scopedInstancePath); } } } } else { this.out.println("No agent found, command not applicable"); } return null; }  @Override Object execute();  }