VerifiedStage

Defines the stage after command execution and expectation verification in aggregate testing.

This interface extends both GivenStage and AggregateExpecter, allowing for additional command executions or further expectations on the verified results.

Parameters

S

the type of the aggregate state

Properties

Link copied to clipboard

The state aggregate after command execution.

Link copied to clipboard
open val stateRoot: S

The root state object from the aggregate.

Link copied to clipboard

The verified result of the command execution.

Functions

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

Applies additional expectations to the verified result.

Link copied to clipboard

Expects that an error occurred during command execution.

open fun <E : Throwable> expectError(expected: Consumer<E>): VerifiedStage<S>

Expects a specific error with detailed validation using a Consumer.

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

Expects a specific error with detailed validation.

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

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

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

Expects an error of a specific type.

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

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

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

Expects specific conditions on the first domain event in the stream.

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

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

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

Expects specific conditions on the body of the first domain event.

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

Expects a specific number of events in the domain event stream.

Link copied to clipboard

Expects specific conditions on an event iterator using a Consumer.

Expects specific conditions on an event iterator for the domain event stream.

Link copied to clipboard

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

Expects specific conditions on the domain event stream.

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

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

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

Expects events of specific types in the exact order provided.

Link copied to clipboard

Expects that no error occurred during command execution.

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

Expects specific conditions on the aggregate state object using a Consumer.

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

Expects specific conditions on the aggregate state object.

Link copied to clipboard

Expects specific conditions on the aggregate state and metadata.

Link copied to clipboard
abstract fun fork(verifyError: Boolean = false): VerifiedStage<S>

Creates a completely independent test branch context from the current state.

open fun fork(verifyError: Boolean = false, handle: VerifiedStage<S>.() -> Unit): VerifiedStage<S>

Creates a test branch and executes a handler function on it.

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, serviceType: KType): 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
abstract fun then(verifyError: Boolean = false): VerifiedStage<S>

Continues to the next stage, optionally verifying error conditions.

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.