@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); }
@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 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 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); }
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(); }
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();  }