Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
add original execution id in WorkFlowResponseDTO
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardW98 authored and openshift-merge-robot committed Jul 27, 2023
1 parent 3299079 commit 6263160
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions workflow-service/generated/openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,10 @@
"executeBy" : {
"type" : "string"
},
"originalExecutionId" : {
"type" : "string",
"format" : "uuid"
},
"projectId" : {
"type" : "string",
"format" : "uuid"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public class WorkFlowResponseDTO {

private List<AdditionalInfo> additionalInfos;

private UUID originalExecutionId;

private WorkFlowType workFlowType;

public record AdditionalInfo(String key, String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import javax.annotation.PreDestroy;

import com.redhat.parodos.common.entity.AbstractEntity;
import com.redhat.parodos.common.exceptions.IllegalWorkFlowStateException;
import com.redhat.parodos.common.exceptions.ResourceNotFoundException;
import com.redhat.parodos.common.exceptions.ResourceType;
Expand Down Expand Up @@ -537,6 +538,8 @@ private WorkFlowResponseDTO buildWorkflowResponseDTO(WorkFlowExecution workflowE
.startDate(Optional.ofNullable(workflowExecution.getStartDate()).map(Date::toString).orElse(null))
.endDate(Optional.ofNullable(workflowExecution.getEndDate()).map(Date::toString).orElse(null))
.executeBy(workflowExecution.getUser().getUsername())
.originalExecutionId(Optional.ofNullable(workflowExecution.getOriginalWorkFlowExecution())
.map(AbstractEntity::getId).orElse(null))
.additionalInfos(Optional.ofNullable(workflowExecution.getWorkFlowExecutionContext())
.flatMap(workFlowExecutionContext -> Optional
.ofNullable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,9 @@ void getWorkFlowsByProjectId_when_projectIsFound_then_returnWorkFlowStatus() {
.status(WorkStatus.COMPLETED).workFlowDefinition(workFlowDefinition)
.workFlowExecutionContext(WorkFlowExecutionContext.builder().workContext(workContext).build()).build();
workFlowExecution.setId(workflowExecutionId);
WorkFlowExecution originalWorkFlowExecution = new WorkFlowExecution();
originalWorkFlowExecution.setId(UUID.randomUUID());
workFlowExecution.setOriginalWorkFlowExecution(originalWorkFlowExecution);

when(workFlowRepository.findAllByProjectId(projectId)).thenReturn(List.of(workFlowExecution));
when(projectService.getProjectByIdAndUserId(eq(projectId), eq(userId)))
Expand All @@ -1094,6 +1097,7 @@ void getWorkFlowsByProjectId_when_projectIsFound_then_returnWorkFlowStatus() {
assertThat(workFlowService.getWorkFlowsByProjectId(projectId)).hasSize(1).satisfies(workflowStatus -> {
assertEquals(workflowStatus.get(0).getAdditionalInfos().get(0),
new WorkFlowResponseDTO.AdditionalInfo(TEST_ADDITIONAL_INFO_KEY, TEST_ADDITIONAL_INFO_VALUE));
assertEquals(workflowStatus.get(0).getOriginalExecutionId(), originalWorkFlowExecution.getId());
assertEquals(WorkStatus.COMPLETED, workflowStatus.get(0).getWorkStatus());
});
}
Expand Down

0 comments on commit 6263160

Please sign in to comment.