aggregateVerifier
Creates a GivenStage for testing an aggregate using reified generic types.
This inline function provides a convenient way to create aggregate verifiers without explicitly specifying Class objects, leveraging Kotlin's reified generics for type-safe testing setup. Uses default configurations for event store and service provider.
Example:
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 reified type of the command aggregate
the reified 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
Throws
if aggregate metadata cannot be resolved from the command class
Creates a GivenStage for testing an aggregate with custom service provider using reified generics.
This inline function allows specifying a custom ServiceProvider for dependency injection while using default event store. Useful for testing aggregates with mocked dependencies.
Example:
val mockServiceProvider = SimpleServiceProvider().apply {
register("inventoryService", mockInventoryService)
}
aggregateVerifier<Order, OrderState>(serviceProvider = mockServiceProvider)
.inject(mockPricingService)
.given()
.whenCommand(CreateOrder(...))
.expectEventType(OrderCreated::class)
.verify()Return
a GivenStage instance ready for chaining test expectations
Parameters
the reified type of the command aggregate
the reified 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
the service provider instance for dependency injection
Throws
if aggregate metadata cannot be resolved from the command class
Creates a GivenStage for testing an aggregate with custom event store and service provider using reified generics.
This inline function provides full control over both event store and service provider configurations, enabling comprehensive testing scenarios including custom event stores for testing event sourcing behavior.
Example:
val customEventStore = InMemoryEventStore()
val mockServiceProvider = SimpleServiceProvider().apply {
register("paymentService", mockPaymentService)
}
aggregateVerifier<Order, OrderState>(
eventStore = customEventStore,
serviceProvider = mockServiceProvider
)
.given()
.whenCommand(PayOrder(...))
.expectEventType(OrderPaid::class)
.expectState { status.assert().isEqualTo(OrderStatus.PAID) }
.verify()Return
a GivenStage instance ready for chaining test expectations
Parameters
the reified type of the command aggregate
the reified 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
the event store implementation, defaults to InMemoryEventStore
the service provider for dependency injection, defaults to SimpleServiceProvider
Throws
if aggregate metadata cannot be resolved from the command class