WhenStage

Represents the "when" stage in stateless saga testing.

This interface provides methods to configure the event that triggers the saga and set up expectations for the resulting commands. The typical flow is:

  1. Configure the triggering event

  2. Set expectations on the generated commands

Parameters

T

The type of the saga being tested.

Functions

Link copied to clipboard
abstract fun functionFilter(filter: (MessageFunction<*, *, *>) -> Boolean): WhenStage<T>

Sets a filter for message functions to be considered during testing.

Link copied to clipboard
open fun functionName(functionName: String): WhenStage<T>

Filters message functions by name.

Link copied to clipboard
abstract fun inject(inject: ServiceProvider.() -> Unit): WhenStage<T>

Injects services into the test context using the provided configuration block.

open fun <SERVICE : Any> inject(service: SERVICE, serviceName: String = service.javaClass.toName(), serviceType: KType = service.javaClass.kotlin.defaultType): WhenStage<T>

Injects a service instance into the test context.

Link copied to clipboard
open fun when(event: Any): ExpectStage<T>

Triggers saga processing with a domain event.

open fun when(event: Any, state: Any?, ownerId: String = OwnerId.Companion.DEFAULT_OWNER_ID): ExpectStage<T>

Triggers saga processing with a domain event and optional state.

Link copied to clipboard
abstract fun whenEvent(event: Any, state: Any? = null, ownerId: String = OwnerId.Companion.DEFAULT_OWNER_ID): ExpectStage<T>

Triggers saga processing with a domain event and optional parameters.