ProcessorSpec
Calls the handlers of one processor of kind as the runtime would, one commit or receipt at a time.
Scenarios that share a prefix fork from it, at the current point or after a handling from inside its checks (ProcessorExpectations.fork): the fork starts on a copy of what the specification holds, the executions that derived each command, so a rejection or receipt in it goes back to the right handler, and how calls are answered. A processor keeps no state between handlings, so that is all a fork copies: the fakes a projection or reactor writes to are the test's own, shared by the forks.
Properties
Functions
Answers each synchronous call a saga's handler makes with what answer returns for its command, as the target's command gateway would: committedResult (the default, at version 1), rejectedResult, which the handler gets as a me.ahoo.wow.api.client.CommandRejectedException, or failedResult, a me.ahoo.wow.api.problem.WowProblemException; answer may also throw one, as a target that is down does.
Runs block on a copy of the specification as it is now, so that several scenarios share a prefix: what block does stays in the fork, and the specification goes on from where it was. A failure in the fork names it (name); in a tree of tests (sagaSpecTests) the fork is a container named by it. Nothing before the fork runs again.
The aggregate ref of model at the state and version its history leaves it in, as givenAggregate does.
The aggregate id of model, in tenantId, at the state and version its history leaves it in, one commit per event, in scope: the aggregate whose next commit whenEvent of events hands over. The model replays the history, so the state is the one the aggregate's own sourcing builds; a peer's view state the processor reads without its model is built by hand with stateEvent.
Serves the handlers' reads (context.queries) from queries, the read side of the test, as a node serves them (ContextQueries.of): a node's API (an engine over states the test gives) pins the tenant of the commit a handler handles as trusted code, reading the whole tenant; a fake (a stub, a mock) serves the reads QueryApi.of a caller of that tenant, the trusted ones NodeQueryApi.trusted. Without it, a handler that reads fails.
Hands committed, the success receipt of a command of command that the saga's handler named by its CommandReceipt.Committed.executionId derived, to the saga's @OnCommitted handler of it, as the runtime does: build it with committedReceipt. expect checks the commands the handler derives; it fails when the saga has no handler of that receipt.
Hands the success receipt of command to the saga's @OnCommitted handler of it, as the runtime does once a command a handler derived is committed, in the saga's context or another. command is one this specification derived (ProcessorExpectations.commands), so the receipt goes back to the execution that derived it. It was committed on the aggregate aggregateId (the target's, for a creation that named none) at version, duplicate when the target had already committed its request; commandType is its full type name (commandTypeOf by default). expect checks the commands the handler derives; it fails when the saga has no handler of that receipt.
Hands the commit of on (by default the only aggregate given) at version, one whenEvent handed over before later ones, to its handlers again, out of order: an older commit arriving after newer ones, as another partition's lag or a replay delivers it. A handler that keeps the newest version leaves what the later commits wrote.
Hands event to each handler that reads it, as its subscription would: those that name its aggregate type in aggregates, or that name none and take its state type (or StateEvent<*>), but a handler of one event type skips a commit without an event of it (ProcessorBinding.skips), as the runtime's does. A commit each of them skips is handled by none (ProcessorExpectations.expectHandledBy of no handler); one no handler reads fails, as a mistake of the test. handler names the only one to call instead, by its function name (onOrderCreated) or its subscription name (OrderSaga.onOrderCreated). expect checks what they did. An exception a handler throws fails the specification, unless expect checks it (ProcessorExpectations.expectError, ProcessorExpectations.expectRetried, ProcessorExpectations.expectParked).
Hands the commit of events on on after its history, the next version in the state they evolve it to, to each handler that reads it, as whenEvent of a StateEvent does. on is the aggregate givenAggregate gave, by default the only one; by is the class of the command that committed the events, which names the commit's command type as the model does (eshop-ordering.order.SubmitOrder), headers its request facts and operator its operator, as an aggregate's AggregateSpec.whenCommand names them.
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).
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.