ProcessorExpectations

The checks of one handling by a ProcessorSpec: the handlers that were called (handled), the commands they derived (commands), among them the schedules they set or cancelled (schedules), or what one of them threw (expectError). The steps that follow a saga's handling go on from its checks: the rejection (whenRejected) or the receipt (whenCommitted) of a command it derived, in place or in a fork.

Properties

Link copied to clipboard
val calls: List<Command<*>>

The commands the handlers called synchronously, in order, each answered by ProcessorSpec.answerCalls; those of a handling that threw are not listed.

Link copied to clipboard

The commands the handlers derived, in order, but the schedules they set or cancelled (schedules).

Link copied to clipboard

What a handler threw; null when they all returned.

Link copied to clipboard

The handlers called, by subscription name (processor.function), in order.

Link copied to clipboard

The schedules the handlers set or cancelled: their derived system commands wow.schedule.Set and wow.schedule.Cancel, in order.

Functions

Link copied to clipboard
fun expectCalls(vararg bodies: Any)

The handlers called commands of exactly these bodies synchronously, in order, field by field as Wow writes them to JSON: a mismatch lists each difference by its path.

Link copied to clipboard
inline fun <reified C : Any> expectCommand(noinline check: C.() -> Unit = {}): C

The handlers derived exactly one command, a C, whose body check checks, as an aggregate's Expectations.expectEvent checks its event: that body.

fun expectCommand(body: Any, to: AggregateRef? = null): Command<*>

The handlers derived exactly one command, of body, to to when given, as expectCommands compares them: that command.

fun <C : Any> expectCommand(type: KClass<C>, check: C.() -> Unit = {}): C

The handlers derived exactly one command, of type, whose body check checks: that body.

Link copied to clipboard

The handlers derived exactly count commands, as an aggregate's expectEventCount counts its events.

Link copied to clipboard
inline fun <reified C : Any> expectCommandEnvelope(noinline check: Command<C>.() -> Unit = {}): Command<C>

The handlers derived exactly one command, a C, which check checks with its envelope: the aggregate it goes to, its ids, scope, request facts and operator beside its body (Command.body), as an aggregate's Expectations.expectEventEnvelope checks its event's.

fun <C : Any> expectCommandEnvelope(type: KClass<C>, check: Command<C>.() -> Unit = {}): Command<C>

The handlers derived exactly one command, of type, which check checks with its envelope.

Link copied to clipboard
fun expectCommands(vararg bodies: Any)

The handlers derived commands of exactly these bodies, in order, field by field as Wow writes them to JSON: a mismatch lists each difference by its path, [0].quantity: expected 3, was 2.

fun expectCommands(vararg commands: Pair<AggregateRef, Any>)

The handlers derived exactly these commands, each a body to the aggregate it goes to (stock to ReserveStock(…)), in order, as expectCommands of bodies compares them.

Link copied to clipboard
fun expectCommandTypes(vararg types: KClass<*>)

The handlers derived commands of exactly these types, in order.

Link copied to clipboard

A saga's handling of the same commit, or rejection, again, with a fresh context as the runtime gives a retry, derives the same commands (ids and request ids included), the schedules among them, and calls the same ones: the targets decide them once. A projection's or a reactor's handling would run its side effects again, so it has no such check.

Link copied to clipboard
inline fun <reified T : Throwable> expectError(noinline check: T.() -> Unit = {}): T

A handler threw a T, which check checks.

fun <T : Throwable> expectError(type: KClass<T>, check: T.() -> Unit = {}): T

A handler threw a type, which check checks.

Link copied to clipboard
fun expectHandledBy(vararg functions: String)

The handlers called are exactly functions, by function name or subscription name, in order.

Link copied to clipboard

The handlers called no command synchronously.

Link copied to clipboard

The handlers derived no command.

Link copied to clipboard

No handler threw.

Link copied to clipboard

The handlers changed no schedule.

Link copied to clipboard
fun expectParked(attempt: Int = 1): Throwable

The handling failed, and the runtime parks it after this attempt, the first by default, for its parked retries and an operator, as parking reads what it threw.

Link copied to clipboard
fun expectRetried(attempt: Int = 1): Throwable

The handling failed, and the runtime retries it after this attempt, the first by default, as parking reads what it threw. The backoff between the attempts is the runtime's. A handling that ran longer than its @Retry(timeout) was cancelled, and threw a me.ahoo.wow.kernel.HandlerTimeoutException.

Link copied to clipboard
fun expectScheduleCancelled(key: String, target: AggregateRef? = null)

The handlers cancelled the schedule key, of target when given.

Link copied to clipboard
fun expectScheduled(key: String, command: Any, rule: ScheduleRule? = null, target: AggregateRef? = null)

The handlers scheduled command under key: they derived wow.schedule.Set to target when given, which schedules command as rule says when it is given.

Link copied to clipboard
fun fork(name: String = "", block: ProcessorSpec.() -> Unit)

Runs block on a copy of the specification as this handling left it, as ProcessorSpec.fork does: the scenarios after a handling branch from its checks, a rejection of the command it derived in one fork and its receipt in another, say. A check that fails before it ends the block, so the forks after it do not run.

Link copied to clipboard
fun whenCommitted(command: Command<*>, version: Int = 1, aggregateId: String = command.ref.id, duplicate: Boolean = false, commandType: String = commandTypeOf(command), expect: ProcessorExpectations.() -> Unit = {})

Hands the success receipt of command, one this handling derived, to the saga's @OnCommitted handler of it, as ProcessorSpec.whenCommitted does: the specification goes on from this handling.

Link copied to clipboard
fun whenRejected(command: Command<*>, code: String, message: String = code, commandType: String = commandTypeOf(command), expect: ProcessorExpectations.() -> Unit = {})

Hands the rejection of command, one this handling derived, to the saga's @OnRejected handler of it, as ProcessorSpec.whenRejected does: the specification goes on from this handling.