GroupsResource { @Path("{groupId}") @Timed @ExceptionMetered @GET public GroupDetailResponse getGroup(@Auth User user, @PathParam("groupId") LongParam groupId) { logger.info("User '{}' retrieving group id={}.", user, groupId); return groupDetailResponseFromId(groupId.get()); } @Inject  GroupsResource(AclDAOFactory aclDAOFactory, GroupDAOFactory groupDAOFactory, AuditLog auditLog); @VisibleForTesting  GroupsResource(AclDAO aclDAO, GroupDAO groupDAO, AuditLog auditLog); @Timed @ExceptionMetered @GET Response findGroups(@Auth User user, @DefaultValue("") @QueryParam("name") String name); @Timed @ExceptionMetered @POST @Consumes(APPLICATION_JSON) Response createGroup(@Auth User user, @Valid CreateGroupRequestV2 request); @Path("{groupId}") @Timed @ExceptionMetered @GET GroupDetailResponse getGroup(@Auth User user, @PathParam("groupId") LongParam groupId); @Path("{groupId}") @Timed @ExceptionMetered @DELETE Response deleteGroup(@Auth User user, @PathParam("groupId") LongParam groupId);  }
@Test public void getSpecificIncludesAllTheThings() { when(groupDAO.getGroupById(4444)).thenReturn(Optional.of(group)); SanitizedSecret secret = SanitizedSecret.of(1, "name", null, "checksum", now, "creator", now, "creator", null, null, null, 1136214245, 125L, now, "creator"); when(aclDAO.getSanitizedSecretsFor(group)).thenReturn(ImmutableSet.of(secret)); Client client = new Client(1, "client", "desc", null, now, "creator", now, "creator", null, null, true, false ); when(aclDAO.getClientsFor(group)).thenReturn(ImmutableSet.of(client)); GroupDetailResponse response = resource.getGroup(user, new LongParam("4444")); assertThat(response.getId()).isEqualTo(group.getId()); assertThat(response.getName()).isEqualTo(group.getName()); assertThat(response.getDescription()).isEqualTo(group.getDescription()); assertThat(response.getCreationDate()).isEqualTo(group.getCreatedAt()); assertThat(response.getCreatedBy()).isEqualTo(group.getCreatedBy()); assertThat(response.getUpdateDate()).isEqualTo(group.getUpdatedAt()); assertThat(response.getUpdatedBy()).isEqualTo(group.getUpdatedBy()); assertThat(response.getSecrets()).containsExactly(secret); assertThat(response.getClients()).containsExactly(client); }
@Test(expected = NotFoundException.class) public void notFoundWhenRetrievingBadId() { when(groupDAO.getGroupById(0x1bad1dea)).thenReturn(Optional.empty()); resource.getGroup(user, new LongParam(Long.toString(0x1bad1dea))); }