I want to add metadata to my mappings: <https://gi...
# wiremock-java
t
I want to add metadata to my mappings: https://github.com/wiremock/spec/blob/main/wiremock/wiremock-admin-api/schemas/stub-mapping.yaml#L35 And get that metadata in a RequestListener that I implement: https://github.com/wiremock/wiremock/blob/master/src/main/java/com/github/tomakehurst/wiremock/http/RequestListener.java#L20 I'm thinking it should be possible to add here: https://github.com/wiremock/wiremock/blob/master/src/main/java/com/github/tomakehurst/wiremock/http/AbstractRequestHandler.java#L94 Some things to consider here: 1. I just need
Metadata
, but perhaps the whole
ServeEvent
should be passed? 2. Perhaps
RequestListener
can have another method like:
default void requestReceived(ServeEvent serveEvent) {}
3. Or maby
void requestReceived(RequestRecieved received)
and add what is needed to the new class
RequestReceived
t
RequestListener
ought to be deprecated really, as it’s been superseded by
ServeEventListener
, which does accept a
ServeEvent
and therefore makes the stub metadata available.
t
Perfect! Thanks.
👍 1
It seems the code I run in
ServeEventListener.afterComplete
is being killed before finished executing. Any hint on why that is? And best way of handling it? Perhaps I should start a new thread and let it do my time consuming task.
t
This event happens asynchronously (at least in some cases) so it’s possible for the test runner to finish and exit before the event is triggered. I suggest either picking one of the earlier lifecycle events (all the others are synchronous) or putting an
await()
type condition in your test case.