respondsWith

fun <P : Any, T : Any> BuildingStep<P>.respondsWith(responseType: Class<T>, configurer: Consumer<ResponseDefinitionBuilder<P, T>>)(source)

Java-friendly overload for BuildingStep.respondsWith.

Accepts a Class and a Consumer in place of a Kotlin suspend lambda.

Prefer dev.mokksy.Mokksy, which returns JavaBuildingStep and allows fluent chaining:

mokksy.get(spec -> spec.path("/ping"))
.respondsWith(builder -> builder.body("Pong"));

Use this extension only when working directly with a BuildingStep obtained from the Kotlin MokksyServer API.

Parameters

responseType

The Java Class of the response type.

configurer

A Consumer applied to a ResponseDefinitionBuilder to configure the response.

Type Parameters

T

The type of the response body.