### Question:
RequestOrgan 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 (organType == null) { outputStream.println("The type of organ to be donated has not been defined."); } else { boolean organCurrentlyRequested = false; for (TransplantRequest tr : client.get().getTransplantRequests()) { if (tr.getRequestedOrgan() == organType && tr.getStatus() == TransplantRequestStatus.WAITING) { organCurrentlyRequested = true; break; } } if (organCurrentlyRequested) { outputStream.println("This organ is already requested."); } else { TransplantRequest newRequest = new TransplantRequest(client.get(), organType); Action action = new AddTransplantRequestAction(client.get(), newRequest, manager); outputStream.println(invoker.execute(action)); } } } RequestOrgan(PrintStream outputStream, ActionInvoker invoker);  RequestOrgan(ClientManager manager, ActionInvoker invoker); @Override void run();  }### Answer:
@Test public void validRequest1() { String[] inputs = {"-u", "1", "-o", "liver"}; CommandLine.run(spyRequestOrgan, System.out, inputs); assertTrue(testClient.getTransplantRequests().size() == 1); }
@Test public void validRequest2() { String[] inputs = {"-u", "1", "-organ", "bone marrow"}; CommandLine.run(spyRequestOrgan, System.out, inputs); assertTrue(testClient.getTransplantRequests().size() == 1); }
@Test public void organAlreadyRequested() { String[] inputs = {"-u", "1", "-organ", "bone marrow"}; CommandLine.run(spyRequestOrgan, System.out, inputs); CommandLine.run(spyRequestOrgan, System.out, inputs); assertTrue(testClient.getTransplantRequests().size() == 1); }
@Test public void invalidUid() { String[] inputs = {"-u", "10", "-organ", "bone marrow"}; CommandLine.run(spyRequestOrgan, System.out, inputs); assertTrue(testClient.getTransplantRequests().size() == 0); }
@Test public void invalidOrgan() { String[] inputs = {"-u", "10", "-organ", "plumbus"}; CommandLine.run(spyRequestOrgan, System.out, inputs); assertTrue(testClient.getTransplantRequests().size() == 0); }
@Test public void missingParams1() { String[] inputs = {"-u", "10", "liver"}; CommandLine.run(spyRequestOrgan, System.out, inputs); assertTrue(testClient.getTransplantRequests().size() == 0); }
@Test public void missingParams2() { String[] inputs = {"-u", "10", "-organ"}; CommandLine.run(spyRequestOrgan, System.out, inputs); assertTrue(testClient.getTransplantRequests().size() == 0); }