WorkspaceMembershipResource { @GET @ApiOperation(value = "Get workspace's group membership for authenticated user", response = WorkspaceUserGroupMemberShipDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkspaceUserGroupMemberShipDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("usergroups") @Produces(MediaType.APPLICATION_JSON) public WorkspaceUserGroupMemberShipDTO[] getWorkspaceUserGroupMemberShips( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId) throws EntityNotFoundException, UserNotActiveException, WorkspaceNotEnabledException { WorkspaceUserGroupMembership[] workspaceUserGroupMemberships = userManager.getWorkspaceUserGroupMemberships(workspaceId); WorkspaceUserGroupMemberShipDTO[] workspaceUserGroupMemberShipDTO = new WorkspaceUserGroupMemberShipDTO[workspaceUserGroupMemberships.length]; for (int i = 0; i < workspaceUserGroupMemberships.length; i++) { workspaceUserGroupMemberShipDTO[i] = mapper.map(workspaceUserGroupMemberships[i], WorkspaceUserGroupMemberShipDTO.class); } return workspaceUserGroupMemberShipDTO; } WorkspaceMembershipResource(); @PostConstruct void init(); @GET @ApiOperation(value = "Get workspace's user memberships", response = WorkspaceUserMemberShipDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkspaceUserMemberShipDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("users") @Produces(MediaType.APPLICATION_JSON) WorkspaceUserMemberShipDTO[] getWorkspaceUserMemberShips(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId); @GET @ApiOperation(value = "Get workspace's user membership for authenticated user", response = WorkspaceUserMemberShipDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkspaceUserMemberShipDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("users/me") @Produces(MediaType.APPLICATION_JSON) WorkspaceUserMemberShipDTO getWorkspaceSpecificUserMemberShips(@ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId); @GET @ApiOperation(value = "Get workspace's group membership for authenticated user", response = WorkspaceUserGroupMemberShipDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkspaceUserGroupMemberShipDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("usergroups") @Produces(MediaType.APPLICATION_JSON) WorkspaceUserGroupMemberShipDTO[] getWorkspaceUserGroupMemberShips(
            @ApiParam(required = true, value = "Workspace id")  @PathParam("workspaceId") String workspaceId); @GET @ApiOperation(value = "Get workspace's group membership for authenticated user", response = WorkspaceUserGroupMemberShipDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkspaceUserGroupMemberShipDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("usergroups/me") @Produces(MediaType.APPLICATION_JSON) Response getWorkspaceSpecificUserGroupMemberShips(
            @ApiParam(required = true, value = "Workspace id")  @PathParam("workspaceId") String workspaceId);  }
@Test public void getWorkspaceUserGroupMemberShipsTest() throws ApplicationException { WorkspaceUserGroupMembership membership = new WorkspaceUserGroupMembership(workspace, group); WorkspaceUserGroupMembership[] list = new WorkspaceUserGroupMembership[]{membership}; Mockito.when(userManager.getWorkspaceUserGroupMemberships(workspaceId)) .thenReturn(list); WorkspaceUserGroupMemberShipDTO[] workspaceUserGroupMemberShips = workspaceMembershipResource.getWorkspaceUserGroupMemberShips(workspaceId); Assert.assertEquals(list.length, workspaceUserGroupMemberShips.length); }