OperationMockState

@Serializable
sealed interface OperationMockState

Represents the mocking state for a single API operation.

Each operation is either passing traffic through to the actual network, returning a specific mock response, or simulating a network failure. The variants are represented as distinct types, eliminating any ambiguous state combinations that existed in a previous boolean-flag approach.

Variants

VariantBehaviordisplayName
NetworkAll requests pass through to the actual network (default)"Network"
MockRequests return the selected response variant"$statusCode - $exampleName"
FailureRequests fail with the selected FailureKinde.g. "Timeout"
SequenceRequests advance through an ordered list, sticking on the laste.g. "200 - default (2/3)"

See also

Inheritors

Types

Link copied to clipboard
@Serializable
@SerialName(value = "failure")
data class Failure(val kind: FailureKind) : OperationMockState

The operation will deterministically simulate a network failure instead of returning any response — every request to it fails the same way, the same way Mock always serves the same response.

Link copied to clipboard
@Serializable
@SerialName(value = "mock")
data class Mock(val statusCode: Int, val mediaType: String, val exampleName: String) : OperationMockState

The operation will return the response variant identified by (statusCode, mediaType, exampleName).

Link copied to clipboard
@Serializable
@SerialName(value = "network")
data object Network : OperationMockState

The operation will pass all requests through to the actual network.

Link copied to clipboard
@Serializable
@SerialName(value = "sequence")
data class Sequence(val responses: List<OperationMockState.Mock>, val currentIndex: Int = 0) : OperationMockState

The operation advances through responses in order on each successive matched request, sticking on the last response once exhausted rather than looping back to the start or falling through to the real network — the least surprising default, and the one that matches how a real async-completion flow behaves (the terminal state is stable).

Properties

Link copied to clipboard
abstract val displayName: String

A human-readable display name for this state, suitable for use in UI labels.