UserInputEvaluation implements CommandRegistry { @VisibleForTesting protected void handleCommand(CommandLineArguments arguments) throws Exception { Scanner scanner = arguments.asScanner(); final String command = scanner.next(); String fullLine = ""; if (scanner.hasNext()) { fullLine = scanner.nextLine(); } if (commands.containsKey(command)) { commandMarshalling(command, fullLine); } else { unknownCommand(); } } UserInputEvaluation(); void setProvisioning(Provisioning provisioning); String[] commands(); @Override void registerCommand(Command command); @Override void unregisterCommand(Command command); @Override Command getCommand(String commandName); void evaluate(String userInput);  }
@Test public void handleCommand() { userInputEvaluation.registerCommand(new CommandImpl("newcommand", new String[]{"arg1", "arg2"}, null)); userInputEvaluation.evaluate("newcommand arg1 arg2"); assertThat(commandLineEvaluation.getLastCommand(), is("newcommand")); Scanner scanner = commandLineEvaluation.getLastArguments().asScanner(); assertThat(scanner.next(), is("arg1")); assertThat(scanner.next(), is("arg2")); }