ClientsResource { protected Client getClientByName(@Auth User user, String name) { logger.info("User '{}' retrieving client name={}.", user, name); return clientFromName(name); } @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);  }
@Test public void findClientByName() { when(clientDAO.getClientByName(client.getName())).thenReturn(Optional.of(client)); assertThat(resource.getClientByName(user, "client")).isEqualTo(client); }
@Test(expected = NotFoundException.class) public void notFoundWhenRetrievingBadName() { when(clientDAO.getClientByName("non-existent-client")).thenReturn(Optional.empty()); resource.getClientByName(user, "non-existent-client"); }