@Test public void testFormatTemplateWhenMultipleParametersShouldReplaceString() throws Exception { templateResource = "this is a test template".getBytes(); parameterList.addParameter(new Parameter("t", "blabla")); parameterList.addParameter(new Parameter("is", "is not")); parameterList.addParameter(new Parameter("a", "o")); byte[] actual = underTest.formatResponse(request, response, templateResource, parameterList); assertEquals(actual, "bloblohis not is not o blobloesbloblo blobloemploblobloe".getBytes()); }
@Override public byte[] formatResponse(final WilmaHttpRequest wilmaRequest, final HttpServletResponse resp, final byte[] templateResource, final ParameterList params) throws Exception { byte[] result = templateResource; String template = null; if (!params.getAllParameters().isEmpty()) { template = getTemplate(templateResource, params); result = template.getBytes(StandardCharsets.UTF_8); } return result; }
StringReplaceResponseFormatter implements ResponseFormatter { @Override public byte[] formatResponse(final WilmaHttpRequest wilmaRequest, final HttpServletResponse resp, final byte[] templateResource, final ParameterList params) throws Exception { byte[] result = templateResource; String template = null; if (!params.getAllParameters().isEmpty()) { template = getTemplate(templateResource, params); result = template.getBytes(StandardCharsets.UTF_8); } return result; } }
StringReplaceResponseFormatter implements ResponseFormatter { @Override public byte[] formatResponse(final WilmaHttpRequest wilmaRequest, final HttpServletResponse resp, final byte[] templateResource, final ParameterList params) throws Exception { byte[] result = templateResource; String template = null; if (!params.getAllParameters().isEmpty()) { template = getTemplate(templateResource, params); result = template.getBytes(StandardCharsets.UTF_8); } return result; }  }
StringReplaceResponseFormatter implements ResponseFormatter { @Override public byte[] formatResponse(final WilmaHttpRequest wilmaRequest, final HttpServletResponse resp, final byte[] templateResource, final ParameterList params) throws Exception { byte[] result = templateResource; String template = null; if (!params.getAllParameters().isEmpty()) { template = getTemplate(templateResource, params); result = template.getBytes(StandardCharsets.UTF_8); } return result; }  @Override byte[] formatResponse(final WilmaHttpRequest wilmaRequest, final HttpServletResponse resp,
                                 final byte[] templateResource, final ParameterList params); }
StringReplaceResponseFormatter implements ResponseFormatter { @Override public byte[] formatResponse(final WilmaHttpRequest wilmaRequest, final HttpServletResponse resp, final byte[] templateResource, final ParameterList params) throws Exception { byte[] result = templateResource; String template = null; if (!params.getAllParameters().isEmpty()) { template = getTemplate(templateResource, params); result = template.getBytes(StandardCharsets.UTF_8); } return result; }  @Override byte[] formatResponse(final WilmaHttpRequest wilmaRequest, final HttpServletResponse resp,
                                 final byte[] templateResource, final ParameterList params);  }