@Test public void testInvalidCommandName() { TestHelper.load(); assertEquals("Invalid command name.", dispatch.processCommand("gibberish")); assertNotEquals("Invalid command name.", dispatch.processCommand("commerce")); }
public String processCommand(String input) { String[] split = input.split(" ", 2); String command = split[0]; String arguments = ""; if (split.length == 2) { arguments = split[1]; } String result = "Invalid command name."; if ("help".equals(command)) { result = help(); } else { for (Command potentialCommand : commands) { if (command.equals(potentialCommand.getCommandName())) { result = potentialCommand.execute(arguments); break; } } } return result; }
CommandDispatch { public String processCommand(String input) { String[] split = input.split(" ", 2); String command = split[0]; String arguments = ""; if (split.length == 2) { arguments = split[1]; } String result = "Invalid command name."; if ("help".equals(command)) { result = help(); } else { for (Command potentialCommand : commands) { if (command.equals(potentialCommand.getCommandName())) { result = potentialCommand.execute(arguments); break; } } } return result; } }
CommandDispatch { public String processCommand(String input) { String[] split = input.split(" ", 2); String command = split[0]; String arguments = ""; if (split.length == 2) { arguments = split[1]; } String result = "Invalid command name."; if ("help".equals(command)) { result = help(); } else { for (Command potentialCommand : commands) { if (command.equals(potentialCommand.getCommandName())) { result = potentialCommand.execute(arguments); break; } } } return result; } CommandDispatch(); }
CommandDispatch { public String processCommand(String input) { String[] split = input.split(" ", 2); String command = split[0]; String arguments = ""; if (split.length == 2) { arguments = split[1]; } String result = "Invalid command name."; if ("help".equals(command)) { result = help(); } else { for (Command potentialCommand : commands) { if (command.equals(potentialCommand.getCommandName())) { result = potentialCommand.execute(arguments); break; } } } return result; } CommandDispatch(); String processCommand(String input); }
CommandDispatch { public String processCommand(String input) { String[] split = input.split(" ", 2); String command = split[0]; String arguments = ""; if (split.length == 2) { arguments = split[1]; } String result = "Invalid command name."; if ("help".equals(command)) { result = help(); } else { for (Command potentialCommand : commands) { if (command.equals(potentialCommand.getCommandName())) { result = potentialCommand.execute(arguments); break; } } } return result; } CommandDispatch(); String processCommand(String input);  }