@Test public void testCompileSoyToBinaryWithCompileTimeModel() throws Exception { final SoyMapData soyMapData = new SoyMapData(); soyMapData.put("test1", "test2"); when(compileTimeGlobalModelResolver.resolveData()).thenReturn(Optional.of(soyMapData)); when(compileTimeGlobalModelResolver.resolveData()).thenReturn(Optional.<SoyMapData>absent()); final URL template1 = getClass().getClassLoader().getResource("templates/template1.soy"); final URL template2 = getClass().getClassLoader().getResource("templates/template2.soy"); final Collection<String> tofu = defaultTofuCompiler.compileToJsSrc(Lists.newArrayList(template1, template2), null); Assert.assertFalse("tofu compiled collection should not be empty", tofu.isEmpty()); Assert.assertEquals("tofu compiled collection.size should be 2", 2, tofu.size()); }
@Override public final Optional<String> compileToJsSrc(@Nullable final URL url, @Nullable final SoyMsgBundle soyMsgBundle) { if (url == null) { return Optional.absent(); } final Collection<String> compiledTemplates = compileToJsSrc(Lists.newArrayList(url), soyMsgBundle); if (compiledTemplates.isEmpty()) { return Optional.absent(); } return Optional.fromNullable(compiledTemplates.iterator().next()); }
DefaultTofuCompiler implements TofuCompiler { @Override public final Optional<String> compileToJsSrc(@Nullable final URL url, @Nullable final SoyMsgBundle soyMsgBundle) { if (url == null) { return Optional.absent(); } final Collection<String> compiledTemplates = compileToJsSrc(Lists.newArrayList(url), soyMsgBundle); if (compiledTemplates.isEmpty()) { return Optional.absent(); } return Optional.fromNullable(compiledTemplates.iterator().next()); } }
DefaultTofuCompiler implements TofuCompiler { @Override public final Optional<String> compileToJsSrc(@Nullable final URL url, @Nullable final SoyMsgBundle soyMsgBundle) { if (url == null) { return Optional.absent(); } final Collection<String> compiledTemplates = compileToJsSrc(Lists.newArrayList(url), soyMsgBundle); if (compiledTemplates.isEmpty()) { return Optional.absent(); } return Optional.fromNullable(compiledTemplates.iterator().next()); }  }
DefaultTofuCompiler implements TofuCompiler { @Override public final Optional<String> compileToJsSrc(@Nullable final URL url, @Nullable final SoyMsgBundle soyMsgBundle) { if (url == null) { return Optional.absent(); } final Collection<String> compiledTemplates = compileToJsSrc(Lists.newArrayList(url), soyMsgBundle); if (compiledTemplates.isEmpty()) { return Optional.absent(); } return Optional.fromNullable(compiledTemplates.iterator().next()); }  @Override SoyTofu compile(@Nullable final Collection<URL> urls); @Override final Optional<String> compileToJsSrc(@Nullable final URL url, @Nullable final SoyMsgBundle soyMsgBundle); @Override Collection<String> compileToJsSrc(Collection<URL> templates, @Nullable SoyMsgBundle soyMsgBundle); void setHotReloadMode(final boolean hotReloadMode); void setCompileTimeGlobalModelResolver(final CompileTimeGlobalModelResolver compileTimeGlobalModelResolver); void setSoyJsSrcOptions(final SoyJsSrcOptions soyJsSrcOptions); boolean isHotReloadMode(); boolean isHotReloadModeOff(); SoyJsSrcOptions getSoyJsSrcOptions(); SoyTofuOptions getSoyTofuOptions(); void setSoyTofuOptions(SoyTofuOptions soyTofuOptions); }
DefaultTofuCompiler implements TofuCompiler { @Override public final Optional<String> compileToJsSrc(@Nullable final URL url, @Nullable final SoyMsgBundle soyMsgBundle) { if (url == null) { return Optional.absent(); } final Collection<String> compiledTemplates = compileToJsSrc(Lists.newArrayList(url), soyMsgBundle); if (compiledTemplates.isEmpty()) { return Optional.absent(); } return Optional.fromNullable(compiledTemplates.iterator().next()); }  @Override SoyTofu compile(@Nullable final Collection<URL> urls); @Override final Optional<String> compileToJsSrc(@Nullable final URL url, @Nullable final SoyMsgBundle soyMsgBundle); @Override Collection<String> compileToJsSrc(Collection<URL> templates, @Nullable SoyMsgBundle soyMsgBundle); void setHotReloadMode(final boolean hotReloadMode); void setCompileTimeGlobalModelResolver(final CompileTimeGlobalModelResolver compileTimeGlobalModelResolver); void setSoyJsSrcOptions(final SoyJsSrcOptions soyJsSrcOptions); boolean isHotReloadMode(); boolean isHotReloadModeOff(); SoyJsSrcOptions getSoyJsSrcOptions(); SoyTofuOptions getSoyTofuOptions(); void setSoyTofuOptions(SoyTofuOptions soyTofuOptions);  }