WorkflowResource { @GET @ApiOperation(value = "Get workflow's aborted workflow list", response = WorkflowDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkflowDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{workflowId}/aborted") @Produces(MediaType.APPLICATION_JSON) public Response getWorkflowAbortedWorkflowList( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId, @ApiParam(required = true, value = "Workflow id") @PathParam("workflowId") int workflowId) throws EntityNotFoundException, UserNotActiveException, AccessRightException, WorkspaceNotEnabledException { Workflow[] abortedWorkflowList = workflowService.getWorkflowAbortedWorkflowList(workspaceId, workflowId); List<WorkflowDTO> abortedWorkflowDTOList = new ArrayList<>(); for (Workflow abortedWorkflow : abortedWorkflowList) { abortedWorkflowDTOList.add(mapper.map(abortedWorkflow, WorkflowDTO.class)); } Collections.sort(abortedWorkflowDTOList); return Response.ok(new GenericEntity<List<WorkflowDTO>>((List<WorkflowDTO>) abortedWorkflowDTOList) { }).build(); } WorkflowResource(); @PostConstruct void init(); @GET @ApiOperation(value = "Get instantiated workflow in workspace", response = WorkflowDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkflowDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{workflowId}") @Produces(MediaType.APPLICATION_JSON) WorkflowDTO getWorkflowInstance(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Workflow id") @PathParam("workflowId") int workflowId); @GET @ApiOperation(value = "Get workflow's aborted workflow list", response = WorkflowDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkflowDTOs. It can be an empty list."), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{workflowId}/aborted") @Produces(MediaType.APPLICATION_JSON) Response getWorkflowAbortedWorkflowList(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Workflow id") @PathParam("workflowId") int workflowId);  }
@Test public void getWorkflowAbortedWorkflowListTest() throws ApplicationException { int workflowId = 42; Workflow workflow = new Workflow(); workflow.setId(workflowId); Workflow[] list = new Workflow[]{workflow}; Mockito.when(workflowService.getWorkflowAbortedWorkflowList(Matchers.anyString(), Matchers.anyInt())).thenReturn(list); Response res = workflowResource.getWorkflowAbortedWorkflowList("wks", workflowId); Object entity = res.getEntity(); Assert.assertTrue(entity.getClass().isAssignableFrom(ArrayList.class)); List workflowList = (ArrayList) entity; Object workflowEntity = workflowList.get(0); Assert.assertTrue(workflowEntity.getClass().isAssignableFrom(WorkflowDTO.class)); WorkflowDTO workflowDTO = (WorkflowDTO) workflowEntity; Assert.assertNotNull(workflowDTO); Assert.assertEquals(workflowId, workflowDTO.getId()); }