@Test public void testRenderWithoutAnyDataWithoutDebug() throws Exception { final Object domainMock = new Object(); final RenderRequest renderRequest = mock(RenderRequest.class); final SoyTofu soyTofu = mock(SoyTofu.class); final PrintWriter printWriter = mock(PrintWriter.class); final HttpServletResponse response = mock(HttpServletResponse.class); final HttpServletRequest request = mock(HttpServletRequest.class); final String templateName = "soy.example.clientWords"; final SoyTofu.Renderer renderer = mock(SoyTofu.Renderer.class); final SoyMapData modelData = new SoyMapData(); final SoyView soyView = mock(SoyView.class); when(renderRequest.getCompiledTemplates()).thenReturn(Optional.of(soyTofu)); when(toSoyDataConverter.toSoyMap(domainMock)).thenReturn(Optional.<SoyMapData>absent()); when(renderRequest.getModel()).thenReturn(domainMock); when(renderRequest.getRequest()).thenReturn(request); when(renderRequest.getResponse()).thenReturn(response); when(renderRequest.getTemplateName()).thenReturn(templateName); when(soyTofu.newRenderer(templateName)).thenReturn(renderer); when(renderRequest.getGlobalRuntimeModel()).thenReturn(Optional.<SoyMapData>absent()); when(renderRequest.getSoyMsgBundle()).thenReturn(Optional.<SoyMsgBundle>absent()); when(renderRequest.getSoyView()).thenReturn(soyView); when(response.getWriter()).thenReturn(printWriter); defaultTemplateRenderer.render(renderRequest); Mockito.verify(renderer, never()).setDontAddToCache(anyBoolean()); Mockito.verify(renderer, never()).setData(modelData); Mockito.verify(renderer, never()).setIjData(any(SoyMapData.class)); Mockito.verify(renderer, never()).setMsgBundle(any(SoyMsgBundle.class)); Mockito.verify(renderer).render(); Mockito.verify(printWriter).write(anyString()); Mockito.verify(printWriter).flush(); Mockito.verify(response).flushBuffer(); }
@Override public void render(final RenderRequest renderRequest) throws Exception { if (!renderRequest.getCompiledTemplates().isPresent()) { logger.warn("compiled templates are not present, nothing to render!"); return; } final SoyTofu compiledTemplates = renderRequest.getCompiledTemplates().get(); final String templateName = renderRequest.getTemplateName(); final SoyTofu.Renderer renderer = compiledTemplates.newRenderer(templateName); final Optional<SoyMapData> soyModel = toSoyDataConverter.toSoyMap(renderRequest.getModel()); setupRenderer(renderer, renderRequest, soyModel); writeResponse(renderer, renderRequest); }
DefaultTemplateRenderer implements TemplateRenderer { @Override public void render(final RenderRequest renderRequest) throws Exception { if (!renderRequest.getCompiledTemplates().isPresent()) { logger.warn("compiled templates are not present, nothing to render!"); return; } final SoyTofu compiledTemplates = renderRequest.getCompiledTemplates().get(); final String templateName = renderRequest.getTemplateName(); final SoyTofu.Renderer renderer = compiledTemplates.newRenderer(templateName); final Optional<SoyMapData> soyModel = toSoyDataConverter.toSoyMap(renderRequest.getModel()); setupRenderer(renderer, renderRequest, soyModel); writeResponse(renderer, renderRequest); } }
DefaultTemplateRenderer implements TemplateRenderer { @Override public void render(final RenderRequest renderRequest) throws Exception { if (!renderRequest.getCompiledTemplates().isPresent()) { logger.warn("compiled templates are not present, nothing to render!"); return; } final SoyTofu compiledTemplates = renderRequest.getCompiledTemplates().get(); final String templateName = renderRequest.getTemplateName(); final SoyTofu.Renderer renderer = compiledTemplates.newRenderer(templateName); final Optional<SoyMapData> soyModel = toSoyDataConverter.toSoyMap(renderRequest.getModel()); setupRenderer(renderer, renderRequest, soyModel); writeResponse(renderer, renderRequest); }  }
DefaultTemplateRenderer implements TemplateRenderer { @Override public void render(final RenderRequest renderRequest) throws Exception { if (!renderRequest.getCompiledTemplates().isPresent()) { logger.warn("compiled templates are not present, nothing to render!"); return; } final SoyTofu compiledTemplates = renderRequest.getCompiledTemplates().get(); final String templateName = renderRequest.getTemplateName(); final SoyTofu.Renderer renderer = compiledTemplates.newRenderer(templateName); final Optional<SoyMapData> soyModel = toSoyDataConverter.toSoyMap(renderRequest.getModel()); setupRenderer(renderer, renderRequest, soyModel); writeResponse(renderer, renderRequest); }  @Override void render(final RenderRequest renderRequest); void setToSoyDataConverter(final ToSoyDataConverter toSoyDataConverter); void setHotReloadMode(boolean hotReloadMode); boolean isHotReloadMode(); boolean isHotReloadModeOff(); }
DefaultTemplateRenderer implements TemplateRenderer { @Override public void render(final RenderRequest renderRequest) throws Exception { if (!renderRequest.getCompiledTemplates().isPresent()) { logger.warn("compiled templates are not present, nothing to render!"); return; } final SoyTofu compiledTemplates = renderRequest.getCompiledTemplates().get(); final String templateName = renderRequest.getTemplateName(); final SoyTofu.Renderer renderer = compiledTemplates.newRenderer(templateName); final Optional<SoyMapData> soyModel = toSoyDataConverter.toSoyMap(renderRequest.getModel()); setupRenderer(renderer, renderRequest, soyModel); writeResponse(renderer, renderRequest); }  @Override void render(final RenderRequest renderRequest); void setToSoyDataConverter(final ToSoyDataConverter toSoyDataConverter); void setHotReloadMode(boolean hotReloadMode); boolean isHotReloadMode(); boolean isHotReloadModeOff();  }