Interface WorkflowEngineTestingState
This type exists to give the test driver and the BDD fixture phases a common view of "what workflow instance is
currently under test". Workflow tests often first select an active WorkflowExecution or a recorded
WorkflowHistory and then perform several assertions against that same workflow state. Without this shared
object, every assertion method would need to repeat selection logic or require the caller to pass workflow ids,
executions, or histories through every step of the fluent API.
The design therefore separates two responsibilities:
WorkflowTestDriverdiscovers executions and history entries and updates the current selectionWorkflowEngineTestingStatekeeps that selection and exposes reusable assertions over the selectedWorkflowState
This separation keeps GivenWhen, Then, and the imperative driver APIs fluent. A test can select an
execution once and then assert waiting steps, passed steps, payload, or step status without restating which workflow
instance those assertions should inspect. The state also abstracts over active and completed workflows by exposing
state(), which resolves to the live execution state when an execution is selected and otherwise falls back to
the selected history entry.
- Since:
- 5.4.0
- Author:
- Simon Zambrovski
-
Method Summary
Modifier and TypeMethodDescriptionReturns the current workflow execution.voidhasSteps(AssertionFailureHandler assertionFailureHandler, String stepName, String... stepNames) Verifies that given steps exist in the workflow state.default voidVerifies that given steps exist in the workflow state.voidhasStepsInAnyOrder(AssertionFailureHandler assertionFailureHandler, String stepName, String... stepNames) Verifies that given steps exist in the workflow state in any order.default voidhasStepsInAnyOrder(String stepName, String... stepNames) Verifies that given steps exist in the workflow state in any order.voidhasStepsInOrder(AssertionFailureHandler assertionFailureHandler, String stepName, String... stepNames) Verifies that given steps exist in the workflow state in the given order.default voidhasStepsInOrder(String stepName, String... stepNames) Verifies that given steps exist in the workflow state in the given order.history()Returns the current workflow history.voidVerifies that given steps do not exist in the workflow state.Returns the workflow payload after asserting it exists.payloadMatches(AssertionFailureHandler assertionFailureHandler, Predicate<Map<String, @Nullable Object>> predicate) Waits until the workflow payload matches the given predicate.payloadMatches(Predicate<Map<String, @Nullable Object>> predicate) Waits until the workflow payload matches the given predicate.voidpayloadSatisfies(Consumer<Map<String, @Nullable Object>> payloadConsumer) Applies a consumer to the workflow payload after asserting it exists.state()Returns the historic workflow state.default WorkflowStepstep(AssertionFailureHandler assertionFailureHandler, Predicate<WorkflowStep> predicate) Waits until a step satisfies the given predicate.default WorkflowStepstep(Predicate<WorkflowStep> predicate) Waits until a step satisfies the given predicate.default WorkflowStepWaits until a workflow step exists.stepMatches(AssertionFailureHandler assertionFailureHandler, Predicate<WorkflowStep> predicate) Waits until a step satisfies the given predicate.default WorkflowStepstepMatches(Predicate<WorkflowStep> predicate) Waits until a step satisfies the given predicate.voidstepSatisfies(AssertionFailureHandler assertionFailureHandler, Predicate<WorkflowStep> predicate, Consumer<WorkflowStep> stepConsumer) Applies a consumer to the first step matching the predicate.voidstepSatisfies(Consumer<WorkflowStep> stepConsumer) Applies a consumer to an existing workflow step.default voidstepSatisfies(Predicate<WorkflowStep> predicate, Consumer<WorkflowStep> stepConsumer) Applies a consumer to the first step matching the predicate.voidstepsPassed(AssertionFailureHandler assertionFailureHandler, String stepName, String... stepNames) Verifies that given steps have passed.default voidstepsPassed(String stepName, String... stepNames) Verifies that given steps have passed.voidwaitingIn(AssertionFailureHandler assertionFailureHandler, String stepName, String... stepNames) Verifies that given steps are waiting in the workflow execution.default voidVerifies that given steps are waiting in the workflow execution.default WorkflowStateReturns the workflow state after asserting it exists.workflowStateMatches(AssertionFailureHandler assertionFailureHandler, Predicate<WorkflowState> predicate) Waits until the workflow state matches the given predicate.default WorkflowStateworkflowStateMatches(Predicate<WorkflowState> predicate) Waits until the workflow state matches the given predicate.voidworkflowStateSatisfies(Consumer<WorkflowState> workflowStateConsumer) Applies a consumer to the workflow state.
-
Method Details
-
execution
WorkflowExecution execution()Returns the current workflow execution.- Returns:
- the current workflow execution
-
history
WorkflowHistory history()Returns the current workflow history.- Returns:
- the current workflow history
-
state
WorkflowState state()Returns the historic workflow state.- Returns:
- the historic workflow state
-
waitingIn
void waitingIn(AssertionFailureHandler assertionFailureHandler, String stepName, String... stepNames) Verifies that given steps are waiting in the workflow execution.- Parameters:
assertionFailureHandler- handler for assertion failuresstepName- first expected waiting step namestepNames- additional optional expected waiting step names
-
waitingIn
Verifies that given steps are waiting in the workflow execution.- Parameters:
stepName- first expected waiting step namestepNames- additional optional expected waiting step names
-
stepsPassed
void stepsPassed(AssertionFailureHandler assertionFailureHandler, String stepName, String... stepNames) Verifies that given steps have passed.- Parameters:
assertionFailureHandler- handler for assertion failuresstepName- first expected passed step namestepNames- additional optional expected passed step names
-
stepsPassed
Verifies that given steps have passed.- Parameters:
stepName- first expected passed step namestepNames- additional optional expected passed step names
-
hasSteps
void hasSteps(AssertionFailureHandler assertionFailureHandler, String stepName, String... stepNames) Verifies that given steps exist in the workflow state.- Parameters:
assertionFailureHandler- handler for assertion failuresstepName- first expected step namestepNames- additional optional expected step names
-
hasSteps
Verifies that given steps exist in the workflow state.- Parameters:
stepName- first expected step namestepNames- additional optional expected step names
-
hasStepsInAnyOrder
void hasStepsInAnyOrder(AssertionFailureHandler assertionFailureHandler, String stepName, String... stepNames) Verifies that given steps exist in the workflow state in any order.- Parameters:
assertionFailureHandler- handler for assertion failuresstepName- first expected step namestepNames- additional optional expected step names
-
hasStepsInAnyOrder
Verifies that given steps exist in the workflow state in any order.- Parameters:
stepName- first expected step namestepNames- additional optional expected step names
-
hasStepsInOrder
void hasStepsInOrder(AssertionFailureHandler assertionFailureHandler, String stepName, String... stepNames) Verifies that given steps exist in the workflow state in the given order.- Parameters:
assertionFailureHandler- handler for assertion failuresstepName- first expected step namestepNames- additional optional expected step names
-
hasStepsInOrder
Verifies that given steps exist in the workflow state in the given order.- Parameters:
stepName- first expected step namestepNames- additional optional expected step names
-
noStep
Verifies that given steps do not exist in the workflow state.- Parameters:
stepName- first expected step namestepNames- additional optional step names
-
stepMatches
WorkflowStep stepMatches(AssertionFailureHandler assertionFailureHandler, Predicate<WorkflowStep> predicate) Waits until a step satisfies the given predicate.- Parameters:
assertionFailureHandler- handler for assertion failurespredicate- predicate for the workflow step- Returns:
- the matching workflow step
-
step
default WorkflowStep step(AssertionFailureHandler assertionFailureHandler, Predicate<WorkflowStep> predicate) Waits until a step satisfies the given predicate.- Parameters:
assertionFailureHandler- handler for assertion failurespredicate- predicate for the workflow step- Returns:
- the matching workflow step
-
stepMatches
Waits until a step satisfies the given predicate.- Parameters:
predicate- predicate for the workflow step- Returns:
- the matching workflow step
-
step
Waits until a step satisfies the given predicate.- Parameters:
predicate- predicate for the workflow step- Returns:
- the matching workflow step
-
stepExists
Waits until a workflow step exists.- Returns:
- the first available workflow step
-
stepSatisfies
Applies a consumer to an existing workflow step.- Parameters:
stepConsumer- consumer to apply to the step
-
stepSatisfies
void stepSatisfies(AssertionFailureHandler assertionFailureHandler, Predicate<WorkflowStep> predicate, Consumer<WorkflowStep> stepConsumer) Applies a consumer to the first step matching the predicate.- Parameters:
assertionFailureHandler- handler for assertion failurespredicate- predicate for the workflow stepstepConsumer- consumer to apply to the matching step
-
stepSatisfies
Applies a consumer to the first step matching the predicate.- Parameters:
predicate- predicate for the workflow stepstepConsumer- consumer to apply to the matching step
-
payloadMatches
Map<String,@Nullable Object> payloadMatches(AssertionFailureHandler assertionFailureHandler, Predicate<Map<String, @Nullable Object>> predicate) Waits until the workflow payload matches the given predicate.- Parameters:
assertionFailureHandler- handler for assertion failurespredicate- predicate for the workflow payload- Returns:
- the matching workflow payload
-
payloadMatches
default Map<String,@Nullable Object> payloadMatches(Predicate<Map<String, @Nullable Object>> predicate) Waits until the workflow payload matches the given predicate.- Parameters:
predicate- predicate for the workflow payload- Returns:
- the matching workflow payload
-
payloadExists
Returns the workflow payload after asserting it exists.- Returns:
- the workflow payload
-
payloadSatisfies
Applies a consumer to the workflow payload after asserting it exists.- Parameters:
payloadConsumer- consumer for the workflow payload
-
workflowStateMatches
WorkflowState workflowStateMatches(AssertionFailureHandler assertionFailureHandler, Predicate<WorkflowState> predicate) Waits until the workflow state matches the given predicate.- Parameters:
assertionFailureHandler- handler for assertion failurespredicate- predicate for the workflow state- Returns:
- the matching workflow state
-
workflowStateMatches
Waits until the workflow state matches the given predicate.- Parameters:
predicate- predicate for the workflow state- Returns:
- the matching workflow state
-
workflowStateExists
Returns the workflow state after asserting it exists.- Returns:
- the workflow state
-
workflowStateSatisfies
Applies a consumer to the workflow state.- Parameters:
workflowStateConsumer- consumer for the workflow state
-