### Question:
DeleteClient implements Runnable { @Override public void run() { Optional<Client> client = manager.getClientByID(uid); if (!client.isPresent()) { outputStream.println("No client exists with that user ID"); } else if (!yes) { outputStream.println( String.format("Removing client: %s, with date of birth: %s,\nto proceed please rerun the command " + "with the -y flag", client.get().getFullName(), client.get().getDateOfBirth())); } else { Action action = new DeleteClientAction(client.get(), manager); outputStream.println(invoker.execute(action)); } } DeleteClient(PrintStream outputStream, ActionInvoker invoker);  DeleteClient(ClientManager manager, ActionInvoker invoker); @Override void run();  }### Answer:
@Test public void deleteuser_invalid_format_id() { doNothing().when(spyClientManager).addClient(any()); String[] inputs = {"-u", "notint"}; CommandLine.run(spyDeleteClient, System.out, inputs); verify(spyDeleteClient, times(0)).run(); }
@Test public void deleteuser_invalid_option() { String[] inputs = {"-u", "1", "--notanoption"}; CommandLine.run(spyDeleteClient, System.out, inputs); verify(spyDeleteClient, times(0)).run(); }
@Test public void deleteuser_non_existent_id() { when(spyClientManager.getClientByID(anyInt())).thenReturn(Optional.empty()); String[] inputs = {"-u", "2"}; CommandLine.run(spyDeleteClient, System.out, inputs); verify(spyDeleteClient, times(1)).run(); verify(spyClientManager, times(0)).removeClient(any()); }
@Test public void deleteuser_valid_reject() { Client client = new Client("First", null, "Last", LocalDate.of(1970, 1, 1), 1); when(spyClientManager.getClientByID(anyInt())).thenReturn(Optional.of(client)); String[] inputs = {"-u", "1"}; ByteArrayInputStream in = new ByteArrayInputStream("n".getBytes(StandardCharsets.UTF_8)); System.setIn(in); CommandLine.run(spyDeleteClient, System.out, inputs); verify(spyClientManager, times(0)).removeClient(client); }
@Test public void DeleteUserValidWithYesFlag() { Client client = new Client("First", null, "Last", LocalDate.of(1970, 1, 1), 1); when(spyClientManager.getClientByID(anyInt())).thenReturn(Optional.of(client)); String[] inputs = {"-u", "1", "-y"}; CommandLine.run(spyDeleteClient, System.out, inputs); verify(spyClientManager, times(1)).removeClient(client); }
@Test public void DeleteUserValidNoYesFlag() { Client client = new Client("First", null, "Last", LocalDate.of(1970, 1, 1), 1); when(spyClientManager.getClientByID(anyInt())).thenReturn(Optional.of(client)); String[] inputs = {"-u", "1"}; CommandLine.run(spyDeleteClient, System.out, inputs); verify(spyClientManager, times(0)).removeClient(client); }