### Question:
CommandFactory { public Command getCommand(String commandLine) throws InvalidCommandException, InvalidCommandParams { commandLine = commandLine.trim().replaceAll(" {2}", " "); String[] split = commandLine.split(" "); String mainCommand = split[0].toUpperCase(); String[] params = Arrays.copyOfRange(split, 1, split.length); switch (mainCommand) { case "Q": return new QuitCommand(); case "C": return new CreateCommand(params); case "L": return new DrawLineCommand(params); case "R": return new DrawRectangleCommand(params); case "B": return new BucketFillCommand(params); default: throw new InvalidCommandException(); } }  Command getCommand(String commandLine);  }### Answer:
@Test public void getCommand3() throws Exception { Command command = commandFactory.getCommand("C 20 4"); Assert.assertThat(command, CoreMatchers.instanceOf(CreateCommand.class)); }
@Test public void getCommand4() throws Exception { Command command = commandFactory.getCommand("L 1 2 1 22"); Assert.assertThat(command, CoreMatchers.instanceOf(DrawLineCommand.class)); }
@Test public void getCommand5() throws Exception { Command command = commandFactory.getCommand("R 14 1 18 3"); Assert.assertThat(command, CoreMatchers.instanceOf(DrawRectangleCommand.class)); }
@Test public void getCommand6() throws Exception { Command command = commandFactory.getCommand("B 1 3 o"); Assert.assertThat(command, CoreMatchers.instanceOf(BucketFillCommand.class)); }
@Test public void getCommand() throws Exception { commandFactory.getCommand("Q"); }