UserGroupResource { @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) public TagSubscriptionDTO[] getTagSubscriptionsForGroup( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId, @ApiParam(required = true, value = "Group id") @PathParam("groupId") String groupId) throws EntityNotFoundException, UserNotActiveException, AccessRightException, WorkspaceNotEnabledException { List<TagUserGroupSubscription> subs = notificationManager.getTagUserGroupSubscriptionsByGroup(workspaceId, groupId); TagSubscriptionDTO[] subDTOs = new TagSubscriptionDTO[subs.size()]; for (int i = 0; i < subs.size(); i++) { subDTOs[i] = mapper.map(subs.get(i), TagSubscriptionDTO.class); } return subDTOs; } 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 getTagSubscriptionsForGroupTest() throws ApplicationException { Tag tag1 = new Tag(workspace, "tag1"); Tag tag2 = new Tag(workspace, "tag2"); UserGroup group1 = new UserGroup(workspace, "group1"); UserGroup group2 = new UserGroup(workspace, "group2"); TagUserGroupSubscription tagSubscription1 = new TagUserGroupSubscription(tag1, group1); TagUserGroupSubscription tagSubscription2 = new TagUserGroupSubscription(tag2, group2); List<TagUserGroupSubscription> subscriptions = Arrays.asList( tagSubscription1, tagSubscription2 ); Mockito.when(notificationManager.getTagUserGroupSubscriptionsByGroup(workspaceId, groupId)) .thenReturn(subscriptions); TagSubscriptionDTO[] subscriptionsDTO = userGroupResource.getTagSubscriptionsForGroup(workspaceId, groupId); Assert.assertEquals(subscriptions.size(), subscriptionsDTO.length); }