HandlebarsView extends AbstractTemplateView { @Override protected void renderMergedTemplateModel(final Map<String, Object> model, final HttpServletRequest request, final HttpServletResponse response) throws IOException { Context context = Context.newBuilder(model) .resolver(valueResolvers) .build(); try { template.apply(context, response.getWriter()); } finally { context.destroy(); } }  Template getTemplate(); @Override boolean checkResource(final Locale locale); void setTemplate(final Template template); void setValueResolver(final ValueResolver... valueResolvers);  }
@Test @SuppressWarnings("unchecked") public void renderMergedTemplateModel() throws Exception { Map<String, Object> model = createMock(Map.class); PrintWriter writer = createMock(PrintWriter.class); Template template = createMock(Template.class); Capture<Context> context = EasyMock.newCapture(); template.apply(capture(context), isA(PrintWriter.class)); HttpServletRequest request = createMock(HttpServletRequest.class); HttpServletResponse response = createMock(HttpServletResponse.class); expect(response.getWriter()).andReturn(writer); replay(template, model, request, response); HandlebarsView view = new HandlebarsView(); view.setValueResolver(MapValueResolver.INSTANCE); view.setTemplate(template); view.renderMergedTemplateModel(model, request, response); assertNotNull(context.getValue()); verify(template, model, request, response); }