TestSession

open class TestSession<F : Failure> @JvmOverloads constructor(script: TestSessionScript<F> = TestSessionScript.auto(Session.State.Succeeded), val id: UUID = UUID.randomUUID(), initialState: Session.State<F> = Pending) : Session<F>

A controllable Session test double.

State listeners are invoked on the calling thread, and the current state is delivered immediately when a listener is added. Use controller to drive state transitions directly or script transitions tied to Session.launch and Session.commit calls with TestSessionScript.

Inheritors

Constructors

Link copied to clipboard
constructor(script: TestSessionScript<F> = TestSessionScript.auto(Session.State.Succeeded), id: UUID = UUID.randomUUID(), initialState: Session.State<F> = Pending)

Properties

Link copied to clipboard

Returns the controller used to drive this session in tests.

Link copied to clipboard
open override val id: UUID
Link copied to clipboard
open override val isActive: Boolean
Link copied to clipboard
open override val isCancelled: Boolean
Link copied to clipboard
open override val isCompleted: Boolean
Link copied to clipboard

Returns the current state of this session.

Link copied to clipboard

Returns a snapshot of state transitions for this session.

Functions

Link copied to clipboard
Link copied to clipboard
open override fun cancel()
Link copied to clipboard
open override fun commit(): Boolean
Link copied to clipboard
open override fun launch(): Boolean
Link copied to clipboard
open override fun removeStateListener(listener: Session.StateListener<F>)
Link copied to clipboard
open fun reset(state: Session.State<F> = Pending, notifyListeners: Boolean = false)

Resets state and state history to the provided state.