@Test public void invalidOrgan() { String[] inputs = {"-u", "10", "-organ", "plumbus"}; CommandLine.run(spyRequestOrgan, System.out, inputs); assertTrue(testClient.getTransplantRequests().size() == 0); }
@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 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 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); }
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(); }
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();  }