WorkspaceWorkflowResource { @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) public WorkspaceWorkflowDTO createWorkspaceWorkflow( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId, @ApiParam(required = true, value = "Workspace workflow to create") WorkspaceWorkflowCreationDTO workflowCreationDTO) throws EntityNotFoundException, AccessRightException, NotAllowedException, WorkspaceNotEnabledException { Map<String, Collection<String>> userRoleMapping = new HashMap<>(); Map<String, Collection<String>> groupRoleMapping = new HashMap<>(); RoleMappingDTO[] roleMappingDTOs = workflowCreationDTO.getRoleMapping(); if (roleMappingDTOs != null) { for (RoleMappingDTO roleMappingDTO : roleMappingDTOs) { userRoleMapping.put(roleMappingDTO.getRoleName(), roleMappingDTO.getUserLogins()); groupRoleMapping.put(roleMappingDTO.getRoleName(), roleMappingDTO.getGroupIds()); } } WorkspaceWorkflow workspaceWorkflow = workflowService.instantiateWorkflow(workspaceId, workflowCreationDTO.getId(), workflowCreationDTO.getWorkflowModelId(), userRoleMapping, groupRoleMapping); return mapper.map(workspaceWorkflow, WorkspaceWorkflowDTO.class); } 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);  }
@Test public void createWorkspaceWorkflowTest() throws ApplicationException { WorkspaceWorkflowCreationDTO workflowCreationDTO = new WorkspaceWorkflowCreationDTO(); workflowCreationDTO.setId("id"); RoleMappingDTO roleMappingDTO = new RoleMappingDTO(); roleMappingDTO.setRoleName("role"); List<String> loginList = Arrays.asList("foo", "bar"); roleMappingDTO.setUserLogins(loginList); RoleMappingDTO[] roleMapping = new RoleMappingDTO[]{roleMappingDTO}; workflowCreationDTO.setRoleMapping(roleMapping); workflowCreationDTO.setWorkflowModelId("modelId"); WorkspaceWorkflow workspaceWorkflow = new WorkspaceWorkflow(); workspaceWorkflow.setId("id"); Mockito.when(workflowService.instantiateWorkflow(Matchers.any(), Matchers.any(), Matchers.any(), Matchers.any(), Matchers.any())).thenReturn(workspaceWorkflow); WorkspaceWorkflowDTO result = workspaceWorkflowResource.createWorkspaceWorkflow(workspaceId, workflowCreationDTO); Assert.assertEquals(workflowCreationDTO.getId(), result.getId()); }