GivenStage

Defines the stage for setting up test preconditions in aggregate testing.

This interface provides methods to configure the initial state of aggregates before command execution, including injecting services, setting owner IDs, and providing initial events or state.

Parameters

S

the type of the aggregate state

Inheritors

Functions

Link copied to clipboard
open fun given(vararg events: Any): WhenStage<S>

Sets up the aggregate by replaying the given domain events.

Link copied to clipboard
abstract fun givenEvent(vararg events: Any): WhenStage<S>
Link copied to clipboard
abstract fun givenOwnerId(ownerId: String): GivenStage<S>

Sets the owner ID for the aggregate in this test.

Link copied to clipboard
abstract fun givenState(state: StateAggregate<S>): WhenStage<S>
abstract fun givenState(state: S, version: Int): WhenStage<S>
Link copied to clipboard
open fun <SERVICE : Any> inject(service: SERVICE, serviceName: String = service.javaClass.toName(), serviceType: KType = service.javaClass.kotlin.defaultType): GivenStage<S>

Injects a service instance into the test context.

abstract fun inject(inject: ServiceProvider.() -> Unit): GivenStage<S>

Injects services into the test context using the provided configuration block.

Link copied to clipboard
fun <S : Any> GivenStage<S>.when(command: Any, header: Header = DefaultHeader.empty(), ownerId: String = OwnerId.DEFAULT_OWNER_ID): ExpectStage<S>

Alias for whenCommand, providing a more natural language interface.

Link copied to clipboard
fun <S : Any> GivenStage<S>.whenCommand(command: Any, header: Header = DefaultHeader.empty(), ownerId: String = OwnerId.DEFAULT_OWNER_ID): ExpectStage<S>

Extension function that allows executing a command directly from the Given stage.