Interface WorkflowEngineTestingState


public interface WorkflowEngineTestingState
Shared selection and assertion state for workflow fixture tests.

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:

  • WorkflowTestDriver discovers executions and history entries and updates the current selection
  • WorkflowEngineTestingState keeps that selection and exposes reusable assertions over the selected WorkflowState

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 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 failures
      stepName - first expected waiting step name
      stepNames - additional optional expected waiting step names
    • waitingIn

      default void waitingIn(String stepName, String... stepNames)
      Verifies that given steps are waiting in the workflow execution.
      Parameters:
      stepName - first expected waiting step name
      stepNames - 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 failures
      stepName - first expected passed step name
      stepNames - additional optional expected passed step names
    • stepsPassed

      default void stepsPassed(String stepName, String... stepNames)
      Verifies that given steps have passed.
      Parameters:
      stepName - first expected passed step name
      stepNames - 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 failures
      stepName - first expected step name
      stepNames - additional optional expected step names
    • hasSteps

      default void hasSteps(String stepName, String... stepNames)
      Verifies that given steps exist in the workflow state.
      Parameters:
      stepName - first expected step name
      stepNames - 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 failures
      stepName - first expected step name
      stepNames - additional optional expected step names
    • hasStepsInAnyOrder

      default void hasStepsInAnyOrder(String stepName, String... stepNames)
      Verifies that given steps exist in the workflow state in any order.
      Parameters:
      stepName - first expected step name
      stepNames - 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 failures
      stepName - first expected step name
      stepNames - additional optional expected step names
    • hasStepsInOrder

      default void hasStepsInOrder(String stepName, String... stepNames)
      Verifies that given steps exist in the workflow state in the given order.
      Parameters:
      stepName - first expected step name
      stepNames - additional optional expected step names
    • noStep

      void noStep(String stepName, String... stepNames)
      Verifies that given steps do not exist in the workflow state.
      Parameters:
      stepName - first expected step name
      stepNames - 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 failures
      predicate - 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 failures
      predicate - predicate for the workflow step
      Returns:
      the matching workflow step
    • stepMatches

      default WorkflowStep stepMatches(Predicate<WorkflowStep> predicate)
      Waits until a step satisfies the given predicate.
      Parameters:
      predicate - predicate for the workflow step
      Returns:
      the matching workflow step
    • step

      default WorkflowStep step(Predicate<WorkflowStep> predicate)
      Waits until a step satisfies the given predicate.
      Parameters:
      predicate - predicate for the workflow step
      Returns:
      the matching workflow step
    • stepExists

      default WorkflowStep stepExists()
      Waits until a workflow step exists.
      Returns:
      the first available workflow step
    • stepSatisfies

      void stepSatisfies(Consumer<WorkflowStep> stepConsumer)
      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 failures
      predicate - predicate for the workflow step
      stepConsumer - consumer to apply to the matching step
    • stepSatisfies

      default void stepSatisfies(Predicate<WorkflowStep> predicate, Consumer<WorkflowStep> stepConsumer)
      Applies a consumer to the first step matching the predicate.
      Parameters:
      predicate - predicate for the workflow step
      stepConsumer - 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 failures
      predicate - 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

      Map<String,@Nullable Object> payloadExists()
      Returns the workflow payload after asserting it exists.
      Returns:
      the workflow payload
    • payloadSatisfies

      void payloadSatisfies(Consumer<Map<String,@Nullable Object>> payloadConsumer)
      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 failures
      predicate - predicate for the workflow state
      Returns:
      the matching workflow state
    • workflowStateMatches

      default WorkflowState workflowStateMatches(Predicate<WorkflowState> predicate)
      Waits until the workflow state matches the given predicate.
      Parameters:
      predicate - predicate for the workflow state
      Returns:
      the matching workflow state
    • workflowStateExists

      default WorkflowState workflowStateExists()
      Returns the workflow state after asserting it exists.
      Returns:
      the workflow state
    • workflowStateSatisfies

      void workflowStateSatisfies(Consumer<WorkflowState> workflowStateConsumer)
      Applies a consumer to the workflow state.
      Parameters:
      workflowStateConsumer - consumer for the workflow state