@Test public void executeInexistent() { CommandExecution commandExecution = mock(CommandExecution.class); ArgumentSet argumentSet = mock(ArgumentSet.class); when(argumentSet.get(eq(0))).thenReturn("absent"); when(argumentSet.isEmpty()).thenReturn(false); when(argumentSet.toArray()).thenReturn(new String[]{"absent", "arg1", "arg2"}); when(commandExecution.getArguments()).thenReturn( argumentSet ); when(commandExecution.getSender()).thenReturn(mock(Sender.class)); nestedCommand.execute(commandExecution); verify(commandExecutor, times(0)).execute( any(), any(), any() ); }
@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);  }