Skip to content

Commit

Permalink
improve: workflow builder naming (#2559)
Browse files Browse the repository at this point in the history
  • Loading branch information
csviri authored and metacosm committed Nov 6, 2024
1 parent 379de6d commit e13cce6
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,17 @@ public WorkflowBuilder<P> withThrowExceptionFurther(boolean throwExceptionFurthe
return WorkflowBuilder.this.withThrowExceptionFurther(throwExceptionFurther);
}

public WorkflowNodeConfigurationBuilder toDependOn(Set<DependentResource> dependentResources) {
public WorkflowNodeConfigurationBuilder dependsOn(Set<DependentResource> dependentResources) {
for (var dependentResource : dependentResources) {
var dependsOn = getNodeByDependentResource(dependentResource);
currentNode.addDependsOnRelation(dependsOn);
}
return this;
}

public WorkflowNodeConfigurationBuilder toDependOn(DependentResource... dependentResources) {
public WorkflowNodeConfigurationBuilder dependsOn(DependentResource... dependentResources) {
if (dependentResources != null) {
return toDependOn(new HashSet<>(Arrays.asList(dependentResources)));
return dependsOn(new HashSet<>(Arrays.asList(dependentResources)));
}
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ void setup() {
void cleanUpDiamondWorkflow() {
var workflow = new WorkflowBuilder<TestCustomResource>()
.addDependentResource(dd1)
.addDependentResourceAndConfigure(dr1).toDependOn(dd1)
.addDependentResourceAndConfigure(dd2).toDependOn(dd1)
.addDependentResourceAndConfigure(dd3).toDependOn(dr1, dd2)
.addDependentResourceAndConfigure(dr1).dependsOn(dd1)
.addDependentResourceAndConfigure(dd2).dependsOn(dd1)
.addDependentResourceAndConfigure(dd3).dependsOn(dr1, dd2)
.build();

var res = workflow.cleanup(new TestCustomResource(), mockContext);
Expand All @@ -73,9 +73,9 @@ void cleanUpDiamondWorkflow() {
void dontDeleteIfDependentErrored() {
var workflow = new WorkflowBuilder<TestCustomResource>()
.addDependentResource(dd1)
.addDependentResourceAndConfigure(dd2).toDependOn(dd1)
.addDependentResourceAndConfigure(dd3).toDependOn(dd2)
.addDependentResourceAndConfigure(errorDD).toDependOn(dd2)
.addDependentResourceAndConfigure(dd2).dependsOn(dd1)
.addDependentResourceAndConfigure(dd3).dependsOn(dd2)
.addDependentResourceAndConfigure(errorDD).dependsOn(dd2)
.withThrowExceptionFurther(false)
.build();

Expand All @@ -95,7 +95,7 @@ void dontDeleteIfDependentErrored() {
void cleanupConditionTrivialCase() {
var workflow = new WorkflowBuilder<TestCustomResource>()
.addDependentResource(dd1)
.addDependentResourceAndConfigure(dd2).toDependOn(dd1)
.addDependentResourceAndConfigure(dd2).dependsOn(dd1)
.withDeletePostcondition(notMetCondition)
.build();

Expand All @@ -111,7 +111,7 @@ void cleanupConditionTrivialCase() {
void cleanupConditionMet() {
var workflow = new WorkflowBuilder<TestCustomResource>()
.addDependentResource(dd1)
.addDependentResourceAndConfigure(dd2).toDependOn(dd1).withDeletePostcondition(metCondition)
.addDependentResourceAndConfigure(dd2).dependsOn(dd1).withDeletePostcondition(metCondition)
.build();

var res = workflow.cleanup(new TestCustomResource(), mockContext);
Expand All @@ -127,10 +127,10 @@ void cleanupConditionMet() {
void cleanupConditionDiamondWorkflow() {
var workflow = new WorkflowBuilder<TestCustomResource>()
.addDependentResource(dd1)
.addDependentResourceAndConfigure(dd2).toDependOn(dd1)
.addDependentResourceAndConfigure(dd3).toDependOn(dd1)
.addDependentResourceAndConfigure(dd2).dependsOn(dd1)
.addDependentResourceAndConfigure(dd3).dependsOn(dd1)
.withDeletePostcondition(notMetCondition)
.addDependentResourceAndConfigure(dd4).toDependOn(dd2, dd3)
.addDependentResourceAndConfigure(dd4).dependsOn(dd2, dd3)
.build();

var res = workflow.cleanup(new TestCustomResource(), mockContext);
Expand Down Expand Up @@ -164,10 +164,10 @@ void dontDeleteIfGarbageCollected() {
void ifDependentActiveDependentNormallyDeleted() {
var workflow = new WorkflowBuilder<TestCustomResource>()
.addDependentResource(dd1)
.addDependentResourceAndConfigure(dd2).toDependOn(dd1)
.addDependentResourceAndConfigure(dd3).toDependOn(dd1)
.addDependentResourceAndConfigure(dd2).dependsOn(dd1)
.addDependentResourceAndConfigure(dd3).dependsOn(dd1)
.withActivationCondition(metCondition)
.addDependentResourceAndConfigure(dd4).toDependOn(dd2, dd3)
.addDependentResourceAndConfigure(dd4).dependsOn(dd2, dd3)
.build();

var res = workflow.cleanup(new TestCustomResource(), mockContext);
Expand All @@ -184,11 +184,11 @@ void ifDependentActiveDependentNormallyDeleted() {
void ifDependentActiveDeletePostConditionIsChecked() {
var workflow = new WorkflowBuilder<TestCustomResource>()
.addDependentResource(dd1)
.addDependentResourceAndConfigure(dd2).toDependOn(dd1)
.addDependentResourceAndConfigure(dd3).toDependOn(dd1)
.addDependentResourceAndConfigure(dd2).dependsOn(dd1)
.addDependentResourceAndConfigure(dd3).dependsOn(dd1)
.withDeletePostcondition(notMetCondition)
.withActivationCondition(metCondition)
.addDependentResourceAndConfigure(dd4).toDependOn(dd2, dd3)
.addDependentResourceAndConfigure(dd4).dependsOn(dd2, dd3)
.build();

var res = workflow.cleanup(new TestCustomResource(), mockContext);
Expand All @@ -208,10 +208,10 @@ void ifDependentActiveDeletePostConditionIsChecked() {
void ifDependentInactiveDeleteIsNotCalled() {
var workflow = new WorkflowBuilder<TestCustomResource>()
.addDependentResource(dd1)
.addDependentResourceAndConfigure(dd2).toDependOn(dd1)
.addDependentResourceAndConfigure(dd3).toDependOn(dd1)
.addDependentResourceAndConfigure(dd2).dependsOn(dd1)
.addDependentResourceAndConfigure(dd3).dependsOn(dd1)
.withActivationCondition(notMetCondition)
.addDependentResourceAndConfigure(dd4).toDependOn(dd2, dd3)
.addDependentResourceAndConfigure(dd4).dependsOn(dd2, dd3)
.build();

var res = workflow.cleanup(new TestCustomResource(), mockContext);
Expand All @@ -227,11 +227,11 @@ void ifDependentInactiveDeleteIsNotCalled() {
void ifDependentInactiveDeletePostConditionNotChecked() {
var workflow = new WorkflowBuilder<TestCustomResource>()
.addDependentResource(dd1)
.addDependentResourceAndConfigure(dd2).toDependOn(dd1)
.addDependentResourceAndConfigure(dd3).toDependOn(dd1)
.addDependentResourceAndConfigure(dd2).dependsOn(dd1)
.addDependentResourceAndConfigure(dd3).dependsOn(dd1)
.withDeletePostcondition(notMetCondition)
.withActivationCondition(notMetCondition)
.addDependentResourceAndConfigure(dd4).toDependOn(dd2, dd3)
.addDependentResourceAndConfigure(dd4).dependsOn(dd2, dd3)
.build();

var res = workflow.cleanup(new TestCustomResource(), mockContext);
Expand Down
Loading

0 comments on commit e13cce6

Please sign in to comment.