@Test public void getWorkspaceWorkflowListTest() throws ApplicationException { WorkspaceWorkflow workflow = new WorkspaceWorkflow(); workflow.setId("id"); WorkspaceWorkflow[] list = new WorkspaceWorkflow[]{workflow}; Mockito.when(workflowService.getWorkspaceWorkflowList(workspaceId)) .thenReturn(list); Response res = workspaceWorkflowResource.getWorkspaceWorkflowList(workspaceId); Object entity = res.getEntity(); Assert.assertTrue(entity.getClass().isAssignableFrom(ArrayList.class)); ArrayList result = (ArrayList) entity; Object o = result.get(0); Assert.assertTrue(o.getClass().isAssignableFrom(WorkspaceWorkflowDTO.class)); WorkspaceWorkflowDTO workflowDTO = (WorkspaceWorkflowDTO) o; Assert.assertEquals(workflow.getId(), String.valueOf(workflowDTO.getId())); }
@GET @ApiOperation(value = "Get workspace workflow list in given workspace", response = WorkspaceWorkflowDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkspaceWorkflowDTOs. 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 getWorkspaceWorkflowList( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId) throws EntityNotFoundException, UserNotActiveException, WorkspaceNotEnabledException { WorkspaceWorkflow[] workspaceWorkflowList = workflowService.getWorkspaceWorkflowList(workspaceId); List<WorkspaceWorkflowDTO> workspaceWorkflowListDTO = new ArrayList<>(); for (WorkspaceWorkflow workspaceWorkflow : workspaceWorkflowList) { workspaceWorkflowListDTO.add(mapper.map(workspaceWorkflow, WorkspaceWorkflowDTO.class)); } return Response.ok(new GenericEntity<List<WorkspaceWorkflowDTO>>((List<WorkspaceWorkflowDTO>) workspaceWorkflowListDTO) { }).build(); }
WorkspaceWorkflowResource { @GET @ApiOperation(value = "Get workspace workflow list in given workspace", response = WorkspaceWorkflowDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkspaceWorkflowDTOs. 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 getWorkspaceWorkflowList( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId) throws EntityNotFoundException, UserNotActiveException, WorkspaceNotEnabledException { WorkspaceWorkflow[] workspaceWorkflowList = workflowService.getWorkspaceWorkflowList(workspaceId); List<WorkspaceWorkflowDTO> workspaceWorkflowListDTO = new ArrayList<>(); for (WorkspaceWorkflow workspaceWorkflow : workspaceWorkflowList) { workspaceWorkflowListDTO.add(mapper.map(workspaceWorkflow, WorkspaceWorkflowDTO.class)); } return Response.ok(new GenericEntity<List<WorkspaceWorkflowDTO>>((List<WorkspaceWorkflowDTO>) workspaceWorkflowListDTO) { }).build(); } }
WorkspaceWorkflowResource { @GET @ApiOperation(value = "Get workspace workflow list in given workspace", response = WorkspaceWorkflowDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkspaceWorkflowDTOs. 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 getWorkspaceWorkflowList( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId) throws EntityNotFoundException, UserNotActiveException, WorkspaceNotEnabledException { WorkspaceWorkflow[] workspaceWorkflowList = workflowService.getWorkspaceWorkflowList(workspaceId); List<WorkspaceWorkflowDTO> workspaceWorkflowListDTO = new ArrayList<>(); for (WorkspaceWorkflow workspaceWorkflow : workspaceWorkflowList) { workspaceWorkflowListDTO.add(mapper.map(workspaceWorkflow, WorkspaceWorkflowDTO.class)); } return Response.ok(new GenericEntity<List<WorkspaceWorkflowDTO>>((List<WorkspaceWorkflowDTO>) workspaceWorkflowListDTO) { }).build(); } WorkspaceWorkflowResource(); }
WorkspaceWorkflowResource { @GET @ApiOperation(value = "Get workspace workflow list in given workspace", response = WorkspaceWorkflowDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkspaceWorkflowDTOs. 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 getWorkspaceWorkflowList( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId) throws EntityNotFoundException, UserNotActiveException, WorkspaceNotEnabledException { WorkspaceWorkflow[] workspaceWorkflowList = workflowService.getWorkspaceWorkflowList(workspaceId); List<WorkspaceWorkflowDTO> workspaceWorkflowListDTO = new ArrayList<>(); for (WorkspaceWorkflow workspaceWorkflow : workspaceWorkflowList) { workspaceWorkflowListDTO.add(mapper.map(workspaceWorkflow, WorkspaceWorkflowDTO.class)); } return Response.ok(new GenericEntity<List<WorkspaceWorkflowDTO>>((List<WorkspaceWorkflowDTO>) workspaceWorkflowListDTO) { }).build(); } WorkspaceWorkflowResource(); @PostConstruct void init(); @GET @ApiOperation(value = "Get workspace workflow list in given workspace", response = WorkspaceWorkflowDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkspaceWorkflowDTOs. 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 getWorkspaceWorkflowList(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId); @GET @ApiOperation(value = "Get a workspace workflow by id", response = WorkspaceWorkflowDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkspaceWorkflowDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{workspaceWorkflowId}") @Produces(MediaType.APPLICATION_JSON) WorkspaceWorkflowDTO getWorkspaceWorkflow(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Workspace workflow id") @PathParam("workspaceWorkflowId") String workspaceWorkflowId); @POST @ApiOperation(value = "Instantiate a workspace workflow from given workflow model", response = WorkspaceWorkflowDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkspaceWorkflowDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) WorkspaceWorkflowDTO createWorkspaceWorkflow(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Workspace workflow to create") WorkspaceWorkflowCreationDTO workflowCreationDTO); @DELETE @Path("{workspaceWorkflowId}") @ApiOperation(value = "Delete a workspace workflow", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful deletion operation"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) Response deleteWorkspaceWorkflow(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Workspace workflow id") @PathParam("workspaceWorkflowId") String workspaceWorkflowId); }
WorkspaceWorkflowResource { @GET @ApiOperation(value = "Get workspace workflow list in given workspace", response = WorkspaceWorkflowDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkspaceWorkflowDTOs. 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 getWorkspaceWorkflowList( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId) throws EntityNotFoundException, UserNotActiveException, WorkspaceNotEnabledException { WorkspaceWorkflow[] workspaceWorkflowList = workflowService.getWorkspaceWorkflowList(workspaceId); List<WorkspaceWorkflowDTO> workspaceWorkflowListDTO = new ArrayList<>(); for (WorkspaceWorkflow workspaceWorkflow : workspaceWorkflowList) { workspaceWorkflowListDTO.add(mapper.map(workspaceWorkflow, WorkspaceWorkflowDTO.class)); } return Response.ok(new GenericEntity<List<WorkspaceWorkflowDTO>>((List<WorkspaceWorkflowDTO>) workspaceWorkflowListDTO) { }).build(); } WorkspaceWorkflowResource(); @PostConstruct void init(); @GET @ApiOperation(value = "Get workspace workflow list in given workspace", response = WorkspaceWorkflowDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkspaceWorkflowDTOs. 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 getWorkspaceWorkflowList(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId); @GET @ApiOperation(value = "Get a workspace workflow by id", response = WorkspaceWorkflowDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkspaceWorkflowDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{workspaceWorkflowId}") @Produces(MediaType.APPLICATION_JSON) WorkspaceWorkflowDTO getWorkspaceWorkflow(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Workspace workflow id") @PathParam("workspaceWorkflowId") String workspaceWorkflowId); @POST @ApiOperation(value = "Instantiate a workspace workflow from given workflow model", response = WorkspaceWorkflowDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkspaceWorkflowDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) WorkspaceWorkflowDTO createWorkspaceWorkflow(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Workspace workflow to create") WorkspaceWorkflowCreationDTO workflowCreationDTO); @DELETE @Path("{workspaceWorkflowId}") @ApiOperation(value = "Delete a workspace workflow", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful deletion operation"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Produces(MediaType.APPLICATION_JSON) Response deleteWorkspaceWorkflow(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Workspace workflow id") @PathParam("workspaceWorkflowId") String workspaceWorkflowId);  }