Class SagaAssertions

java.lang.Object
org.axonframework.test.saga.SagaAssertions

@Internal public final class SagaAssertions extends Object
Assertions on the contents of the SagaStore of a running Configuration.

A Saga keeps its state in a SagaStore rather than in messages, so a test that only observes published events and dispatched commands cannot tell a Saga that ended from one that never started. These assertions close that gap. They are the one thing AxonTestFixture cannot express on its own, and are meant to be handed to its expect operation:


 fixture.given()
        .event(new OrderPlaced("order-1"))
        .when()
        .event(new OrderShipped("shipment-of-order-1"))
        .then()
        .commands(new ConfirmOrder("order-1"))
        .expect(SagaAssertions.activeSagas(1))
        .expect(SagaAssertions.associationWith(OrderSaga.class, "orderId", "order-1"));
 
The SagaStore is resolved from the Configuration as a component, so the configuration under test has to register one. SagaTestFixture does that itself and offers the same assertions under their Axon Framework 4 names.
Since:
5.4.0
Author:
Allard Buijze, Mateusz Nowak