@Test public void testFormatTemplateShouldReplaceRegexp() throws Exception { templateResource = "123 this is a test template 123".getBytes(); parameterList.addParameter(new Parameter("[0-2]+", "HELLO")); byte[] actual = underTest.formatResponse(request, response, templateResource, parameterList); assertEquals(actual, "HELLO3 this is a test template HELLO3".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; }
StringRegexpReplaceResponseFormatter 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; } }
StringRegexpReplaceResponseFormatter 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; }  }
StringRegexpReplaceResponseFormatter 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); }
StringRegexpReplaceResponseFormatter 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);  }