Class GivenWhen<SELF extends GivenWhen<SELF,ASSERT>,ASSERT extends Then<ASSERT,SELF>>
java.lang.Object
io.axoniq.framework.workflow.runtime.test.fixture.Phase<SELF>
io.axoniq.framework.workflow.runtime.test.fixture.GivenWhen<SELF,ASSERT>
- Type Parameters:
SELF- type of action stageASSERT- type of assert stage
- Direct Known Subclasses:
GivenWhen.Phase
public class GivenWhen<SELF extends GivenWhen<SELF,ASSERT>,ASSERT extends Then<ASSERT,SELF>>
extends Phase<SELF>
A stage for defining the workflow actions
- Since:
- 5.4.0
- Author:
- Simon Zambrovski
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReleases an execute step by invoking the original workflow-defined action.execute(String stepName, PayloadProcessor payloadProcessor) Supplies a fake action for an execute step and waits until the step reaches a terminal state.executeFailing(String stepName, StepFailedException expectedFailure) Supplies a fake failing execute-step action and asserts that the step fails.executeReturning(String stepName, Map<String, @Nullable Object> expectedPayload) Supplies a fake successful execute-step result and asserts that the step completes.Waits until any active workflow execution exists.executionExists(Predicate<WorkflowExecution> predicate) Waits until an active workflow execution matching the predicate exists.historyExists(WorkflowStatus workflowStatus) Waits until at least one workflow history exists and has the given status.historyExists(String workflowId) Waits until a workflow history exists for the given workflow id.historyExists(Predicate<WorkflowHistory> predicate) Waits until a workflow history matching the predicate exists.protected voidinitialize(WorkflowTestFixture<?, ?> fixture, WorkflowTestDriver testDriver) Initializes this phase with the owning fixture and the shared test driver.Asserts that no active workflow execution is present.Asserts that no workflow history is recorded.publishEvent(Object event) Publishes an event through the fixture event bus.voidstop()Shuts down the test driver and all services.then()Returns the assert phase to usetimePasses(Duration duration) Advances fixture-controlled time and runs all due timeout tasks.when()Returns the action phase to use.
-
Field Details
-
fixture
-
testDriver
-
-
Constructor Details
-
GivenWhen
public GivenWhen()
-
-
Method Details
-
when
Returns the action phase to use.- Returns:
- fixture to continue fluent invocations
-
then
Returns the assert phase to use- Returns:
- assert phase to continue fluent invocations
-
publishEvent
Publishes an event through the fixture event bus.- Parameters:
event- event payload or an already constructed event message- Returns:
- this phase for fluent chaining
-
execute
Releases an execute step by invoking the original workflow-defined action.- Parameters:
stepName- step name to release- Returns:
- this phase for fluent chaining
-
execute
Supplies a fake action for an execute step and waits until the step reaches a terminal state.- Parameters:
stepName- step name to releasepayloadProcessor- fake action to invoke instead of the workflow-defined action- Returns:
- this phase for fluent chaining
-
executeReturning
Supplies a fake successful execute-step result and asserts that the step completes.- Parameters:
stepName- step name to releaseexpectedPayload- payload returned by the fake step action- Returns:
- this phase for fluent chaining
-
executeFailing
Supplies a fake failing execute-step action and asserts that the step fails.- Parameters:
stepName- step name to releaseexpectedFailure- failure thrown by the fake action- Returns:
- this phase for fluent chaining
-
timePasses
Advances fixture-controlled time and runs all due timeout tasks.- Parameters:
duration- duration by which fixture time advances- Returns:
- this phase for fluent chaining
-
initialize
Initializes this phase with the owning fixture and the shared test driver.The fixture calls this during construction so both phases operate on the same underlying workflow runtime and testing state.
- Parameters:
fixture- owning workflow test fixturetestDriver- shared workflow test driver
-
executionExists
Waits until any active workflow execution exists.- Returns:
- this phase for fluent chaining
-
executionExists
Waits until an active workflow execution matching the predicate exists.If exactly one execution matches, it becomes the selected execution for subsequent assertions.
- Parameters:
predicate- predicate used to select matching executions- Returns:
- this phase for fluent chaining
-
historyExists
Waits until a workflow history matching the predicate exists.If exactly one history matches, it becomes the selected history for subsequent assertions.
- Parameters:
predicate- predicate used to select matching histories- Returns:
- this phase for fluent chaining
-
historyExists
Waits until a workflow history exists for the given workflow id.- Parameters:
workflowId- workflow id to find- Returns:
- this phase for fluent chaining
-
historyExists
Waits until at least one workflow history exists and has the given status.- Parameters:
workflowStatus- expected workflow status- Returns:
- this phase for fluent chaining
-
noExecution
Asserts that no active workflow execution is present.- Returns:
- this phase for fluent chaining
-
noHistory
Asserts that no workflow history is recorded.- Returns:
- this phase for fluent chaining
-
stop
public void stop()Shuts down the test driver and all services.
-