whenRejected

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

Hands the rejection of command with code and message to the saga's @OnRejected handler of it, as the runtime does for a command a handler derived and its target refused. command is one this specification derived (ProcessorExpectations.commands), so the rejection goes back to the execution that derived it; commandType is its full type name (commandTypeOf by default). expect checks the compensating commands. When the saga has no handler of that rejection, or command is one a receipt handler derived (a compensation, which does not compensate itself), the runtime parks the aggregate at once, so expect checks ProcessorExpectations.expectParked.

code is a code the target may answer: one its context's contract declares, the generated <Context>Contract.<Aggregate>.Errors constant, or its local name, which the target's type qualifies; or a framework code (me.ahoo.wow.api.result.FrameworkCodes). Another code fails, listing the target's; when the target's contract is not on the test's class path, the code is not checked and a warning says so.


fun whenRejected(rejected: CommandReceipt.Rejected<*>, command: KClass<*>, expect: ProcessorExpectations.() -> Unit = {})

Hands rejected, the rejection of a command of command that the saga's handler named by its CommandReceipt.Rejected.executionId derived, to the saga's @OnRejected handler of it, as the runtime does: build it with rejectedReceipt. expect checks the compensating commands, or, when the saga has no handler of that rejection, the park (ProcessorExpectations.expectParked).