UserGroupResource { @GET @ApiOperation(value = "Get user groups in given workspace", response = UserGroupDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of UserGroupDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) public UserGroupDTO[] getGroups( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId) throws AccessRightException, EntityNotFoundException, UserNotActiveException, WorkspaceNotEnabledException { UserGroup[] userGroups = userManager.getUserGroups(workspaceId); UserGroupDTO[] userGroupDTOs = new UserGroupDTO[userGroups.length]; for (int i = 0; i < userGroups.length; i++) { userGroupDTOs[i] = mapper.map(userGroups[i], UserGroupDTO.class); } return userGroupDTOs; } UserGroupResource(); @PostConstruct void init(); @GET @ApiOperation(value = "Get user groups in given workspace", response = UserGroupDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of UserGroupDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) UserGroupDTO[] getGroups(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId); @GET @ApiOperation(value = "Get tag subscriptions of given user group", response = TagSubscriptionDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of TagSubscriptionDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{groupId}/tag-subscriptions") @Produces(MediaType.APPLICATION_JSON) TagSubscriptionDTO[] getTagSubscriptionsForGroup(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Group id") @PathParam("groupId") String groupId); @GET @ApiOperation(value = "Get users of given user group", response = UserDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of UserDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{groupId}/users") @Produces(MediaType.APPLICATION_JSON) UserDTO[] getUsersInGroup(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Group id") @PathParam("groupId") String groupId); @PUT @ApiOperation(value = "Update or create tag subscription of given user group", response = TagSubscriptionDTO.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Successful retrieval of TagSubscriptionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{groupId}/tag-subscriptions/{tagName}") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) Response updateUserGroupSubscription(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Group id") @PathParam("groupId") String groupId,
            @ApiParam(required = true, value = "Tag name") @PathParam("tagName") String tagName,
            @ApiParam(required = true, value = "Tag subscription to update or create") TagSubscriptionDTO subDTO); @DELETE @ApiOperation(value = "Delete tag subscription of given user group", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful deletion of TagSubscriptionDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{groupId}/tag-subscriptions/{tagName}") @Produces(MediaType.APPLICATION_JSON) Response deleteUserGroupSubscription(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Group id id") @PathParam("groupId") String groupId,
            @ApiParam(required = true, value = "Tag name") @PathParam("tagName") String tagName);  }
@Test public void getGroupsTest() throws ApplicationException { UserGroup group = new UserGroup(workspace, groupId); UserGroup[] groups = new UserGroup[]{group}; Mockito.when(userManager.getUserGroups(workspaceId)) .thenReturn(groups); UserGroupDTO[] result = userGroupResource.getGroups(workspaceId); Assert.assertEquals(groups.length, result.length); Assert.assertEquals(groups[0].getId(), result[0].getId()); Assert.assertEquals(groups[0].getWorkspaceId(), result[0].getWorkspaceId()); }