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

Commit

Permalink
Return Checkers in WorkFlowDefinitions
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-farache committed Jun 30, 2023
1 parent 10e4fa0 commit 79c68e3
Show file tree
Hide file tree
Showing 24 changed files with 263 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;

import com.redhat.parodos.flows.common.WorkFlowTestBuilder;
Expand Down Expand Up @@ -79,12 +80,13 @@ private Consumer<WorkFlowDefinitionResponseDTO> getWorkFlowDefinitionResponseCon

assertNotNull(workFlowDefinition.getWorks());
assertEquals(1, workFlowDefinition.getWorks().size());
assertEquals("notificationTask", workFlowDefinition.getWorks().get(0).getName());
assertEquals(WorkDefinitionResponseDTO.WorkTypeEnum.TASK,
workFlowDefinition.getWorks().get(0).getWorkType());
assertTrue(CollectionUtils.isEmpty(workFlowDefinition.getWorks().get(0).getWorks()));
assertNull(workFlowDefinition.getWorks().get(0).getProcessingType());
assertNotNull(workFlowDefinition.getWorks().get(0).getParameters());
Optional<WorkDefinitionResponseDTO> firstWork = workFlowDefinition.getWorks().stream().findFirst();
assertTrue(firstWork.isPresent());
assertEquals("notificationTask", firstWork.get().getName());
assertEquals(WorkDefinitionResponseDTO.WorkTypeEnum.TASK, firstWork.get().getWorkType());
assertTrue(CollectionUtils.isEmpty(firstWork.get().getWorks()));
assertNull(firstWork.get().getProcessingType());
assertNotNull(firstWork.get().getParameters());
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,18 @@ private static Consumer<WorkFlowDefinitionResponseDTO> getWorkFlowDefinitionResp

assertNotNull(workFlowDefinition.getWorks());
assertEquals(2, workFlowDefinition.getWorks().size());
assertEquals("restCallTask", workFlowDefinition.getWorks().get(0).getName());
assertEquals(WorkDefinitionResponseDTO.WorkTypeEnum.TASK,
workFlowDefinition.getWorks().get(0).getWorkType());
assertTrue(CollectionUtils.isEmpty(workFlowDefinition.getWorks().get(0).getWorks()));
assertNull(workFlowDefinition.getWorks().get(0).getProcessingType());
assertNotNull(workFlowDefinition.getWorks().get(0).getParameters());

assertEquals("loggingTask", workFlowDefinition.getWorks().get(1).getName());
assertEquals(WorkDefinitionResponseDTO.WorkTypeEnum.TASK,
workFlowDefinition.getWorks().get(1).getWorkType());
assertTrue(CollectionUtils.isEmpty(workFlowDefinition.getWorks().get(1).getWorks()));
assertNull(workFlowDefinition.getWorks().get(1).getProcessingType());
assertNotNull(workFlowDefinition.getWorks().get(1).getParameters());
List<WorkDefinitionResponseDTO> works = workFlowDefinition.getWorks().stream().toList();
assertEquals("restCallTask", works.get(0).getName());
assertEquals(WorkDefinitionResponseDTO.WorkTypeEnum.TASK, works.get(0).getWorkType());
assertTrue(CollectionUtils.isEmpty(works.get(0).getWorks()));
assertNull(works.get(0).getProcessingType());
assertNotNull(works.get(0).getParameters());

assertEquals("loggingTask", works.get(1).getName());
assertEquals(WorkDefinitionResponseDTO.WorkTypeEnum.TASK, works.get(1).getWorkType());
assertTrue(CollectionUtils.isEmpty(works.get(1).getWorks()));
assertNull(works.get(1).getProcessingType());
assertNotNull(works.get(1).getParameters());
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.redhat.parodos.flows.negative;

import java.util.List;
import java.util.function.Consumer;

import com.redhat.parodos.flows.common.WorkFlowTestBuilder;
Expand Down Expand Up @@ -86,13 +87,13 @@ private static Consumer<WorkFlowDefinitionResponseDTO> getWorkFlowDefinitionResp

