GroupsResource { protected List<Group> listGroups(@Auth User user) { logger.info("User '{}' listing groups.", user); Set<Group> groups = groupDAO.getGroups(); return ImmutableList.copyOf(groups); } @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 listingOfGroups() { Group group1 = new Group(1, "group1", "desc", now, "creator", now, "updater", ImmutableMap.of( "app", "app")); Group group2 = new Group(2, "group2", "desc", now, "creator", now, "updater", ImmutableMap.of("app", "app")); when(groupDAO.getGroups()).thenReturn(ImmutableSet.of(group1, group2)); List<Group> response = resource.listGroups(user); assertThat(response).containsOnly(group1, group2); }