//I am able to get the sample code working
Helper<String> serialNumberHelper = new Helper<String>() {
// @Override Helper<String> stringLengthHelper = new Helper<String>() {
// @Override
public Object apply(String context, Options options)
throws IOException {
return context.length();
}
};
public Object apply(String context, Options options)
throws IOException {
return context.substring(2);
}
};
Map<String, Helper> helpers = new HashMap<String, Helper>();
helpers.put("GetLength", stringLengthHelper);
helpers.put("GetSerialNumber", serialNumberHelper);
wireMockServer = new WireMockServer(
wireMockConfig().port(8080).options().extensions(
new ResponseTemplateTransformer(false, helpers)));
// and able to use the same in response.
wireMockServer
.stubFor(get(urlMatching("/vis/([a-z]*)\\?unitid=([0-9]*)"))
.willReturn(aResponse()
.withHeader("Content-Type", "text/plain")
.withBody(
"{{GetSerialNumber request.query.unitid.[0]}}")
.withTransformers("response-template")));