Interface AxonTestPhase.Then.Message<T extends AxonTestPhase.Then.Message<T>>

Type Parameters:
T - the type of the current Then instance, for fluent interfacing; the type depends on the operation which was triggered in the When phase
All Superinterfaces:
AxonTestPhase.Then.MessageAssertions<T>
All Known Subinterfaces:
AxonTestPhase.Then.Command, AxonTestPhase.Then.Event, AxonTestPhase.Then.Nothing
Enclosing interface:
AxonTestPhase.Then

public static interface AxonTestPhase.Then.Message<T extends AxonTestPhase.Then.Message<T>> extends AxonTestPhase.Then.MessageAssertions<T>
Interface describing the operations available in the Then phase of the test fixture execution. It's possible to assert messages produced while handling inputs in the When phase.

Message assertions exclude commands and events supplied directly through the current when-phase. Messages produced while handling those inputs remain visible, including messages with equal payloads, because inputs are identified by their message identifier.

  • Method Details

    • await

      default T await(Consumer<T> assertion)
      Waits until the given assertion passes or the default timeout of 5 seconds is reached. The assertion receives the current Then instance, allowing to invoke any of its assertion methods.
      Parameters:
      assertion - The assertion to wait for. The assertion will be invoked on the current Then instance.
      Returns:
      The current Then instance, for fluent interfacing.
    • await

      T await(Consumer<T> assertion, Duration timeout)
      Waits until the given assertion passes or the given timeout is reached. The assertion receives the current Then instance, allowing to invoke any of its assertion methods.
      Parameters:
      assertion - The assertion to wait for. The assertion will be invoked on the current Then instance.
      timeout - The maximum time to wait for the assertion to pass. If the timeout is reached, the assertion.
      Returns:
      The current Then instance, for fluent interfacing.
    • and

      Returns to the setup phase to continue with additional test scenarios. This allows for chaining multiple test scenarios within a single test method. The same configuration from the original fixture is reused, so all components are shared among the invocations.

      Example usage:

       
       fixture.given()
              .event(new AccountCreatedEvent("account-1"))
              .when()
              .command(new WithdrawMoneyCommand("account-1", 50.00))
              .then()
              .events(new MoneyWithdrawnEvent("account-1", 50.00))
              .success()
              .and()  // Return to setup phase with same configuration
              .given() // Start a new scenario
              .event(new AccountCreatedEvent("account-2"))
              .when()
              .command(new WithdrawMoneyCommand("account-2", 30.00))
              .then()
              .events(new MoneyWithdrawnEvent("account-2", 30.00));
       
       
      Returns:
      A AxonTestPhase.Setup instance that allows configuring a new test scenario.
    • stop

      default void stop()
      Stops the fixture, releasing any active resources, like registered handlers or pending event processing tasks.