AbstractExecutableCommand extends CommandImpl implements ExecutableCommand { protected boolean isArgumentsCountFalse(CommandLineArguments arguments) { if (arguments.argumentCount() != getArgumentCount()) { getCommandLineHandle().expectedArguments(getArguments()); return true; } else { return false; } } AbstractExecutableCommand(String commandName, String[] arguments, String helpText); @Override abstract void execute(CommandLineArguments arguments);  }
@Test public void isArgumentsCountFalseScanner() { assertThat(executableCommand.isArgumentsCountFalse(new CommandLineArguments("foo")), is(true)); assertThat(executableCommand.isArgumentsCountFalse(new CommandLineArguments("foo bar")), is(false)); assertThat(executableCommand.isArgumentsCountFalse(new CommandLineArguments("foo bar baz")), is(true)); }
@Test public void isArgumentsCountFalseScanner_unmodifiedScanner() { CommandLineArguments commandLineArguments = new CommandLineArguments("foo bar"); assertThat(executableCommand.isArgumentsCountFalse(commandLineArguments), is(false)); Scanner scanner = commandLineArguments.asScanner(); assertThat(scanner.next(), is("foo")); assertThat(scanner.next(), is("bar")); assertThat(scanner.hasNext(), is(false)); }