assertThat(workFlowDefinition.getWorks()).isNotNull();
assertThat(workFlowDefinition.getWorks()).hasSize(2);
assertThat(workFlowDefinition.getWorks().get(1).getName()).isEqualTo("doNothingAgainWorkFlowTask");
assertThat(workFlowDefinition.getWorks().get(1).getWorkType())
.isEqualTo(WorkDefinitionResponseDTO.WorkTypeEnum.TASK);
assertThat(workFlowDefinition.getWorks().get(1).getWorks()).isNullOrEmpty();
assertThat(workFlowDefinition.getWorks().get(1).getProcessingType()).isNull();
assertThat(workFlowDefinition.getWorks().get(1).getParameters()).isNotNull();
assertThat(workFlowDefinition.getWorks().get(0).getName()).isEqualTo("failedWithAlertMessageWorkFlowTask");
List<WorkDefinitionResponseDTO> works = workFlowDefinition.getWorks().stream().toList();
assertThat(works.get(1).getName()).isEqualTo("doNothingAgainWorkFlowTask");
assertThat(works.get(1).getWorkType()).isEqualTo(WorkDefinitionResponseDTO.WorkTypeEnum.TASK);
assertThat(works.get(1).getWorks()).isNullOrEmpty();
assertThat(works.get(1).getProcessingType()).isNull();
assertThat(works.get(1).getParameters()).isNotNull();
assertThat(works.get(0).getName()).isEqualTo("failedWithAlertMessageWorkFlowTask");
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.redhat.parodos.flows.negative;

import java.util.List;
import java.util.function.Consumer;

import com.redhat.parodos.flows.common.WorkFlowTestBuilder;
Expand Down Expand Up @@ -86,13 +87,13 @@ private static Consumer<WorkFlowDefinitionResponseDTO> getWorkFlowDefinitionResp

assertThat(workFlowDefinition.getWorks()).isNotNull();
assertThat(workFlowDefinition.getWorks()).hasSize(2);
assertThat(workFlowDefinition.getWorks().get(1).getName()).isEqualTo("doNothingWorkFlowTask");
assertThat(workFlowDefinition.getWorks().get(1).getWorkType())
.isEqualTo(WorkDefinitionResponseDTO.WorkTypeEnum.TASK);
assertThat(workFlowDefinition.getWorks().get(1).getWorks()).isNullOrEmpty();
assertThat(workFlowDefinition.getWorks().get(1).getProcessingType()).isNull();
assertThat(workFlowDefinition.getWorks().get(1).getParameters()).isNotNull();
assertThat(workFlowDefinition.getWorks().get(0).getName()).isEqualTo("pendingWithAlertMessageWorkFlowTask");
List<WorkDefinitionResponseDTO> works = workFlowDefinition.getWorks().stream().toList();
assertThat(works.get(1).getName()).isEqualTo("doNothingWorkFlowTask");
assertThat(works.get(1).getWorkType()).isEqualTo(WorkDefinitionResponseDTO.WorkTypeEnum.TASK);
assertThat(works.get(1).getWorks()).isNullOrEmpty();
assertThat(works.get(1).getProcessingType()).isNull();
assertThat(works.get(1).getParameters()).isNotNull();
assertThat(works.get(0).getName()).isEqualTo("pendingWithAlertMessageWorkFlowTask");
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.redhat.parodos.flows.negative;

import java.util.Optional;
import java.util.function.Consumer;

import com.redhat.parodos.flows.common.WorkFlowTestBuilder;
Expand All @@ -21,6 +22,7 @@
import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;

