@Override public int render(Renderer renderer, ContentStore db, File destination, File templatesPath, CompositeConfiguration config) throws RenderingException { JBakeConfiguration configuration = new JBakeConfigurationFactory().createDefaultJbakeConfiguration(templatesPath.getParentFile(), config); return render(renderer, db, configuration); } }
@Test public void returnsZeroWhenConfigDoesNotRenderIndices() throws RenderingException { IndexRenderer renderer = new IndexRenderer(); JBakeConfiguration configuration = mock(DefaultJBakeConfiguration.class); when(configuration.getRenderIndex()).thenReturn(false); ContentStore contentStore = mock(ContentStore.class); Renderer mockRenderer = mock(Renderer.class); int renderResponse = renderer.render(mockRenderer, contentStore, configuration); assertThat(renderResponse).isEqualTo(0); }
@Test public void returnsOneWhenConfigRendersIndices() throws RenderingException { IndexRenderer renderer = new IndexRenderer(); JBakeConfiguration configuration = mock(DefaultJBakeConfiguration.class); when(configuration.getRenderIndex()).thenReturn(true); ContentStore contentStore = mock(ContentStore.class); Renderer mockRenderer = mock(Renderer.class); int renderResponse = renderer.render(mockRenderer, contentStore, configuration); assertThat(renderResponse).isEqualTo(1); }
@Test public void doesNotRenderWhenConfigDoesNotRenderIndices() throws Exception { IndexRenderer renderer = new IndexRenderer(); JBakeConfiguration configuration = mock(DefaultJBakeConfiguration.class); when(configuration.getRenderIndex()).thenReturn(false); ContentStore contentStore = mock(ContentStore.class); Renderer mockRenderer = mock(Renderer.class); renderer.render(mockRenderer, contentStore, configuration); verify(mockRenderer, never()).renderIndex(anyString()); }
@Test(expected = RenderingException.class) public void propagatesRenderingException() throws Exception { IndexRenderer renderer = new IndexRenderer(); JBakeConfiguration configuration = mock(DefaultJBakeConfiguration.class); when(configuration.getRenderIndex()).thenReturn(true); when(configuration.getIndexFileName()).thenReturn("mockindex.html"); ContentStore contentStore = mock(ContentStore.class); Renderer mockRenderer = mock(Renderer.class); doThrow(new Exception()).when(mockRenderer).renderIndex(anyString()); renderer.render(mockRenderer, contentStore, configuration); verify(mockRenderer, never()).renderIndex(anyString()); }
@Test public void shouldRenderPaginatedIndex() throws Exception { IndexRenderer renderer = new IndexRenderer(); JBakeConfiguration configuration = mock(DefaultJBakeConfiguration.class); when(configuration.getRenderIndex()).thenReturn(true); when(configuration.getPaginateIndex()).thenReturn(true); when(configuration.getIndexFileName()).thenReturn("mockindex.html"); ContentStore contentStore = mock(ContentStore.class); Renderer mockRenderer = mock(Renderer.class); renderer.render(mockRenderer, contentStore, configuration); verify(mockRenderer, times(1)).renderIndexPaging(anyString()); } }
/** * @see <a href="https://github.com/jbake-org/jbake/issues/332">Issue 332</a> */ @Test public void shouldFallbackToStandardIndexRenderingIfPropertyIsMissing() throws Exception { IndexRenderer renderer = new IndexRenderer(); JBakeConfiguration configuration = mock(DefaultJBakeConfiguration.class); when(configuration.getRenderIndex()).thenReturn(true); when(configuration.getIndexFileName()).thenReturn("mockindex.html"); ContentStore contentStore = mock(ContentStore.class); Renderer mockRenderer = mock(Renderer.class); renderer.render(mockRenderer, contentStore, configuration); verify(mockRenderer, times(1)).renderIndex(anyString()); }
@Override public int render(Renderer renderer, ContentStore db, File destination, File templatesPath, CompositeConfiguration config) throws RenderingException { JBakeConfiguration configuration = new JBakeConfigurationFactory().createDefaultJbakeConfiguration(templatesPath.getParentFile(), config); return render(renderer, db, configuration); } }