Wiremock customize recording and playback

647 Views Asked by At

I am using Wiremock for stubbing the service. So that I can continue working on client application while service is down. I am recording the request and response by creating the proxy to service and using the recordings while service is down.

Their is one problem here. The api I am calling accepts xml input. One of the parameter is guid which changes every time. Now for Wiremock change in guid is another request it does another recording. Also when running playback the request does not match because of new guid in every request. Is their any way to ignore this parameter completely while doing recording and responding through playback ?

TIA

1

There are 1 best solutions below

0
Tom On

You can create an implementation of StubMappingTransformer in Java and register it as an extension with WireMock via wireMockConfig().extensions(new MyStubMappingTransformer() when you're starting it programmatically.

This will be called after a recording is completed and passed each stub that gets created, so you can add code that will e.g. swap the fields you don't want to match on exactly for placeholders.