JavaBuildingStep

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

Instances are returned by MokksyServerJava's HTTP method stubs (get, post, etc.). Do not construct directly.

Example (Java):

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

mokksy.post(MyRequest.class, spec -> spec.path("/items"))
.respondsWith(MyResponse.class, builder -> {
builder.setBody(new MyResponse("created"));
builder.httpStatus(201);
builder.addHeader("Location", "/items/1");
});

Parameters

P

The type of the request payload.

Functions

Link copied to clipboard

Configures a String response for this stub.

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

Configures a typed response for this stub.

Link copied to clipboard

Configures a String streaming response for this stub.

fun <T : Any> respondsWithStream(responseType: Class<T>, configurer: Consumer<StreamingResponseDefinitionBuilder<P, T>>)

Configures a typed streaming response for this stub.