DefaultExpectDsl

Default implementation of the ExpectDsl interface for defining aggregate test expectations.

This class provides methods to specify various expectations about the outcome of aggregate operations, including state changes, events, and error conditions. It wraps an ExpectStage and converts expectations into JUnit 5 dynamic tests that can be executed dynamically.

Parameters

S

the state type of the aggregate being tested

Constructors

Link copied to clipboard
constructor(context: AggregateDslContext<S>, delegate: ExpectStage<S>)

Properties

Link copied to clipboard
open override val context: AggregateDslContext<S>

The aggregate DSL context for managing shared test state.

Link copied to clipboard
open override val delegate: ExpectStage<S>

the underlying ExpectStage that performs the actual verification logic

Link copied to clipboard
open override val dynamicNodes: MutableList<DynamicNode>

A mutable list of dynamic test nodes that can be modified by subclasses.

Functions

Link copied to clipboard
open override fun expect(expected: ExpectedResult<S>.() -> Unit): ExpectDsl<S>

Defines expectations for the complete test result.

Link copied to clipboard
open fun <E : Throwable> expectError(expected: Consumer<E>): ExpectDsl<S>

Expects a specific error with detailed validation using a Consumer.

open override fun expectError(): ExpectDsl<S>

Defines expectation that an error occurred during command processing.

open override fun <E : Throwable> expectError(expected: E.() -> Unit): ExpectDsl<S>

Defines expectations for a specific error that occurred.

Link copied to clipboard
open fun <E : Throwable> expectErrorType(expected: Class<E>): ExpectDsl<S>

Expects an error of a specific type (Java-friendly overload).

open override fun <E : Throwable> expectErrorType(expected: KClass<E>): ExpectDsl<S>

Defines expectation for the type of error that occurred.

Link copied to clipboard
open fun <E : Any> expectEvent(expected: Consumer<DomainEvent<E>>): ExpectDsl<S>

Expects specific conditions on the first domain event using a Consumer.

open override fun <E : Any> expectEvent(expected: DomainEvent<E>.() -> Unit): ExpectDsl<S>

Defines expectations for a specific domain event.

Link copied to clipboard
open fun <E : Any> expectEventBody(expected: Consumer<E>): ExpectDsl<S>

Expects specific conditions on the body of the first domain event using a Consumer.

open override fun <E : Any> expectEventBody(expected: E.() -> Unit): ExpectDsl<S>

Defines expectations for a domain event's body content.

Link copied to clipboard
open override fun expectEventCount(expected: Int): ExpectDsl<S>

Defines expectations for the number of domain events produced.

Link copied to clipboard

Expects specific conditions on an event iterator using a Consumer.

open override fun expectEventIterator(expected: EventIterator.() -> Unit): ExpectDsl<S>

Defines expectations for iterating through domain events.

Link copied to clipboard

Expects specific conditions on the domain event stream using a Consumer.

open override fun expectEventStream(expected: DomainEventStream.() -> Unit): ExpectDsl<S>

Defines expectations for the complete domain event stream.

Link copied to clipboard
open fun expectEventType(vararg expected: Class<*>): ExpectDsl<S>

Expects events of specific types in the exact order provided (Java-friendly overload).

open override fun expectEventType(vararg expected: KClass<*>): ExpectDsl<S>

Defines expectations for the types of domain events produced.

Link copied to clipboard
open override fun expectNoError(): ExpectDsl<S>

Defines expectation that no error occurred during command processing.

Link copied to clipboard
open override fun expectState(expected: Consumer<S>): ExpectDsl<S>

Defines expectations for the aggregate's state using a Consumer.

open override fun expectState(expected: S.() -> Unit): ExpectDsl<S>

Defines expectations for the aggregate's state object.

Link copied to clipboard
open override fun expectStateAggregate(expected: StateAggregate<S>.() -> Unit): ExpectDsl<S>

Defines expectations for the aggregate's complete state including metadata.

Link copied to clipboard
open override fun fork(name: String, verifyError: Boolean, block: ForkedVerifiedStageDsl<S>.() -> Unit)

Creates a forked verification path for testing alternative scenarios.

Link copied to clipboard
open override fun ref(ref: String)

Marks the current ExpectStage with a reference name for later branching.