aggregateVerifier
Creates a GivenStage for testing an aggregate using the command class as the aggregate type.
This extension function on Class
Example:
Cart::class.java.aggregateVerifier<Cart, CartState>()
.given()
.whenCommand(AddCartItem(productId = "item1", quantity = 1))
.expectEventType(CartItemAdded::class)
.expectState { items.assert().hasSize(1) }
.verify()Return
a GivenStage instance ready for chaining test expectations
Parameters
the type of the command aggregate class
the type of the state aggregate
the unique identifier for the aggregate instance, defaults to a generated global ID
the tenant identifier for multi-tenant scenarios, defaults to DEFAULT_TENANT_ID
factory for creating state aggregate instances, defaults to ConstructorStateAggregateFactory
the event store implementation for event sourcing, defaults to InMemoryEventStore for isolated testing
container for dependency injection, defaults to SimpleServiceProvider
Throws
if aggregate metadata cannot be resolved from the class annotations
Creates a GivenStage for testing an aggregate with explicit command and state types.
This static method provides an alternative way to initialize aggregate testing when you need to specify both command and state aggregate types explicitly. It internally delegates to the extension function on the command aggregate type.
Example:
aggregateVerifier(Cart::class.java, CartState::class.java)
.given(CartItemAdded(...))
.whenCommand(RemoveCartItem(productIds = setOf("item1")))
.expectEventType(CartItemRemoved::class)
.expectState { items.assert().isEmpty() }
.verify()Return
a GivenStage instance ready for chaining test expectations
Parameters
the type of the command aggregate
the type of the state aggregate
the Class representing the command aggregate type
the Class representing the state aggregate type (used for type safety)
the unique identifier for the aggregate instance, defaults to a generated global ID
the tenant identifier for multi-tenant scenarios, defaults to DEFAULT_TENANT_ID
factory for creating state aggregate instances, defaults to ConstructorStateAggregateFactory
the event store implementation for event sourcing, defaults to InMemoryEventStore for isolated testing
container for dependency injection, defaults to SimpleServiceProvider
Throws
if aggregate metadata cannot be resolved from the command class