### Question:
ResolveOrgan implements Runnable { @Override public void run() { Optional<Client> optionalClient = manager.getClientByID(uid); Client client; if (!optionalClient.isPresent()) { outputStream.println("No client exists with that user ID"); return; } else { client = optionalClient.get(); } TransplantRequest selectedTransplantRequest = null; for (TransplantRequest tr : client.getTransplantRequests()) { if (tr.getRequestedOrgan() == organType && tr.getStatus() == TransplantRequestStatus.WAITING) { selectedTransplantRequest = tr; break; } } if (selectedTransplantRequest == null) { outputStream.println(client.getFullName() + " is not currently requesting this organ."); } else { resolveRequest(selectedTransplantRequest); } } ResolveOrgan(PrintStream outputStream, ActionInvoker invoker);  ResolveOrgan(ClientManager manager, ActionInvoker invoker); @Override void run();  }### Answer:
@Test public void validResolve1() { TransplantRequest tr = new TransplantRequest(testClient, Organ.LIVER); testClient.addTransplantRequest(tr); String[] inputs = {"-u", "1", "-o", "liver", "-r", "input error"}; CommandLine.run(spyResolveOrgan, System.out, inputs); assertTrue(tr.getStatus() == TransplantRequestStatus.CANCELLED); }
@Test public void validResolve2() { TransplantRequest tr = new TransplantRequest(testClient, Organ.HEART); testClient.addTransplantRequest(tr); String[] inputs = {"-u", "1", "-o", "heart", "-reason", "Transplant completed"}; CommandLine.run(spyResolveOrgan, System.out, inputs); assertTrue(tr.getStatus() == TransplantRequestStatus.COMPLETED); }
@Test public void validResolveCustom() { TransplantRequest tr = new TransplantRequest(testClient, Organ.PANCREAS); testClient.addTransplantRequest(tr); String[] inputs = {"-u", "1", "-o", "pancreas", "-reason", "Custom reason...", "-m", "A message for a custom " + "reason"}; CommandLine.run(spyResolveOrgan, System.out, inputs); assertTrue(tr.getStatus() == TransplantRequestStatus.CANCELLED); }
@Test public void resolveNonExisting() { TransplantRequest tr = new TransplantRequest(testClient, Organ.PANCREAS); testClient.addTransplantRequest(tr); String[] inputs = {"-u", "1", "-o", "liver", "-reason", "input error"}; CommandLine.run(spyResolveOrgan, System.out, inputs); assertTrue(tr.getStatus() == TransplantRequestStatus.WAITING); }
@Test public void resolveInvalidParam1() { TransplantRequest tr = new TransplantRequest(testClient, Organ.LIVER); testClient.addTransplantRequest(tr); String[] inputs = {"-u", "1", "-o", "liver", "-r", "ops this input is invalid"}; CommandLine.run(spyResolveOrgan, System.out, inputs); assertTrue(tr.getStatus() == TransplantRequestStatus.WAITING); }
@Test public void resolveInvalidParam2() { TransplantRequest tr = new TransplantRequest(testClient, Organ.HEART); testClient.addTransplantRequest(tr); String[] inputs = {"-u", "1", "-o", "liver", "-r", "input error"}; CommandLine.run(spyResolveOrgan, System.out, inputs); assertTrue(tr.getStatus() == TransplantRequestStatus.WAITING); }
@Test public void resolveInvalidParam3() { TransplantRequest tr = new TransplantRequest(testClient, Organ.LUNG); testClient.addTransplantRequest(tr); String[] inputs = {"-u", "1", "-o", "liver", "-r", "input error", "-m"}; CommandLine.run(spyResolveOrgan, System.out, inputs); assertTrue(tr.getStatus() == TransplantRequestStatus.WAITING); }