Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix filling stateOptions for failure proceeding state (#211)
- Loading branch information
1 parent
b87c388
commit db7f7c7
Showing
13 changed files
with
143 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/test/java/io/iworkflow/integ/stateapifail/StateFailProceedToRecoverNoWaitUntil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.iworkflow.integ.stateapifail; | ||
|
||
import io.iworkflow.core.WorkflowStateOptionsExtension; | ||
import io.iworkflow.gen.models.RetryPolicy; | ||
import io.iworkflow.gen.models.WorkflowStateOptions; | ||
|
||
public class StateFailProceedToRecoverNoWaitUntil extends StateFailBasic { | ||
@Override | ||
public WorkflowStateOptions getStateOptions() { | ||
return new WorkflowStateOptionsExtension() | ||
.setProceedOnExecuteFailure(StateRecoverNoWaitUntil.class) | ||
.executeApiRetryPolicy( | ||
new RetryPolicy() | ||
.maximumAttempts(1) | ||
.backoffCoefficient(2f) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/test/java/io/iworkflow/integ/stateapifail/StateRecoverNoWaitUntil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.iworkflow.integ.stateapifail; | ||
|
||
import io.iworkflow.core.Context; | ||
import io.iworkflow.core.StateDecision; | ||
import io.iworkflow.core.WorkflowState; | ||
import io.iworkflow.core.command.CommandResults; | ||
import io.iworkflow.core.communication.Communication; | ||
import io.iworkflow.core.persistence.Persistence; | ||
|
||
public class StateRecoverNoWaitUntil implements WorkflowState<Integer> { | ||
|
||
@Override | ||
public Class<Integer> getInputType() { | ||
return Integer.class; | ||
} | ||
|
||
@Override | ||
public StateDecision execute( | ||
Context context, | ||
Integer input, | ||
CommandResults commandResults, | ||
Persistence persistence, | ||
final Communication communication) { | ||
if(input == 10){ | ||
return StateDecision.gracefulCompleteWorkflow(input); | ||
}else if(input == 5){ | ||
return StateDecision.singleNextState(StateFailProceedToRecoverNoWaitUntil.class, input * 2); | ||
}else{ | ||
return StateDecision.forceFailWorkflow("unexpected input "+input); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...st/java/io/iworkflow/integ/stateapifail/WorkflowStateFailProceedToRecoverNoWaitUntil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.iworkflow.integ.stateapifail; | ||
|
||
import io.iworkflow.core.ObjectWorkflow; | ||
import io.iworkflow.core.StateDef; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
@Component | ||
public class WorkflowStateFailProceedToRecoverNoWaitUntil implements ObjectWorkflow { | ||
@Override | ||
public List<StateDef> getWorkflowStates() { | ||
return Arrays.asList( | ||
StateDef.startingState(new StateFailProceedToRecoverNoWaitUntil()), | ||
StateDef.nonStartingState(new StateRecoverNoWaitUntil()) | ||
); | ||
} | ||
} |