MilestonesResource { @PUT @ApiOperation(value = "Update ACL of a milestone", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful ACL update of MilestoneDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{milestoneId}/acl") @Consumes(MediaType.APPLICATION_JSON) public Response updateMilestoneACL( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId, @ApiParam(required = true, value = "Milestone id") @PathParam("milestoneId") int milestoneId, @ApiParam(required = true, value = "ACL rules to set") ACLDTO acl) throws EntityNotFoundException, UserNotActiveException, AccessRightException, WorkspaceNotEnabledException { if (acl.hasEntries()) { changeManager.updateACLForMilestone(workspaceId, milestoneId, acl.getUserEntriesMap(), acl.getUserGroupEntriesMap()); } else { changeManager.removeACLFromMilestone(workspaceId, milestoneId); } return Response.noContent().build(); } MilestonesResource(); @PostConstruct void init(); @GET @ApiOperation(value = "Get milestones for given parameters", response = MilestoneDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of MilestoneDTOs. 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) Response getMilestones(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId); @POST @ApiOperation(value = "Create a new milestone", response = MilestoneDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of created MilestoneDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) MilestoneDTO createMilestone(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Milestone to create") MilestoneDTO milestoneDTO); @GET @ApiOperation(value = "Get a milestone by id", response = MilestoneDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of MilestoneDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) @Path("{milestoneId}") MilestoneDTO getMilestone(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Milestone id") @PathParam("milestoneId") int milestoneId); @PUT @ApiOperation(value = "Update milestone", response = MilestoneDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of updated MilestoneDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("{milestoneId}") MilestoneDTO updateMilestone(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Milestone id") @PathParam("milestoneId") int milestoneId,
            @ApiParam(required = true, value = "Milestone to update") MilestoneDTO pMilestoneDTO); @DELETE @ApiOperation(value = "Delete milestone", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful deletion of MilestoneDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Consumes(MediaType.APPLICATION_JSON) @Path("{milestoneId}") Response removeMilestone(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Milestone id") @PathParam("milestoneId") int milestoneId); @GET @ApiOperation(value = "Get change requests for a given milestone", response = ChangeRequestDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of created ChangeRequestDTOs. 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) @Path("{milestoneId}/requests") Response getRequestsByMilestone(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Milestone id") @PathParam("milestoneId") int milestoneId); @GET @ApiOperation(value = "Get change orders for a given milestone", response = ChangeOrderDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of created ChangeOrderDTOs. 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) @Path("{milestoneId}/orders") Response getOrdersByMilestone(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Milestone id") @PathParam("milestoneId") int milestoneId); @PUT @ApiOperation(value = "Update ACL of a milestone", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful ACL update of MilestoneDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{milestoneId}/acl") @Consumes(MediaType.APPLICATION_JSON) Response updateMilestoneACL(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Milestone id") @PathParam("milestoneId") int milestoneId,
            @ApiParam(required = true, value = "ACL rules to set") ACLDTO acl);  }
@Test public void updateMilestoneACLTest() throws ApplicationException { int milestoneId = 22; ACLDTO acl = new ACLDTO(); ACLEntryDTO userEntry = new ACLEntryDTO(); userEntry.setKey("key"); userEntry.setValue(ACLPermission.FULL_ACCESS); ACLEntryDTO groupEntry = new ACLEntryDTO(); groupEntry.setKey("key"); groupEntry.setValue(ACLPermission.FULL_ACCESS); acl.setUserEntries(Collections.singletonList(userEntry)); acl.setGroupEntries(Collections.singletonList(groupEntry)); Mockito.when(changeManager.updateACLForMilestone(workspaceId, milestoneId, acl.getUserEntriesMap(), acl.getUserGroupEntriesMap())) .thenReturn(null); Response response = milestonesResource.updateMilestoneACL(workspaceId, milestoneId, acl); Mockito.verify(changeManager, Mockito.times(1)) .updateACLForMilestone(workspaceId, milestoneId, acl.getUserEntriesMap(), acl.getUserGroupEntriesMap()); Assert.assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus()); acl.setUserEntries(new ArrayList<>()); acl.setGroupEntries(new ArrayList<>()); Mockito.when(changeManager.removeACLFromMilestone(workspaceId, milestoneId)) .thenReturn(null); response = milestonesResource.updateMilestoneACL(workspaceId, milestoneId, acl); Mockito.verify(changeManager, Mockito.times(1)) .removeACLFromMilestone(workspaceId, milestoneId); Assert.assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus()); }