### Question:
ClasspathTemplateFilesResolver implements TemplateFilesResolver, InitializingBean { @Override public Collection<URL> resolve() throws IOException { Preconditions.checkNotNull(templatesLocation, "templatesLocation cannot be null!"); return Collections.unmodifiableCollection(handleResolution()); }  @Override void afterPropertiesSet(); @Override Collection<URL> resolve(); @Override Optional<URL> resolve(final @Nullable String templateFileName); void setTemplatesLocation(String templatesLocation); void setRecursive(boolean recursive); void setHotReloadMode(boolean hotReloadMode); String getTemplatesLocation(); boolean isRecursive(); boolean isHotReloadMode(); String getFilesExtension(); void setFilesExtension(String filesExtension);  }### Answer:
@Test public void resolveDebugOffRecursiveOn() throws Exception { final Collection<URL> urls = templateFilesResolver.resolve(); Assert.assertEquals("should resolve urls", 5, urls.size()); Set<String> names = nab_template_names(urls); for (final String s : new String[] {"template1", "template2", "template3", "sub/template4", "sub/template5"}) { Assert.assertTrue(s + " must be in the set of resolved templates.", names.contains("templates/" + s + ".soy")); } }
@Test public void resolveWithFullTemplateNameDebugOff() throws Exception { final Optional<URL> url = templateFilesResolver.resolve("templates/template1"); Assert.assertTrue("should be present", url.isPresent()); Assert.assertTrue("template1Url file should end with template1.soy", url.get().getFile().endsWith("template1.soy")); }
@Test public void resolveWithTemplateNameDebugOff() throws Exception { final Optional<URL> url = templateFilesResolver.resolve("template1"); Assert.assertTrue("should be present", url.isPresent()); Assert.assertTrue("template1Url file should end with template1.soy", url.get().getFile().endsWith("template1.soy")); }
@Test public void resolveWithFullTemplateNameExtDebugOff() throws Exception { final Optional<URL> url = templateFilesResolver.resolve("templates/template1.soy"); Assert.assertTrue("should be present", url.isPresent()); Assert.assertTrue("template1Url file should end with template1.soy", url.get().getFile().endsWith("template1.soy")); }
@Test public void resolveWithTemplateNameExtDebugOff() throws Exception { final Optional<URL> url = templateFilesResolver.resolve("template1.soy"); Assert.assertTrue("should be present", url.isPresent()); Assert.assertTrue("template1Url file should end with template1.soy", url.get().getFile().endsWith("template1.soy")); }
@Test public void resolveWithFullTemplateNameExtDebugOffShouldNotWork() throws Exception { final Optional<URL> url = templateFilesResolver.resolve("tmpl/template1.soy"); Assert.assertFalse("should be absent", url.isPresent()); }
@Test public void cacheDisabledByDefault() throws Exception { templateFilesResolver.resolve("template1"); Assert.assertFalse("cache should not be empty", templateFilesResolver.cachedFiles.isEmpty()); }
@Test public void cacheEnabledWithDebugOff() throws Exception { templateFilesResolver.resolve("template1"); Assert.assertFalse("cache should not be empty", templateFilesResolver.cachedFiles.isEmpty()); Assert.assertEquals("number of items in cache should be equal", 5, templateFilesResolver.cachedFiles.size()); }