DocumentBaselinesResource { @GET @ApiOperation(value = "Get document baselines", response = DocumentBaselineDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of checked out DocumentBaselineDTOs. 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 Response getDocumentBaselines( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId) throws EntityNotFoundException, UserNotActiveException, WorkspaceNotEnabledException { List<DocumentBaseline> documentBaselines = documentBaselineService.getBaselines(workspaceId); List<DocumentBaselineDTO> baselinesDTO = new ArrayList<>(); for (DocumentBaseline documentBaseline : documentBaselines) { DocumentBaselineDTO documentBaselineDTO = mapper.map(documentBaseline, DocumentBaselineDTO.class); baselinesDTO.add(documentBaselineDTO); } return Response.ok(new GenericEntity<List<DocumentBaselineDTO>>((List<DocumentBaselineDTO>) baselinesDTO) { }).build(); } DocumentBaselinesResource(); @PostConstruct void init(); @GET @ApiOperation(value = "Get document baselines", response = DocumentBaselineDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of checked out DocumentBaselineDTOs. 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 getDocumentBaselines(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId); @POST @ApiOperation(value = "Create a new document baseline", response = DocumentBaselineDTO.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Successful retrieval of created DocumentBaselineDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Consumes(MediaType.APPLICATION_JSON) Response createDocumentBaseline(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Document baseline to create") DocumentBaselineDTO documentBaselineDTO); @DELETE @ApiOperation(value = "Delete a document baseline", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful deletion of DocumentBaselineDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{baselineId}") @Consumes(MediaType.APPLICATION_JSON) Response deleteBaseline(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Baseline id") @PathParam("baselineId") int baselineId); @GET @ApiOperation(value = "Get document baseline by id", response = DocumentBaselineDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of DocumentBaselineDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{baselineId}") @Produces(MediaType.APPLICATION_JSON) DocumentBaselineDTO getBaseline(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Baseline id") @PathParam("baselineId") int baselineId); @GET @ApiOperation(value = "Get document baseline in a light format", response = DocumentBaselineDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of DocumentBaselineDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{baselineId}-light") @Produces(MediaType.APPLICATION_JSON) DocumentBaselineDTO getBaselineLight(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Baseline id") @PathParam("baselineId") int baselineId); @GET @ApiOperation(value = "Export document baseline's files", response = File.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful files export, download a zipped file containing requested files."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{baselineId}/export-files") Response exportDocumentFiles(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Baseline id") @PathParam("baselineId") int baselineId);  }
@Test public void getDocumentBaselinesTest() throws ApplicationException { DocumentBaseline baseline1 = new DocumentBaseline(); DocumentBaseline baseline2 = new DocumentBaseline(); List<DocumentBaseline> list = Arrays.asList(baseline1, baseline2); Mockito.when(documentBaselineService.getBaselines(workspaceId)) .thenReturn(list); Response res = documentBaselinesResource.getDocumentBaselines(workspaceId); Assert.assertEquals(Response.Status.OK.getStatusCode(), res.getStatus()); Object entity = res.getEntity(); Assert.assertTrue(entity.getClass().isAssignableFrom(ArrayList.class)); ArrayList result = (ArrayList) entity; Assert.assertEquals(list.size(), result.size()); }