Package-level declarations

Core server, stub registration, and configuration.

Core server, stub registration, and configuration.

Types

Link copied to clipboard
Link copied to clipboard
class BuildingStep<P : Any>

Defines the building step for associating an inbound RequestSpecification with its corresponding response definition. This class is part of a fluent API used to define mappings between request specifications and their respective responses.

Link copied to clipboard

A Java-friendly wrapper around BuildingStep that exposes respondsWith and respondsWithStream as instance methods accepting Consumer instead of Kotlin suspend lambdas.

Link copied to clipboard

Controls which requests are recorded in the dev.mokksy.mokksy.request.RequestJournal.

Link copied to clipboard
typealias Mokksy = MokksyServer

A typealias for MokksyServer, allowing the use of Mokksy as an alternative, more concise name for referencing the MokksyServer class.

Link copied to clipboard
open class MokksyServer @JvmOverloads constructor(host: String = DEFAULT_HOST, port: Int = 0, configuration: ServerConfiguration, configurer: ApplicationConfigurer = {})

An embedded mock HTTP server for testing. Registers stubs for any HTTP method and verifies request expectations after the test.

Link copied to clipboard

Java-friendly wrapper around MokksyServer that provides a fully instance-method-based API.

Link copied to clipboard
data class ServerConfiguration @JvmOverloads constructor(val verbose: Boolean = false, val name: String? = "Mokksy", val journalMode: JournalMode = JournalMode.LEAN, val contentNegotiationConfigurer: (ContentNegotiationConfig) -> Unit = ::configureContentNegotiation)

Configuration for a MokksyServer instance.

Link copied to clipboard
data class StubConfiguration @JvmOverloads constructor(val name: String? = null, val removeAfterMatch: Boolean = false, val verbose: Boolean = false)

Configuration for a stub's lifecycle and logging behaviour.

Functions

Link copied to clipboard
fun <P : Any, T : Any> BuildingStep<P>.respondsWith(responseType: Class<T>, configurer: Consumer<ResponseDefinitionBuilder<P, T>>)

Java-friendly overload for BuildingStep.respondsWith.

Link copied to clipboard

Java-friendly overload for BuildingStep.respondsWithStream.

Link copied to clipboard
fun Mokksy.shutdown(gracePeriodMillis: Long = 500, timeoutMillis: Long = 1000)

Stops the Mokksy server, blocking until shutdown is complete.

fun Mokksy.shutdown(gracePeriodMillis: Long = 500, timeoutMillis: Long = 1000, dispatcher: CoroutineDispatcher)

Stops the Mokksy server on the given dispatcher, blocking until shutdown is complete.

Link copied to clipboard

Starts the Mokksy server and blocks until the port is bound and ready to accept requests.

Starts the Mokksy server on the given dispatcher, blocking until the port is bound.