@Test public void deleteCallsDelete() { when(clientDAO.getClientById(12)).thenReturn(Optional.of(client)); Response blah = resource.deleteClient(user, new LongParam("12")); verify(clientDAO).deleteClient(client); assertThat(blah.getStatus()).isEqualTo(204); }
@Path("{clientId}") @Timed @ExceptionMetered @DELETE public Response deleteClient(@Auth User user, @PathParam("clientId") LongParam clientId) { logger.info("User '{}' deleting client id={}.", user, clientId); Optional<Client> client = clientDAO.getClientById(clientId.get()); if (!client.isPresent()) { throw new NotFoundException("Client not found."); } clientDAO.deleteClient(client.get()); auditLog.recordEvent( new Event(Instant.now(), EventTag.CLIENT_DELETE, user.getName(), client.get().getName())); return Response.noContent().build(); }
ClientsResource { @Path("{clientId}") @Timed @ExceptionMetered @DELETE public Response deleteClient(@Auth User user, @PathParam("clientId") LongParam clientId) { logger.info("User '{}' deleting client id={}.", user, clientId); Optional<Client> client = clientDAO.getClientById(clientId.get()); if (!client.isPresent()) { throw new NotFoundException("Client not found."); } clientDAO.deleteClient(client.get()); auditLog.recordEvent( new Event(Instant.now(), EventTag.CLIENT_DELETE, user.getName(), client.get().getName())); return Response.noContent().build(); } }
ClientsResource { @Path("{clientId}") @Timed @ExceptionMetered @DELETE public Response deleteClient(@Auth User user, @PathParam("clientId") LongParam clientId) { logger.info("User '{}' deleting client id={}.", user, clientId); Optional<Client> client = clientDAO.getClientById(clientId.get()); if (!client.isPresent()) { throw new NotFoundException("Client not found."); } clientDAO.deleteClient(client.get()); auditLog.recordEvent( new Event(Instant.now(), EventTag.CLIENT_DELETE, user.getName(), client.get().getName())); return Response.noContent().build(); } @Inject  ClientsResource(AclDAOFactory aclDAOFactory, ClientDAOFactory clientDAOFactory,
      AuditLog auditLog); @VisibleForTesting  ClientsResource(AclDAO aclDAO, ClientDAO clientDAO, AuditLog auditLog); }
ClientsResource { @Path("{clientId}") @Timed @ExceptionMetered @DELETE public Response deleteClient(@Auth User user, @PathParam("clientId") LongParam clientId) { logger.info("User '{}' deleting client id={}.", user, clientId); Optional<Client> client = clientDAO.getClientById(clientId.get()); if (!client.isPresent()) { throw new NotFoundException("Client not found."); } clientDAO.deleteClient(client.get()); auditLog.recordEvent( new Event(Instant.now(), EventTag.CLIENT_DELETE, user.getName(), client.get().getName())); return Response.noContent().build(); } @Inject  ClientsResource(AclDAOFactory aclDAOFactory, ClientDAOFactory clientDAOFactory,
      AuditLog auditLog); @VisibleForTesting  ClientsResource(AclDAO aclDAO, ClientDAO clientDAO, AuditLog auditLog); @Timed @ExceptionMetered @GET Response findClients(@Auth User user, @DefaultValue("") @QueryParam("name") String name); @Timed @ExceptionMetered @POST @Consumes(APPLICATION_JSON) Response createClient(@Auth User user,
      @Valid CreateClientRequestV2 createClientRequest); @Path("{clientId}") @Timed @ExceptionMetered @GET ClientDetailResponse getClient(@Auth User user,
      @PathParam("clientId") LongParam clientId); @Path("{clientId}") @Timed @ExceptionMetered @DELETE Response deleteClient(@Auth User user, @PathParam("clientId") LongParam clientId); }
ClientsResource { @Path("{clientId}") @Timed @ExceptionMetered @DELETE public Response deleteClient(@Auth User user, @PathParam("clientId") LongParam clientId) { logger.info("User '{}' deleting client id={}.", user, clientId); Optional<Client> client = clientDAO.getClientById(clientId.get()); if (!client.isPresent()) { throw new NotFoundException("Client not found."); } clientDAO.deleteClient(client.get()); auditLog.recordEvent( new Event(Instant.now(), EventTag.CLIENT_DELETE, user.getName(), client.get().getName())); return Response.noContent().build(); } @Inject  ClientsResource(AclDAOFactory aclDAOFactory, ClientDAOFactory clientDAOFactory,
      AuditLog auditLog); @VisibleForTesting  ClientsResource(AclDAO aclDAO, ClientDAO clientDAO, AuditLog auditLog); @Timed @ExceptionMetered @GET Response findClients(@Auth User user, @DefaultValue("") @QueryParam("name") String name); @Timed @ExceptionMetered @POST @Consumes(APPLICATION_JSON) Response createClient(@Auth User user,
      @Valid CreateClientRequestV2 createClientRequest); @Path("{clientId}") @Timed @ExceptionMetered @GET ClientDetailResponse getClient(@Auth User user,
      @PathParam("clientId") LongParam clientId); @Path("{clientId}") @Timed @ExceptionMetered @DELETE Response deleteClient(@Auth User user, @PathParam("clientId") LongParam clientId);  }