Interface AxonTestPhase.Given

Enclosing interface:
AxonTestPhase

public static interface AxonTestPhase.Given
Interface describing the operations available in the Given phase of the test fixture execution. This phase is used to define the initial state of the system before executing the test action.
  • Method Details

    • noPriorActivity

      AxonTestPhase.Given noPriorActivity()
      Indicates that no relevant activities like commands or events have occurred in the past. This also means that no previous state is present in the system.
      Returns:
      The current Given instance, for fluent interfacing
    • event

      default AxonTestPhase.Given event(@Nonnull Object payload)
      Configures a single event as part of the "given" state. This 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 Given instance, for fluent interfacing.
    • event

      default AxonTestPhase.Given event(@Nonnull Object payload, @Nonnull Map<String,String> metadata)
      Configures a single event with the given metadata as part of the "given" state. This event will be published.

      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 Given instance, for fluent interfacing.
    • event

      AxonTestPhase.Given event(@Nonnull Object payload, @Nonnull Metadata metadata)
      Configures a single event with the given metadata as part of the "given" state. This event will be published.

      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 Given instance, for fluent interfacing.
    • events

      AxonTestPhase.Given events(@Nonnull EventMessage... messages)
      Configures the given messages as events in the "given" state. These events will be published in the order they are provided.

      All the messages will be processed within a single Unit of Work, meaning their processing won't be affected by changes made by earlier messages passed to this method.

      Parameters:
      messages - The event messages to publish.
      Returns:
      The current Given instance, for fluent interfacing.
    • events

      default AxonTestPhase.Given events(@Nonnull Object... events)
      Configures the given events as events in the "given" state. These events will be published in the order they are provided.

      All the messages will be processed within a single Unit of Work, meaning their processing won't be affected by changes made by earlier messages passed to this method.

      Parameters:
      events - The lists of events to publish.
      Returns:
      The current Given instance, for fluent interfacing.
    • events

      AxonTestPhase.Given events(@Nonnull List<?> events)
      Configures the given events as events in the "given" state. These events will be published in the order they are provided.

      All the messages will be processed within a single Unit of Work, meaning their processing won't be affected by changes made by earlier messages passed to this method.

      Parameters:
      events - The lists of events to publish.
      Returns:
      The current Given instance, for fluent interfacing.
    • command

      default AxonTestPhase.Given command(@Nonnull Object payload)
      Configures a single command as part of the "given" state. This command will be dispatched to corresponding command handlers 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 Given instance, for fluent interfacing.
    • command

      default AxonTestPhase.Given command(@Nonnull Object payload, @Nonnull Map<String,String> metadata)
      Configures a single command with the given metadata as part of the "given" state. This command will be dispatched to corresponding command handlers.

      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 Given instance, for fluent interfacing.
    • command

      AxonTestPhase.Given command(@Nonnull Object payload, @Nonnull Metadata metadata)
      Configures a single command with the given metadata as part of the "given" state. This command will be dispatched to corresponding command handlers.

      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 Given instance, for fluent interfacing.
    • commands

      AxonTestPhase.Given commands(@Nonnull CommandMessage... messages)
      Configures the given messages as commands in the "given" state.

      Each message will be processed in a dedicated Unit of Work, meaning that the processing of a message will be affected by the state changes made by the processing of previous messages. This behavior is in contrast to the events(org.axonframework.messaging.eventhandling.EventMessage...) method, where all messages are processed within a single Unit of Work.

      Parameters:
      messages - The command messages to dispatch.
      Returns:
      The current Given instance, for fluent interfacing.
    • commands

      default AxonTestPhase.Given commands(@Nonnull Object... commands)
      Configures the given commands as commands in the "given" state. These commands will be dispatched in the order they are provided in the same Unit of Work.

      Each message will be processed in a dedicated Unit of Work, meaning that the processing of a message will be affected by the state changes made by the processing of previous messages. This behavior is in contrast to the events(org.axonframework.messaging.eventhandling.EventMessage...) method, where all messages are processed within a single Unit of Work.

      Parameters:
      commands - The command messages to dispatch.
      Returns:
      The current Given instance, for fluent interfacing.
    • commands

      AxonTestPhase.Given commands(@Nonnull List<?> commands)
      Configures the given commands as commands in the "given" state. These commands will be dispatched in the order they are provided in the same Unit of Work.

      Each message will be processed in a dedicated Unit of Work, meaning that the processing of a message will be affected by the state changes made by the processing of previous messages. This behavior is in contrast to the events(org.axonframework.messaging.eventhandling.EventMessage...) method, where all messages are processed within a single Unit of Work.

      Parameters:
      commands - The command messages to dispatch.
      Returns:
      The current Given instance, for fluent interfacing.
    • execute

      default AxonTestPhase.Given execute(@Nonnull Consumer<Configuration> consumer)
      Allows running custom setup steps (other than executing messages) on any component retrievable from the Configuration.
      Parameters:
      consumer - The consumer to execute on the configuration.
      Returns:
      The current Given instance, for fluent interfacing.
    • executeAsync

      AxonTestPhase.Given executeAsync(@Nonnull Function<Configuration,CompletableFuture<?>> function)
      Allows running custom setup steps (other than executing messages) on any component retrievable from the Configuration.
      Parameters:
      function - The function to execute on the configuration.
      Returns:
      The current Given instance, for fluent interfacing.
    • when

      Transitions to the When phase to execute the test action.
      Returns:
      A AxonTestPhase.When instance that allows executing the test.
    • then

      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.