whenCommand

abstract fun whenCommand(command: Any, header: Header = DefaultHeader.empty(), ownerId: String = OwnerId.DEFAULT_OWNER_ID, block: ExpectDsl<S>.() -> Unit)

Executes a command on the aggregate and validates the results.

This method processes the specified command through the aggregate's command handling logic and provides an ExpectDsl context for defining assertions on the outcome.

Parameters

command

the command object to execute on the aggregate

header

optional command header for additional context (defaults to empty)

ownerId

optional owner ID override for the command execution

block

the expectation block that defines assertions on command results