addListener

Registers a listener that is invoked when a matched stub is about to send its response.

Accepts a RequestListener — works from both Kotlin and Java.

Prefer onResponseReady from Kotlin for suspend-aware usage.

Example (Java):

mokksy.addListener((request, response) -> {
assertThat(request.getUri()).isEqualTo("/path");
});

Only a single listener may be registered. Subsequent calls replace the previous one.

Parameters

listener

The RequestListener whose RequestListener.onResponseReady will be called when a stub response is ready.