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 stage
ASSERT - 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
  • Field Details

  • Constructor Details

    • GivenWhen

      public GivenWhen()
  • Method Details

    • when

      public SELF when()
      Returns the action phase to use.
      Returns:
      fixture to continue fluent invocations
    • then

      public ASSERT then()
      Returns the assert phase to use
      Returns:
      assert phase to continue fluent invocations
    • publishEvent

      public SELF publishEvent(Object event)
      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

      public SELF execute(String stepName)
      Releases an execute step by invoking the original workflow-defined action.
      Parameters:
      stepName - step name to release
      Returns:
      this phase for fluent chaining
    • execute

      public SELF execute(String stepName, PayloadProcessor payloadProcessor)
      Supplies a fake action for an execute step and waits until the step reaches a terminal state.
      Parameters:
      stepName - step name to release
      payloadProcessor - fake action to invoke instead of the workflow-defined action
      Returns:
      this phase for fluent chaining
    • executeReturning

      public SELF executeReturning(String stepName, Map<String,@Nullable Object> expectedPayload)
      Supplies a fake successful execute-step result and asserts that the step completes.
      Parameters:
      stepName - step name to release
      expectedPayload - payload returned by the fake step action
      Returns:
      this phase for fluent chaining
    • executeFailing

      public SELF executeFailing(String stepName, StepFailedException expectedFailure)
      Supplies a fake failing execute-step action and asserts that the step fails.
      Parameters:
      stepName - step name to release
      expectedFailure - failure thrown by the fake action
      Returns:
      this phase for fluent chaining
    • timePasses

      public SELF timePasses(Duration duration)
      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

      protected void initialize(WorkflowTestFixture<?,?> fixture, WorkflowTestDriver testDriver)
      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 fixture
      testDriver - shared workflow test driver
    • executionExists

      public SELF executionExists()
      Waits until any active workflow execution exists.
      Returns:
      this phase for fluent chaining
    • executionExists

      public SELF executionExists(Predicate<WorkflowExecution> predicate)
      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

      public SELF historyExists(Predicate<WorkflowHistory> predicate)
      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

      public SELF historyExists(String workflowId)
      Waits until a workflow history exists for the given workflow id.
      Parameters:
      workflowId - workflow id to find
      Returns:
      this phase for fluent chaining
    • historyExists

      public SELF historyExists(WorkflowStatus workflowStatus)
      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

      public SELF noExecution()
      Asserts that no active workflow execution is present.
      Returns:
      this phase for fluent chaining
    • noHistory

      public SELF 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.