### Question:
PrintClientInfo implements Runnable { @Override public void run() { Optional<Client> client = manager.getClientByID(uid); if (!client.isPresent()) { outputStream.println("No client exists with that user ID"); return; } outputStream.println(client.get().getClientInfoString()); } PrintClientInfo();  PrintClientInfo(PrintStream outputStream);  PrintClientInfo(ClientManager manager); @Override void run();  }### Answer:
@Test public void printuserinfo_invalid_format_id() { doNothing().when(spyClientManager).addClient(any()); String[] inputs = {"-u", "notint"}; CommandLine.run(spyPrintClientInfo, System.out, inputs); verify(spyPrintClientInfo, times(0)).run(); }
@Test public void printuserinfo_invalid_option() { String[] inputs = {"-u", "1", "--notanoption"}; CommandLine.run(spyPrintClientInfo, System.out, inputs); verify(spyPrintClientInfo, times(0)).run(); }
@Test public void printuserinfo_non_existent_id() { when(spyClientManager.getClientByID(anyInt())).thenReturn(Optional.empty()); String[] inputs = {"-u", "2"}; CommandLine.run(spyPrintClientInfo, System.out, inputs); verify(spyPrintClientInfo, times(1)).run(); assertThat(outContent.toString(), containsString("No client exists with that user ID")); }
@Test public void printuserinfo_valid() { Client client = new Client("First", "mid", "Last", LocalDate.of(1970, 1, 1), 1); when(spyClientManager.getClientByID(anyInt())).thenReturn(Optional.of(client)); String[] inputs = {"-u", "1"}; CommandLine.run(spyPrintClientInfo, System.out, inputs); assertThat(outContent.toString(), containsString("User: 1. Name: First mid Last, date of birth: 1970-01-01, date of death: null")); }