WorkflowModelResource { @POST @ApiOperation(value = "Create a new workflow model", response = WorkflowModelDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of created WorkflowModelDTO"), @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) public WorkflowModelDTO createWorkflowModel( @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId, @ApiParam(required = true, value = "Workflow model to create rules to set") WorkflowModelDTO workflowModelDTOToPersist) throws EntityNotFoundException, EntityAlreadyExistsException, UserNotActiveException, NotAllowedException, AccessRightException, CreationException, WorkspaceNotEnabledException { List<ActivityModelDTO> activityModelDTOsList = workflowModelDTOToPersist.getActivityModels(); ActivityModel[] activityModels = extractActivityModelFromDTO(activityModelDTOsList); WorkflowModel workflowModel = workflowService.createWorkflowModel(workspaceId, workflowModelDTOToPersist.getReference(), workflowModelDTOToPersist.getFinalLifeCycleState(), activityModels); return mapper.map(workflowModel, WorkflowModelDTO.class); } WorkflowModelResource(); @PostConstruct void init(); @GET @ApiOperation(value = "Get workflow models in given workspace", response = WorkflowModelDTO.class, responseContainer = "List") @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkflowModelDTOs. 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) WorkflowModelDTO[] getWorkflowModelsInWorkspace(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId); @GET @ApiOperation(value = "Get workflow model by id", response = WorkflowModelDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of WorkflowModelDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{workflowModelId}") @Produces(MediaType.APPLICATION_JSON) WorkflowModelDTO getWorkflowModelInWorkspace(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Workflow model id") @PathParam("workflowModelId") String workflowModelId); @DELETE @ApiOperation(value = "Delete a workflow model", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful deletion of WorkflowModelDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{workflowModelId}") Response delWorkflowModel(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Workflow model id") @PathParam("workflowModelId") String workflowModelId); @PUT @ApiOperation(value = "Update a workflow model", response = WorkflowModelDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of updated WorkflowModelDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{workflowModelId}") @Produces(MediaType.APPLICATION_JSON) WorkflowModelDTO updateWorkflowModel(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Workflow model id") @PathParam("workflowModelId") String workflowModelId,
            @ApiParam(required = true, value = "Workflow model to update") WorkflowModelDTO workflowModelDTOToPersist); @PUT @ApiOperation(value = "Update workflow model ACL", response = Response.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Successful update of WorkflowModelDTO"), @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 500, message = "Internal server error") }) @Path("{workflowModelId}/acl") @Consumes(MediaType.APPLICATION_JSON) Response updateWorkflowModelACL(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String pWorkspaceId,
            @ApiParam(required = true, value = "Workflow model id") @PathParam("workflowModelId") String workflowModelId,
            @ApiParam(required = true, value = "ACL rules to set") ACLDTO acl); @POST @ApiOperation(value = "Create a new workflow model", response = WorkflowModelDTO.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of created WorkflowModelDTO"), @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) WorkflowModelDTO createWorkflowModel(
            @ApiParam(required = true, value = "Workspace id") @PathParam("workspaceId") String workspaceId,
            @ApiParam(required = true, value = "Workflow model to create rules to set") WorkflowModelDTO workflowModelDTOToPersist);  }
@Test public void createWorkflowModelTest() throws ApplicationException { String workflowModelId = "whatever"; WorkflowModel workflowModel = new WorkflowModel(workspace, workflowModelId, user, "state"); Mockito.when(workflowService.createWorkflowModel(Matchers.any(),Matchers.any(),Matchers.any(),Matchers.any())) .thenReturn(workflowModel); WorkflowModelDTO workflowModelDTO = new WorkflowModelDTO(); ActivityModelDTO activityModel1 = new ActivityModelDTO(); activityModel1.setType(ActivityType.SEQUENTIAL); ActivityModelDTO activityModel2 = new ActivityModelDTO(); activityModel2.setType(ActivityType.SEQUENTIAL); activityModel2.setRelaunchStep(0); workflowModelDTO.setActivityModels(Arrays.asList(activityModel1, activityModel2)); WorkflowModelDTO result = workflowModelResource.createWorkflowModel(workspaceId, workflowModelDTO); Assert.assertNotNull(result); }