Interface AxonTestPhase.When

Enclosing interface:
AxonTestPhase

public static interface AxonTestPhase.When
Interface describing the operations available in the When phase of the test fixture execution. This phase is used to execute the actual action being tested, typically a command.

Each operation in the phase (such as dispatching a command) is executed in its own separate Unit of Work which is committed immediately after execution. This allows for building up the initial state incrementally with each operation being processed independently.

  • Method Details

    • command

      default AxonTestPhase.When.Command command(@Nonnull Object payload)
      Dispatches the given command to the appropriate command handler and records all activity for result validation. The command will be dispatched with empty metadata.

      The payload parameter accepts either a command payload object or a CommandMessage. If a CommandMessage is provided, it will be used directly.

      Parameters:
      payload - The command payload or CommandMessage to dispatch.
      Returns:
      The current When instance, for fluent interfacing.
    • command

      default AxonTestPhase.When.Command command(@Nonnull Object payload, @Nonnull Map<String,String> metadata)
      Dispatches the given command with the provided metadata to the appropriate command handler and records all activity for result validation.

      The payload parameter accepts either a command payload object or a CommandMessage. If a CommandMessage is provided, the given metadata will be merged with the message's existing metadata using CommandMessage.andMetadata(Metadata).

      Parameters:
      payload - The command payload or CommandMessage to dispatch.
      metadata - The metadata to attach to the command (merged if payload is a CommandMessage).
      Returns:
      The current When instance, for fluent interfacing.
    • command

      AxonTestPhase.When.Command command(@Nonnull Object payload, @Nonnull Metadata metadata)
      Dispatches the given command with the provided metadata to the appropriate command handler and records all activity for result validation.

      The payload parameter accepts either a command payload object or a CommandMessage. If a CommandMessage is provided, the given metadata will be merged with the message's existing metadata using CommandMessage.andMetadata(Metadata).

      Parameters:
      payload - The command payload or CommandMessage to dispatch.
      metadata - The metadata to attach to the command (merged if payload is a CommandMessage).
      Returns:
      The current When instance, for fluent interfacing.
    • event

      default AxonTestPhase.When.Event event(@Nonnull Object payload)
      Publishes the given event to the appropriate event handler and records all activity for result validation. The event will be published with empty metadata.

      The payload parameter accepts either an event payload object or an EventMessage. If an EventMessage is provided, it will be used directly.

      Parameters:
      payload - The event payload or EventMessage to publish.
      Returns:
      The current When instance, for fluent interfacing.
    • event

      default AxonTestPhase.When.Event event(@Nonnull Object payload, @Nonnull Map<String,String> metadata)
      Publishes the given event with the provided metadata to the appropriate event handler and records all activity for result validation.

      The payload parameter accepts either an event payload object or an EventMessage. If an EventMessage is provided, the given metadata will be merged with the message's existing metadata using EventMessage.andMetadata(Metadata).

      Parameters:
      payload - The event payload or EventMessage to publish.
      metadata - The metadata to attach to the event (merged if payload is an EventMessage).
      Returns:
      The current When instance, for fluent interfacing.
    • event

      AxonTestPhase.When.Event event(@Nonnull Object payload, @Nonnull Metadata metadata)
      Publishes the given event with the provided metadata to the appropriate event handler and records all activity for result validation.

      The payload parameter accepts either an event payload object or an EventMessage. If an EventMessage is provided, the given metadata will be merged with the message's existing metadata using EventMessage.andMetadata(Metadata).

      Parameters:
      payload - The event payload or EventMessage to publish.
      metadata - The metadata to attach to the event (merged if payload is an EventMessage).
      Returns:
      The current When instance, for fluent interfacing.
    • events

      AxonTestPhase.When.Event events(@Nonnull EventMessage... messages)
      Publishes the given Event Messages to the appropriate event handlers and records all activity for result validation.
      Parameters:
      messages - The event messages to publish.
      Returns:
      The current When instance, for fluent interfacing.
    • events

      default AxonTestPhase.When.Event events(@Nonnull Object... events)
      Publishes the given events to the appropriate event handlers and records all activity for result validation. The events will be published with empty metadata.
      Parameters:
      events - The events (payloads or EventMessages) to publish.
      Returns:
      The current When instance, for fluent interfacing.
    • events

      AxonTestPhase.When.Event events(@Nonnull List<?> events)
      Publishes the given events to the appropriate event handlers and records all activity for result validation.
      Parameters:
      events - The list of events to publish.
      Returns:
      The current When instance, for fluent interfacing.
    • nothing

      Transitions to the Then phase to validate the results of the test. It skips the When phase.
      Returns:
      A AxonTestPhase.Then.Nothing instance that allows validating the test results.