### Question:
UserGroupResource { @GET @RolesAllowed("/roleManagement") public Response getGroups(@Auth UserInfo userInfo) { log.debug("Getting all groups for admin {}...", userInfo.getName()); return Response.ok(userGroupService.getAggregatedRolesByGroup(userInfo)).build(); } @Inject  UserGroupResource(UserGroupService userGroupService); @POST @RolesAllowed("/roleManagement/create") Response createGroup(@Auth UserInfo userInfo, @Valid GroupDTO dto); @PUT @RolesAllowed("/roleManagement") Response updateGroup(@Auth UserInfo userInfo, @Valid GroupDTO dto); @GET @RolesAllowed("/roleManagement") Response getGroups(@Auth UserInfo userInfo); @DELETE @Path("{id}") @RolesAllowed("/roleManagement/delete") Response deleteGroup(@Auth UserInfo userInfo, @PathParam("id") String group);  }### Answer:
@Test public void getGroups() { when(userGroupService.getAggregatedRolesByGroup(any(UserInfo.class))).thenReturn(Collections.singletonList(getUserGroup())); final Response response = resources.getJerseyTest() .target("/group") .request() .header("Authorization", "Bearer " + TOKEN) .get(); final List<UserGroupDto> actualRoles = response.readEntity(new GenericType<List<UserGroupDto>>() { }); assertEquals(HttpStatus.SC_OK, response.getStatus()); assertEquals(GROUP, actualRoles.get(0).getGroup()); assertTrue(actualRoles.get(0).getRoles().isEmpty()); assertEquals(MediaType.APPLICATION_JSON, response.getHeaderString(HttpHeaders.CONTENT_TYPE)); verify(userGroupService).getAggregatedRolesByGroup(getUserInfo()); verifyNoMoreInteractions(userGroupService); }