org.requirementsascode.InterruptingFlowStep Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of requirementsascodecore Show documentation
Show all versions of requirementsascodecore Show documentation
Enables you to define and run executable use case specifications, in your code.
package org.requirementsascode;
import java.util.function.Predicate;
import org.requirementsascode.flowposition.FlowPosition;
public class InterruptingFlowStep extends FlowStep {
InterruptingFlowStep(String stepName, Flow useCaseFlow, FlowPosition flowPosition, Condition condition) {
super(stepName, useCaseFlow, condition);
setFlowPosition(flowPosition);
}
public Predicate getPredicate() {
Predicate predicate;
Condition reactWhile = getReactWhile();
predicate = isFlowConditionTrueAndRunnerInDifferentFlow();
if (reactWhile != null) {
predicate = predicate.and(toPredicate(reactWhile));
}
return predicate;
}
private Predicate isFlowConditionTrueAndRunnerInDifferentFlow() {
Predicate flowCondition = getFlowPosition().and(isRunnerInDifferentFlow()).and(isConditionTrue());
return flowCondition;
}
private Predicate isRunnerInDifferentFlow() {
Predicate isRunnerInDifferentFlow = runner -> runner.getLatestFlow()
.map(runnerFlow -> !runnerFlow.equals(getFlow())).orElse(true);
return isRunnerInDifferentFlow;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy