GivenDsl

Defines the "Given" phase of aggregate testing where preconditions are established.

This interface provides methods to set up the initial state of an aggregate before executing commands. It supports various ways to initialize aggregate state including event replay, direct state setting, and dependency injection.

Parameters

S

the type of the aggregate state

Inheritors

Properties

Link copied to clipboard

The aggregate DSL context for managing shared test state.

Functions

Link copied to clipboard
abstract fun givenEvent(event: Any, block: WhenDsl<S>.() -> Unit)

Initializes the aggregate by replaying a single domain event.

abstract fun givenEvent(events: Array<out Any> = emptyArray(), block: WhenDsl<S>.() -> Unit)

Initializes the aggregate by replaying multiple domain events.

Link copied to clipboard
abstract fun givenOwnerId(ownerId: String)

Sets the owner ID for the aggregate in this test scenario.

Link copied to clipboard
abstract fun givenState(state: S, version: Int, block: WhenDsl<S>.() -> Unit)

Initializes the aggregate with a specific state and version.

Link copied to clipboard
abstract fun inject(inject: ServiceProvider.() -> Unit)

Injects services or dependencies into the test context.

Link copied to clipboard
abstract fun name(name: String)

Sets the name for this test element.

Link copied to clipboard
abstract fun whenCommand(command: Any, header: Header, ownerId: String, block: ExpectDsl<S>.() -> Unit)

Executes a command on the aggregate and validates the results.