Interface WorkflowTestFixture<ACTION extends GivenWhen<ACTION,ASSERT>,ASSERT extends Then<ASSERT,ACTION>>
- Type Parameters:
ACTION- type of the action phase used forgiven()andwhen()ASSERT- type of the assertion phase used forthen()
- All Known Implementing Classes:
DefaultWorkflowTestFixture
This fixture wraps a WorkflowTestDriver in a small phase-oriented API so tests can read as
given / when / then scenarios while still exercising the real workflow runtime. The fixture starts the
workflow module in stepping mode, publishes real events, records normal workflow history, and keeps the selected
execution or history entry shared across all phases.
The phase model is intentionally small:
given()returns the action phase for arranging workflow state before the behavior under testwhen()returns the same action phase, but named for the stimulus or transition being testedthen()returns the assertion phase for verifying workflow state, steps, history, or payload
All phases are bound to the same underlying workflow runtime. Switching between them does not reset the fixture or start a new workflow test driver; it only changes which fluent operations are exposed next.
Failures are intentionally surfaced differently per phase. Action-phase methods reached through given()
and when() use WorkflowTestFixtureException for fixture-driving failures such as missing executions
or steps that never reach the expected terminal state. Assertion-phase methods reached through then() fail
with plain AssertionErrors, so they behave like conventional test assertions.
- Since:
- 5.4.0
- Author:
- Simon Zambrovski
-
Method Summary
Modifier and TypeMethodDescriptiongiven()Returns the action phase in its setup role.static <T extends WorkflowContext>
WorkflowTestFixture<GivenWhen.Phase, Then.Phase> of(WorkflowModule<T> workflowModule) Creates a fixture with the default action and assertion phases.static <T extends WorkflowContext>
WorkflowTestFixture<GivenWhen.Phase, Then.Phase> of(WorkflowModule<T> workflowModule, UnaryOperator<WorkflowConfigurer> customize) Creates a fixture with the default action and assertion phases and a custom configuration step.static <T extends WorkflowContext,ACTION extends GivenWhen<ACTION, ASSERT>, ASSERT extends Then<ASSERT, ACTION>>
WorkflowTestFixture<ACTION, ASSERT> of(WorkflowModule<T> workflowModule, UnaryOperator<WorkflowConfigurer> customize, ACTION givenWhenPhase, ASSERT thenPhase) Creates a fixture with caller-supplied action and assertion phases.then()Returns the assertion phase.when()Returns the action phase in its stimulus role.static <T extends WorkflowContext>
WorkflowModule<T> workflowModule(Class<T> contextType, ComponentBuilder<WorkflowContextFactory<T>> workflowContextFactoryBuilder, ComponentBuilder<Object> workflowInstanceBuilder) Builds an autodetectedWorkflowModuleregistered underWorkflowTestServices.DEFAULT_MODULE_NAME, ready to be passed intoof(WorkflowModule)orof(WorkflowModule, UnaryOperator).
-
Method Details
-
workflowModule
static <T extends WorkflowContext> WorkflowModule<T> workflowModule(Class<T> contextType, ComponentBuilder<WorkflowContextFactory<T>> workflowContextFactoryBuilder, ComponentBuilder<Object> workflowInstanceBuilder) Builds an autodetectedWorkflowModuleregistered underWorkflowTestServices.DEFAULT_MODULE_NAME, ready to be passed intoof(WorkflowModule)orof(WorkflowModule, UnaryOperator).- Type Parameters:
T- type of the workflow context- Parameters:
contextType- type of the workflow contextworkflowContextFactoryBuilder- builder of theWorkflowContextFactoryfor the workflow contextworkflowInstanceBuilder- builder of the workflow instance to autodetect handlers on- Returns:
- workflow module ready for use in a
WorkflowTestFixture
-
of
static <T extends WorkflowContext> WorkflowTestFixture<GivenWhen.Phase,Then.Phase> of(WorkflowModule<T> workflowModule) Creates a fixture with the default action and assertion phases.- Type Parameters:
T- type of the workflow context- Parameters:
workflowModule- workflow module to test- Returns:
- fixture backed by the supplied workflow module
-
of
static <T extends WorkflowContext> WorkflowTestFixture<GivenWhen.Phase,Then.Phase> of(WorkflowModule<T> workflowModule, UnaryOperator<WorkflowConfigurer> customize) Creates a fixture with the default action and assertion phases and a custom configuration step.- Type Parameters:
T- type of the workflow context- Parameters:
workflowModule- workflow module to testcustomize- customizer of the workflow configuration- Returns:
- fixture backed by the supplied workflow module and customization
-
of
static <T extends WorkflowContext,ACTION extends GivenWhen<ACTION, WorkflowTestFixture<ACTION,ASSERT>, ASSERT extends Then<ASSERT, ACTION>> ASSERT> of(WorkflowModule<T> workflowModule, UnaryOperator<WorkflowConfigurer> customize, ACTION givenWhenPhase, ASSERT thenPhase) Creates a fixture with caller-supplied action and assertion phases.Use this overload to introduce domain-specific phase methods while keeping the same underlying fixture behavior.
- Type Parameters:
T- type of the workflow contextACTION- type of the action phaseASSERT- type of the assertion phase- Parameters:
workflowModule- workflow module to testcustomize- customizer of the workflow configurationgivenWhenPhase- phase instance used forgiven()andwhen()thenPhase- phase instance used forthen()- Returns:
- fixture backed by the supplied workflow module and custom phases
-
given
ACTION given()Returns the action phase in its setup role.Use this entry point for the given part of a scenario, where the test prepares workflow state before the main behavior is triggered. The returned object is the shared action phase instance used by this fixture. Failures raised while driving the fixture from this phase are reported as
WorkflowTestFixtureException.- Returns:
- action phase for arranging workflow state
-
when
ACTION when()Returns the action phase in its stimulus role.This method returns the same phase instance as
given(). The different name exists so tests can read naturally when they move from setup to the behavior under test. Callingwhen()does not reset the fixture or change the selected workflow state. Failures raised while driving the fixture from this phase are reported asWorkflowTestFixtureException.- Returns:
- action phase for triggering the behavior under test
-
then
ASSERT then()Returns the assertion phase.The returned phase shares the same workflow runtime and testing state as
given()andwhen(). Use it to assert executions, histories, steps, payload, and workflow state after one or more action-phase operations. Failures raised from this phase are reported asAssertionErrors.- Returns:
- assertion phase for verifying workflow behavior
-