@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 returnsZeroWhenConfigDoesNotRenderTags() throws RenderingException { TagsRenderer renderer = new TagsRenderer(); JBakeConfiguration configuration = mock(DefaultJBakeConfiguration.class); when(configuration.getRenderTags()).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 doesNotRenderWhenConfigDoesNotRenderTags() throws Exception { TagsRenderer renderer = new TagsRenderer(); JBakeConfiguration configuration = mock(DefaultJBakeConfiguration.class); when(configuration.getRenderTags()).thenReturn(false); ContentStore contentStore = mock(ContentStore.class); Renderer mockRenderer = mock(Renderer.class); renderer.render(mockRenderer, contentStore, configuration); verify(mockRenderer, never()).renderTags(anyString()); }
@Test public void returnsOneWhenConfigRendersIndices() throws Exception { TagsRenderer renderer = new TagsRenderer(); JBakeConfiguration configuration = mock(DefaultJBakeConfiguration.class); when(configuration.getRenderTags()).thenReturn(true); when(configuration.getTagPathName()).thenReturn("mocktagpath"); ContentStore contentStore = mock(ContentStore.class); Renderer mockRenderer = mock(Renderer.class); Set<String> tags = new HashSet<String>(Arrays.asList("tag1", "tags2")); when(contentStore.getTags()).thenReturn(tags); when(mockRenderer.renderTags(anyString())).thenReturn(1); int renderResponse = renderer.render(mockRenderer, contentStore, configuration); assertThat(renderResponse).isEqualTo(1); }
@Test(expected = RenderingException.class) public void propogatesRenderingException() throws Exception { TagsRenderer renderer = new TagsRenderer(); JBakeConfiguration configuration = mock(DefaultJBakeConfiguration.class); when(configuration.getRenderTags()).thenReturn(true); when(configuration.getTagPathName()).thenReturn("mocktagpath/tag"); ContentStore contentStore = mock(ContentStore.class); Renderer mockRenderer = mock(Renderer.class); doThrow(new Exception()).when(mockRenderer).renderTags(anyString()); renderer.render(mockRenderer, contentStore, configuration); verify(mockRenderer, never()).renderTags(anyString()); } }
@Test public void doesRenderWhenConfigDoesRenderIndices() throws Exception { TagsRenderer renderer = new TagsRenderer(); JBakeConfiguration configuration = mock(DefaultJBakeConfiguration.class); when(configuration.getRenderTags()).thenReturn(true); ContentStore contentStore = mock(ContentStore.class); Renderer mockRenderer = mock(Renderer.class); Set<String> tags = new HashSet<String>(Arrays.asList("tag1", "tags2")); when(contentStore.getTags()).thenReturn(tags); when(configuration.getTagPathName()).thenReturn("mockTagfile.html"); renderer.render(mockRenderer, contentStore, configuration); verify(mockRenderer, times(1)).renderTags(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); }