JsonResponseFormatter implements ResponseFormatter { @Override public byte[] formatResponse(final WilmaHttpRequest wilmaRequest, final HttpServletResponse resp, final byte[] templateResource, final ParameterList params) { JsonElement response = new JsonParser().parse(new String(templateResource, StandardCharsets.UTF_8)); new NonRecursiveJsonTreeEvaluator(wilmaRequest.getBody()).replaceAllNonRecursive(response); return response.toString().getBytes(); }  @Override byte[] formatResponse(final WilmaHttpRequest wilmaRequest, final HttpServletResponse resp,
                                 final byte[] templateResource, final ParameterList params);  }
@Test(dataProvider = "messages") public void testFormatTemplate(String request, String template, String expected) throws Exception { givenWilmaRequestWithBody(request); byte[] formattedResponse = underTest.formatResponse(wilmaRequest, response, template.getBytes(), null); assertEquals(whitespaceFree(new String(formattedResponse)), whitespaceFree(expected)); }