### Question:
DefaultRenderingCacheConfiguration implements RenderingCacheConfiguration { @Override public boolean isCached(DocumentReference documentReference) { if (documentReference != null && isFarmEnabled()) { if (isCachedInFarm(documentReference)) { return true; } return isCachedInWiki(documentReference); } return false; }  @Override boolean isEnabled(); boolean isFarmEnabled(); boolean isWikiEnabled(); @Override int getDuration(); @Override int getSize(); @Override boolean isCached(DocumentReference documentReference); boolean isCachedInWiki(DocumentReference documentReference);  }### Answer:
@Test public void testIsCachedWithNoConfiguration() throws Exception { Assert.assertFalse(this.configuration.isCached(this.documentReference)); }
@Test public void testIsCachedWhenDisabled() throws Exception { this.xwikipropertiesConfiguration.setProperty("core.renderingcache.enabled", false); Assert.assertFalse(this.configuration.isCached(this.documentReference)); }
@Test public void testIsCachedWhenDisabledWithNoConfiguration() throws Exception { this.xwikipropertiesConfiguration.setProperty("core.renderingcache.enabled", true); Assert.assertFalse(this.configuration.isCached(this.documentReference)); }
@Test public void testIsCachedWithExactReference() throws Exception { this.xwikipropertiesConfiguration.setProperty("core.renderingcache.enabled", true); this.xwikipropertiesConfiguration.setProperty("core.renderingcache.documents", Collections.singletonList("wiki:space.page")); Assert.assertTrue(this.configuration.isCached(this.documentReference)); }
@Test public void testIsCachedWithWrongReference() throws Exception { this.xwikipropertiesConfiguration.setProperty("core.renderingcache.enabled", true); this.xwikipropertiesConfiguration.setProperty("core.renderingcache.documents", Collections.singletonList("wrongreference")); Assert.assertFalse(this.configuration.isCached(this.documentReference)); }
@Test public void testIsCachedWithOnePattern() throws Exception { this.xwikipropertiesConfiguration.setProperty("core.renderingcache.enabled", true); this.xwikipropertiesConfiguration.setProperty("core.renderingcache.documents", Collections.singletonList("wiki:space.*")); Assert.assertTrue(this.configuration.isCached(this.documentReference)); }
@Test public void testIsCachedWithSeveralPattern() throws Exception { this.xwikipropertiesConfiguration.setProperty("core.renderingcache.enabled", true); this.xwikipropertiesConfiguration.setProperty("core.renderingcache.documents", Arrays.asList("wrongreference", "wiki:space.*")); Assert.assertTrue(this.configuration.isCached(this.documentReference)); }
@Test public void testIsCachedWithSeveralPattern2() throws Exception { this.xwikipropertiesConfiguration.setProperty("core.renderingcache.enabled", true); this.xwikipropertiesConfiguration.setProperty("core.renderingcache.documents", Arrays.asList("wiki:space.*", "wrongreference")); Assert.assertTrue(this.configuration.isCached(this.documentReference)); }
@Test public void testIsCachedWithWikiConfiguration() throws Exception { this.xwikipropertiesConfiguration.setProperty("core.renderingcache.enabled", true); this.wikiConfiguration.setProperty("core.renderingcache.enabled", true); this.wikiConfiguration.setProperty("core.renderingcache.documents", Arrays.asList("wiki:space.*", "wrongreference")); Assert.assertTrue(this.configuration.isCached(this.documentReference)); this.wikiConfiguration.setProperty("core.renderingcache.documents", Arrays.asList("space.*", "wrongreference")); Assert.assertTrue(this.configuration.isCached(this.documentReference)); }