@Override public String executeTemplate(final String templateName, final Map<String, Object> data) throws IOException { final String templateText = getTemplateText(templateName); return executeTemplateText(templateText, data); }
@Override protected void configure() { bind(TemplateEngine.class).to(MustacheTemplateEngine.class).asEagerSingleton(); }
public String generateEmail(final Account account, final BillingState billingState, final Account overdueable, final OverdueState nextOverdueState) throws IOException { final Map<String, Object> data = new HashMap<String, Object>(); // TODO raw objects for now. We eventually should respect the account locale and support translations data.put("account", account); data.put("billingState", overdueEmailFormatterFactory.createBillingStateFormatter(billingState)); data.put("overdueable", overdueable); data.put("nextOverdueState", nextOverdueState); // TODO single template for all languages for now return templateEngine.executeTemplate(nextOverdueState.getEnterStateEmailNotification().getTemplateName(), data); } }
private void checkOutput(final Invoice invoice, final String template, final String expected, final Locale locale) { final Map<String, Object> data = new HashMap<String, Object>(); data.put("invoice", new DefaultInvoiceFormatter(config, invoice, locale, null)); final String formattedText = templateEngine.executeTemplateText(template, data); Assert.assertEquals(formattedText, expected); } }
@Override protected void configure() { super.configure(); install(new CallContextModule()); install(new MockGlobalLockerModule()); install(new CatalogModule(configSource)); install(new CacheModule(configSource)); install(new TemplateModule()); install(new EmailModule(configSource)); install(new NotificationQueueModule(configSource)); install(new TagStoreModule()); install(new CustomFieldModule()); installExternalApis(); bind(TestInvoiceHelper.class).asEagerSingleton(); } }
@Override @BeforeClass(groups = "fast") public void beforeClass() throws Exception { super.beforeClass(); config = new ConfigurationObjectFactory(System.getProperties()).build(TranslatorConfig.class); templateEngine = new MustacheTemplateEngine(); }
private void checkOutput(final InvoiceItem invoiceItem, final String template, final String expected, final Locale locale) { final Map<String, Object> data = new HashMap<String, Object>(); data.put("invoiceItem", new DefaultInvoiceItemFormatter(config, invoiceItem, DateTimeFormat.mediumDate(), locale)); final String formattedText = templateEngine.executeTemplateText(template, data); Assert.assertEquals(formattedText, expected); } }
public String generateInvoice(final Account account, @Nullable final Invoice invoice, final boolean manualPay) throws IOException { // Don't do anything if the invoice is null if (invoice == null) { return null; } final Map<String, Object> data = new HashMap<String, Object>(); final DefaultInvoiceTranslator invoiceTranslator = new DefaultInvoiceTranslator(config); final Locale locale = LocaleUtils.toLocale(account.getLocale()); invoiceTranslator.setLocale(locale); data.put("text", invoiceTranslator); data.put("account", account); final InvoiceFormatter formattedInvoice = factory.createInvoiceFormatter(config, invoice, locale, currencyConversionApi); data.put("invoice", formattedInvoice); if (manualPay) { return templateEngine.executeTemplate(config.getManualPayTemplateName(), data); } else { return templateEngine.executeTemplate(config.getTemplateName(), data); } } }
@Override protected void configure() { super.configure(); install(new AuditModule()); install(new CacheModule(configSource)); install(new CallContextModule()); install(new CustomFieldModule()); install(new EmailModule(configSource)); install(new MockAccountModule()); install(new MockEntitlementModule()); install(new MockInvoiceModule()); install(new MockTagModule()); install(new TemplateModule()); // We can't use the dumb mocks in MockJunctionModule here install(new ApplicatorMockJunctionModule()); bind(OverdueBusListenerTester.class).asEagerSingleton(); bind(TestOverdueHelper.class).asEagerSingleton(); } }
@BeforeClass(groups = "fast") public void beforeClass() throws Exception { super.beforeClass(); config = new ConfigurationObjectFactory(System.getProperties()).build(TranslatorConfig.class); templateEngine = new MustacheTemplateEngine(); }
final String formattedText = templateEngine.executeTemplateText(template, data);
@Override @BeforeClass(groups = "fast") public void beforeClass() throws Exception { super.beforeClass(); final TranslatorConfig config = new ConfigurationObjectFactory(System.getProperties()).build(TranslatorConfig.class); final TemplateEngine templateEngine = new MustacheTemplateEngine(); final InvoiceFormatterFactory factory = new DefaultInvoiceFormatterFactory(); g = new HtmlInvoiceGenerator(factory, templateEngine, config, null); }