@Slf4j
public class SequentialFailedWithExceptionWorkFlowTest {
Expand Down Expand Up @@ -77,12 +79,13 @@ private static Consumer<WorkFlowDefinitionResponseDTO> getWorkFlowDefinitionResp

assertThat(workFlowDefinition.getWorks()).isNotNull();
assertThat(workFlowDefinition.getWorks()).hasSize(1);
assertThat(workFlowDefinition.getWorks().get(0).getName()).isEqualTo("failedWithExceptionWorkFlowTask");
assertThat(workFlowDefinition.getWorks().get(0).getWorkType())
.isEqualTo(WorkDefinitionResponseDTO.WorkTypeEnum.TASK);
assertThat(workFlowDefinition.getWorks().get(0).getWorks()).isNullOrEmpty();
assertThat(workFlowDefinition.getWorks().get(0).getProcessingType()).isNull();
assertThat(workFlowDefinition.getWorks().get(0).getParameters()).isNotNull();
Optional<WorkDefinitionResponseDTO> firstWork = workFlowDefinition.getWorks().stream().findFirst();
assertTrue(firstWork.isPresent());
assertThat(firstWork.get().getName()).isEqualTo("failedWithExceptionWorkFlowTask");
assertThat(firstWork.get().getWorkType()).isEqualTo(WorkDefinitionResponseDTO.WorkTypeEnum.TASK);
assertThat(firstWork.get().getWorks()).isNullOrEmpty();
assertThat(firstWork.get().getProcessingType()).isNull();
assertThat(firstWork.get().getParameters()).isNotNull();
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.redhat.parodos.flows.negative;

import java.util.Optional;
import java.util.function.Consumer;

import com.redhat.parodos.flows.common.WorkFlowTestBuilder;
Expand All @@ -21,6 +22,7 @@
import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;

@Slf4j
public class SequentialFailedWorkFlowTest {
Expand Down Expand Up @@ -74,12 +76,13 @@ private static Consumer<WorkFlowDefinitionResponseDTO> getWorkFlowDefinitionResp

assertThat(workFlowDefinition.getWorks()).isNotNull();
assertThat(workFlowDefinition.getWorks()).hasSize(1);
assertThat(workFlowDefinition.getWorks().get(0).getName()).isEqualTo("failedWorkFlowTask");
assertThat(workFlowDefinition.getWorks().get(0).getWorkType())
.isEqualTo(WorkDefinitionResponseDTO.WorkTypeEnum.TASK);
assertThat(workFlowDefinition.getWorks().get(0).getWorks()).isNullOrEmpty();
assertThat(workFlowDefinition.getWorks().get(0).getProcessingType()).isNull();
assertThat(workFlowDefinition.getWorks().get(0).getParameters()).isNotNull();
Optional<WorkDefinitionResponseDTO> firstWork = workFlowDefinition.getWorks().stream().findFirst();
assertTrue(firstWork.isPresent());
assertThat(firstWork.get().getName()).isEqualTo("failedWorkFlowTask");
assertThat(firstWork.get().getWorkType()).isEqualTo(WorkDefinitionResponseDTO.WorkTypeEnum.TASK);
assertThat(firstWork.get().getWorks()).isNullOrEmpty();
assertThat(firstWork.get().getProcessingType()).isNull();
assertThat(firstWork.get().getParameters()).isNotNull();
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
*/
public enum WorkType {

TASK, WORKFLOW
TASK, WORKFLOW, CHECKER

}
8 changes: 8 additions & 0 deletions workflow-service-sdk/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1133,11 +1133,13 @@ components:
enum:
- TASK
- WORKFLOW
- CHECKER
type: string
works:
items:
$ref: '#/components/schemas/WorkDefinitionResponseDTO'
type: array
uniqueItems: true
type: object
WorkFlowCheckerTaskRequestDTO:
example:
Expand Down Expand Up @@ -1259,6 +1261,7 @@ components:
type: object
WorkFlowDefinitionResponseDTO:
example:
cronExpression: cronExpression
processingType: SEQUENTIAL
rollbackWorkflow: rollbackWorkflow
works:
Expand Down Expand Up @@ -1307,6 +1310,8 @@ components:
createDate:
format: date-time
type: string
cronExpression:
type: string
id:
format: uuid
type: string
Expand Down Expand Up @@ -1342,6 +1347,7 @@ components:
items:
$ref: '#/components/schemas/WorkDefinitionResponseDTO'
type: array
uniqueItems: true
type: object
WorkFlowExecutionResponseDTO:
example:
Expand Down Expand Up @@ -1703,6 +1709,7 @@ components:
enum:
- TASK
- WORKFLOW
- CHECKER
type: string
workName:
type: string
Expand Down Expand Up @@ -1736,6 +1743,7 @@ components:
enum:
- TASK
- WORKFLOW
- CHECKER
type: string
works:
items:
Expand Down
3 changes: 2 additions & 1 deletion workflow-service-sdk/docs/WorkDefinitionResponseDTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
|**parameters** | **Map&lt;String, Map&lt;String, Object&gt;&gt;** | | [optional] |
|**processingType** | [**ProcessingTypeEnum**](#ProcessingTypeEnum) | | [optional] |
|**workType** | [**WorkTypeEnum**](#WorkTypeEnum) | | [optional] |
|**works** | [**List&lt;WorkDefinitionResponseDTO&gt;**](WorkDefinitionResponseDTO.md) | | [optional] |
|**works** | [**Set&lt;WorkDefinitionResponseDTO&gt;**](WorkDefinitionResponseDTO.md) | | [optional] |



Expand Down Expand Up @@ -45,6 +45,7 @@
|---- | -----|
| TASK | &quot;TASK&quot; |
| WORKFLOW | &quot;WORKFLOW&quot; |
| CHECKER | &quot;CHECKER&quot; |



3 changes: 2 additions & 1 deletion workflow-service-sdk/docs/WorkFlowDefinitionResponseDTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
|------------ | ------------- | ------------- | -------------|
|**author** | **String** | | [optional] |
|**createDate** | **Date** | | [optional] |
|**cronExpression** | **String** | | [optional] |
|**id** | **UUID** | | [optional] |
|**modifyDate** | **Date** | | [optional] |
|**name** | **String** | | [optional] |
Expand All @@ -17,7 +18,7 @@
|**properties** | [**WorkFlowPropertiesDefinitionDTO**](WorkFlowPropertiesDefinitionDTO.md) | | [optional] |
|**rollbackWorkflow** | **String** | | [optional] |
|**type** | [**TypeEnum**](#TypeEnum) | | [optional] |
|**works** | [**List&lt;WorkDefinitionResponseDTO&gt;**](WorkDefinitionResponseDTO.md) | | [optional] |
|**works** | [**Set&lt;WorkDefinitionResponseDTO&gt;**](WorkDefinitionResponseDTO.md) | | [optional] |



Expand Down
1 change: 1 addition & 0 deletions workflow-service-sdk/docs/WorkRequestDTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
|---- | -----|
| TASK | &quot;TASK&quot; |
| WORKFLOW | &quot;WORKFLOW&quot; |
| CHECKER | &quot;CHECKER&quot; |



1 change: 1 addition & 0 deletions workflow-service-sdk/docs/WorkStatusResponseDTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
|---- | -----|
| TASK | &quot;TASK&quot; |
| WORKFLOW | &quot;WORKFLOW&quot; |
| CHECKER | &quot;CHECKER&quot; |



Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -188,7 +189,9 @@ public enum WorkTypeEnum {

TASK("TASK"),

WORKFLOW("WORKFLOW");
WORKFLOW("WORKFLOW"),

CHECKER("CHECKER");

private String value;

Expand Down Expand Up @@ -239,7 +242,7 @@ public WorkTypeEnum read(final JsonReader jsonReader) throws IOException {
public static final String SERIALIZED_NAME_WORKS = "works";

@SerializedName(SERIALIZED_NAME_WORKS)
private List<WorkDefinitionResponseDTO> works;
private Set<WorkDefinitionResponseDTO> works;

public WorkDefinitionResponseDTO() {
}
Expand Down Expand Up @@ -393,15 +396,15 @@ public void setWorkType(WorkTypeEnum workType) {
this.workType = workType;
}

public WorkDefinitionResponseDTO works(List<WorkDefinitionResponseDTO> works) {
public WorkDefinitionResponseDTO works(Set<WorkDefinitionResponseDTO> works) {

this.works = works;
return this;
}

public WorkDefinitionResponseDTO addWorksItem(WorkDefinitionResponseDTO worksItem) {
if (this.works == null) {
this.works = new ArrayList<>();
this.works = new LinkedHashSet<>();
}
this.works.add(worksItem);
return this;
Expand All @@ -412,11 +415,11 @@ public WorkDefinitionResponseDTO addWorksItem(WorkDefinitionResponseDTO worksIte
* @return works
**/
@javax.annotation.Nullable
public List<WorkDefinitionResponseDTO> getWorks() {
public Set<WorkDefinitionResponseDTO> getWorks() {
return works;
}

public void setWorks(List<WorkDefinitionResponseDTO> works) {
public void setWorks(Set<WorkDefinitionResponseDTO> works) {
this.works = works;
}

Expand Down
Loading

0 comments on commit 79c68e3

Please sign in to comment.