Search code examples
wiremock

How to migrate `ResponseTemplateTransformer(false)` into WireMock version 3 - Java code


Being on WireMock version 2, I had the following snippet in some test code, which has been meant to instantiate the WireMockConfig object:

com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig().dynamicPort().extensions(new ResponseTemplateTransformer(false))

The idea has been not to have any specific response transformations.

After upgrading WireMock dependency to version 3, I realised the constructor on class ResponseTemplateTransformer which has been accepting only a boolean, has been disappeared. Looks like there is no good migration guide available online or I did not find it. So I will post what I did to hopefully save some one's time.


Solution

  • So the answer to me was:

    In order to have no response transformations active, do not make yourself tired searching for a new constructor equivalent to ResponseTemplateTransformer(false).

    Just ignore calling the extensions builder-method on WireMockConfiguration for passing the ResponseTemplateTransformer. You do not need a Transformer here:

    com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig().dynamicPort();

    I hope I'm not missing something here as I'm not that much into WireMock.