JavaResponseDefinitionBuilder

Java-friendly wrapper around ResponseDefinitionBuilder that returns this from every mutating method, enabling fluent chaining without Kotlin-specific idioms.

Java callers receive this type from JavaBuildingStep.respondsWith and use it to configure the HTTP response for a stub:

mokksy.post(spec -> spec.path("/items"))
.respondsWith(builder -> builder
.body("{\"id\":\"42\"}")
.status(201)
.header("Location", "/items/42")
.delayMillis(50));

For typed response bodies, supply the response class to respondsWith:

mokksy.post(MyRequest.class, spec -> spec.path("/items"))
.respondsWith(MyResponse.class, builder -> builder
.body(new MyResponse("created"))
.status(201));

Type Parameters

P

The type of the request payload.

T

The type of the response body.

Functions

Link copied to clipboard

Sets the response body.

Link copied to clipboard

Sets the Content-Type of the response from a MIME-type string.

Link copied to clipboard

Sets a delay before the response is sent.

Link copied to clipboard

Sets a delay before the response is sent.

Link copied to clipboard

Adds a response header.

Link copied to clipboard

Sets the HTTP status code.