fork

fun fork(name: String = "", block: AggregateSpec<S>.() -> Unit)

Runs block on a copy of the aggregate as this command left it, as AggregateSpec.fork does, so that the scenarios after a command branch from its checks, as 9.x's VerifiedStage.fork did:

whenCommand(PlaceOrder(...)) {
expectEventTypes(OrderPlaced::class)
fork("paid") { whenCommand(PayOrder(...)) { expectEventTypes(OrderPaid::class) } }
fork("cancelled") { whenCommand(CancelOrder(...)) { expectEventTypes(OrderCancelled::class) } }
}

A check that fails before it ends the block, so the forks after it do not run.


fun fork(name: String = "", model: AggregateModel<S>, block: AggregateSpec<S>.() -> Unit)

Runs block on a copy of the aggregate as this command left it, as fork does, with model deciding from there on: the same aggregate built with other services (AggregateSpec.fork of a model).