diff --git a/workflow-service/generated/openapi/openapi.json b/workflow-service/generated/openapi/openapi.json index 41f740265..a9da4c45c 100644 --- a/workflow-service/generated/openapi/openapi.json +++ b/workflow-service/generated/openapi/openapi.json @@ -798,7 +798,8 @@ "type" : "object", "properties" : { "status" : { - "type" : "string" + "type" : "string", + "enum" : [ "FAILED", "COMPLETED", "IN_PROGRESS", "REJECTED", "PENDING" ] }, "workFlowExecutionId" : { "type" : "string", diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/dto/WorkFlowStatusResponseDTO.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/dto/WorkFlowStatusResponseDTO.java index f4e9dbaa9..e64a301dc 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/dto/WorkFlowStatusResponseDTO.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/dto/WorkFlowStatusResponseDTO.java @@ -19,6 +19,7 @@ import java.util.UUID; import com.fasterxml.jackson.annotation.JsonInclude; +import com.redhat.parodos.workflows.work.WorkStatus; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -41,7 +42,7 @@ public class WorkFlowStatusResponseDTO { private String workFlowName; - private String status; + private WorkStatus status; @JsonInclude(JsonInclude.Include.NON_NULL) private List works; diff --git a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/service/WorkFlowServiceImpl.java b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/service/WorkFlowServiceImpl.java index 5bd37f95f..09ac24fa3 100644 --- a/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/service/WorkFlowServiceImpl.java +++ b/workflow-service/src/main/java/com/redhat/parodos/workflow/execution/service/WorkFlowServiceImpl.java @@ -223,7 +223,7 @@ public WorkFlowStatusResponseDTO getWorkFlowStatus(UUID workFlowExecutionId) { .getWorkFlowAndWorksStatus(workFlowExecution, workFlowDefinition); return WorkFlowStatusResponseDTO.builder().workFlowExecutionId(workFlowExecution.getId()) - .workFlowName(workFlowDefinition.getName()).status(workFlowExecution.getStatus().name()) + .workFlowName(workFlowDefinition.getName()).status(workFlowExecution.getStatus()) .works(workFlowWorksStatusResponseDTOs).build(); } diff --git a/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/controller/WorkFlowControllerTest.java b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/controller/WorkFlowControllerTest.java index 10c28721a..633923a5a 100644 --- a/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/controller/WorkFlowControllerTest.java +++ b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/controller/WorkFlowControllerTest.java @@ -130,7 +130,7 @@ public void testGetStatus() throws Exception { String testWorkFlowTask1 = "testWorkFlowTask1"; WorkFlowStatusResponseDTO workFlowStatusResponseDTO = WorkFlowStatusResponseDTO.builder() - .workFlowExecutionId(mainWorkFlowExecutionId).status(WorkStatus.IN_PROGRESS.name()) + .workFlowExecutionId(mainWorkFlowExecutionId).status(WorkStatus.IN_PROGRESS) .workFlowName(testMainWorkFlow) .works(List.of( WorkStatusResponseDTO.builder().name(testSubWorkFlow1).status(WorkStatus.PENDING) diff --git a/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/service/WorkFlowServiceImplTest.java b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/service/WorkFlowServiceImplTest.java index 778f93b72..dfa537240 100644 --- a/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/service/WorkFlowServiceImplTest.java +++ b/workflow-service/src/test/java/com/redhat/parodos/workflow/execution/service/WorkFlowServiceImplTest.java @@ -556,28 +556,26 @@ void testGetWorkStatusWithValidData() { assertNotNull(workFlowStatusResponseDTO); assertEquals(workFlowExecution.getId(), workFlowStatusResponseDTO.getWorkFlowExecutionId()); assertEquals(workFlowStatusResponseDTO.getWorkFlowName(), workFlowDefinition.getName()); - assertEquals(workFlowStatusResponseDTO.getStatus(), WorkStatus.IN_PROGRESS.name()); + assertEquals(workFlowStatusResponseDTO.getStatus(), WorkStatus.IN_PROGRESS); assertEquals(workFlowStatusResponseDTO.getWorks().size(), 2); // subWorkflow1 assertEquals(workFlowStatusResponseDTO.getWorks().get(0).getType(), WorkType.WORKFLOW); assertEquals(workFlowStatusResponseDTO.getWorks().get(0).getName(), subWorkFlow1Definition.getName()); - assertEquals(workFlowStatusResponseDTO.getWorks().get(0).getStatus().name(), WorkStatus.PENDING.name()); + assertEquals(workFlowStatusResponseDTO.getWorks().get(0).getStatus(), WorkStatus.PENDING); assertEquals(workFlowStatusResponseDTO.getWorks().get(0).getWorks().size(), 1); // subWorkflow1Task1 assertEquals(workFlowStatusResponseDTO.getWorks().get(0).getWorks().get(0).getType(), WorkType.TASK); assertEquals(workFlowStatusResponseDTO.getWorks().get(0).getWorks().get(0).getName(), subWorkFlow1Task1Definition.getName()); - assertEquals(workFlowStatusResponseDTO.getWorks().get(0).getWorks().get(0).getStatus().name(), - WorkStatus.PENDING.name()); + assertEquals(workFlowStatusResponseDTO.getWorks().get(0).getWorks().get(0).getStatus(), WorkStatus.PENDING); assertNull(workFlowStatusResponseDTO.getWorks().get(0).getWorks().get(0).getWorks()); // workflowTask1 assertEquals(workFlowStatusResponseDTO.getWorks().get(1).getType(), WorkType.TASK); assertEquals(workFlowStatusResponseDTO.getWorks().get(1).getName(), workFlowTask1Definition.getName()); - assertEquals(workFlowStatusResponseDTO.getWorks().get(1).getStatus().name(), - WorkFlowTaskStatus.COMPLETED.name()); + assertEquals(workFlowStatusResponseDTO.getWorks().get(1).getStatus(), WorkStatus.COMPLETED); assertNull(workFlowStatusResponseDTO.getWorks().get(1).getWorks()); } @@ -732,7 +730,7 @@ void testGetWorkFlowStatusWhenSubWorkflowNotExecutedWithValidData() { assertNotNull(workFlowStatusResponseDTO); assertEquals(workFlowExecution.getId(), workFlowStatusResponseDTO.getWorkFlowExecutionId()); assertEquals(workFlowStatusResponseDTO.getWorkFlowName(), workFlowDefinition.getName()); - assertEquals(workFlowStatusResponseDTO.getStatus(), WorkStatus.IN_PROGRESS.name()); + assertEquals(workFlowStatusResponseDTO.getStatus(), WorkStatus.IN_PROGRESS); assertEquals(workFlowStatusResponseDTO.getWorks().size(), 2); // sub workflow 1