@Test public void executeExisting() { CommandExecution commandExecution = mock(CommandExecution.class); ArgumentSet argumentSet = mock(ArgumentSet.class); when(argumentSet.get(eq(0))).thenReturn("subA"); when(argumentSet.isEmpty()).thenReturn(false); when(argumentSet.toArray()).thenReturn(new String[]{"subA", "arg1", "arg2"}); when(commandExecution.getArguments()).thenReturn( argumentSet ); nestedCommand.execute(commandExecution); verify(commandExecutor).execute( eq(nestedCommands.get("subA")), any(), eq(new String[]{"arg1", "arg2"}) ); }
@Override public void execute(CommandExecution execution) { if (execution.getArguments().isEmpty() || !nestedCommands.containsKey(execution.getArguments().get(0))) { this.sendHelp(execution); } else { this.executeInternal(execution, execution.getArguments().get(0)); } }
NestedCommand implements Command { @Override public void execute(CommandExecution execution) { if (execution.getArguments().isEmpty() || !nestedCommands.containsKey(execution.getArguments().get(0))) { this.sendHelp(execution); } else { this.executeInternal(execution, execution.getArguments().get(0)); } } }
NestedCommand implements Command { @Override public void execute(CommandExecution execution) { if (execution.getArguments().isEmpty() || !nestedCommands.containsKey(execution.getArguments().get(0))) { this.sendHelp(execution); } else { this.executeInternal(execution, execution.getArguments().get(0)); } } NestedCommand(Map<String, CommandRegistration> nestedCommands, CommandExecutor commandExecutor, InternalizationService internalizationService); }
NestedCommand implements Command { @Override public void execute(CommandExecution execution) { if (execution.getArguments().isEmpty() || !nestedCommands.containsKey(execution.getArguments().get(0))) { this.sendHelp(execution); } else { this.executeInternal(execution, execution.getArguments().get(0)); } } NestedCommand(Map<String, CommandRegistration> nestedCommands, CommandExecutor commandExecutor, InternalizationService internalizationService); @Override void execute(CommandExecution execution); }
NestedCommand implements Command { @Override public void execute(CommandExecution execution) { if (execution.getArguments().isEmpty() || !nestedCommands.containsKey(execution.getArguments().get(0))) { this.sendHelp(execution); } else { this.executeInternal(execution, execution.getArguments().get(0)); } } NestedCommand(Map<String, CommandRegistration> nestedCommands, CommandExecutor commandExecutor, InternalizationService internalizationService); @Override void execute(CommandExecution execution);  }