### Question:
CreateClient implements Runnable { @Override public void run() { if (!force && manager.doesClientExist(firstName, lastName, dateOfBirth)) { outputStream.println("Duplicate client found, use --force to create anyway"); return; } Client client = new Client(firstName, middleNames, lastName, dateOfBirth, null); Action action = new CreateClientAction(client, manager); outputStream.println(invoker.execute(action)); } CreateClient(PrintStream outputStream, ActionInvoker invoker);  CreateClient(ClientManager manager, ActionInvoker invoker); @Override void run();  }### Answer:
@Test public void createclient_valid() { doNothing().when(spyClientManager).addClient(any()); String[] inputs = {"-f", "Jack", "-l", "Steel", "-d", "21/04/1997"}; CommandLine.run(spyCreateClient, System.out, inputs); verify(spyClientManager, times(1)).addClient(any()); }
@Test public void createclient_invalidDOB() { doNothing().when(spyClientManager).addClient(any()); String[] inputs = {"-f", "Jack", "-l", "Steel", "-d", "21/04/197"}; CommandLine.run(spyCreateClient, System.out, inputs); verify(spyClientManager, times(0)).addClient(any()); }
@Test public void createclient_invalidFieldCountLow() { String[] inputs = {"-f", "Jack", "-l", "Steel"}; CommandLine.run(spyCreateClient, System.out, inputs); verify(spyCreateClient, times(0)).run(); }
@Test public void createclient_invalidFieldCountHigh() { String[] inputs = {"-f", "Jack", "-l", "Steel", "-d", "21/04/1997", "extra"}; CommandLine.run(spyCreateClient, System.out, inputs); verify(spyClientManager, times(0)).addClient(any()); }
@Test public void createclient_duplicateAccept() { when(spyClientManager.doesClientExist(any(), any(), any())).thenReturn(true); doNothing().when(spyClientManager).addClient(any()); String[] inputs = {"-f", "Jack", "-l", "Steel", "-d", "21/04/1997", "--force"}; CommandLine.run(spyCreateClient, System.out, inputs); verify(spyClientManager, times(1)).addClient(any()); }
@Test public void createclient_duplicateReject() { when(spyClientManager.doesClientExist(any(), any(), any())).thenReturn(true); doNothing().when(spyClientManager).addClient(any()); String[] inputs = {"-f", "Jack", "-l", "Steel", "-d", "21/04/1997"}; CommandLine.run(spyCreateClient, System.out, inputs); verify(spyClientManager, times(0)).addClient(any()); }