@Test public void complexObjectNavigation() throws MessagingException, IOException, ClassNotFoundException { final CacheManager cacheManager = mockery.mock(CacheManager.class); final Cache cache = mockery.mock(Cache.class); final MailTemplateResourcesProvider provider = mockery.mock(MailTemplateResourcesProvider.class); final List<String> chain = Collections.EMPTY_LIST; final String shopCode = "S001"; final String locale = "en"; final String fileName = "tmp"; final String ext = "txt"; final String template = "$root.first $root.second"; mockery.checking(new Expectations() {{ allowing(provider).getTemplate(chain, shopCode, locale, fileName, ext); will(returnValue(template)); allowing(cacheManager).getCache("contentService-templateSupport"); will(returnValue(cache)); allowing(cache).get(includeFunc + template); will(returnValue(null)); allowing(cache).put(with(equal(includeFunc + template)), with(any(Object.class))); }}); final TemplateProcessor templates = new MailComposerTemplateSupportGroovyImpl(new GroovyGStringTemplateSupportImpl(cacheManager)); Map<String, Object> model = new HashMap<>(); model.put("root", new Pair("hi", "there")); MailComposerImpl mailComposer = new MailComposerImpl(provider, templates); String result = mailComposer.processTemplate(chain, shopCode, locale, fileName, ext, model); assertEquals("hi there", result); mockery.assertIsSatisfied(); }
String processTemplate(final List<String> mailTemplateChain, final String shopCode, final String locale, final String fileName, final String ext, final Map<String, Object> model) { return processTemplate(mailTemplateChain, shopCode, locale, fileName, ext, model, false); }
MailComposerImpl implements MailComposer { String processTemplate(final List<String> mailTemplateChain, final String shopCode, final String locale, final String fileName, final String ext, final Map<String, Object> model) { return processTemplate(mailTemplateChain, shopCode, locale, fileName, ext, model, false); } }
MailComposerImpl implements MailComposer { String processTemplate(final List<String> mailTemplateChain, final String shopCode, final String locale, final String fileName, final String ext, final Map<String, Object> model) { return processTemplate(mailTemplateChain, shopCode, locale, fileName, ext, model, false); } MailComposerImpl(final MailTemplateResourcesProvider mailTemplateResourcesProvider,
                            final TemplateProcessor templateSupport); }
MailComposerImpl implements MailComposer { String processTemplate(final List<String> mailTemplateChain, final String shopCode, final String locale, final String fileName, final String ext, final Map<String, Object> model) { return processTemplate(mailTemplateChain, shopCode, locale, fileName, ext, model, false); } MailComposerImpl(final MailTemplateResourcesProvider mailTemplateResourcesProvider,
                            final TemplateProcessor templateSupport); String getResourceExpression(); void setResourceExpression(final String resourceExpression); @Override void composeMessage(final Mail mail,
                               final String shopCode,
                               final String locale,
                               final List<String> mailTemplateChain,
                               final String templateName,
                               final String from,
                               final String toEmail,
                               final String ccEmail,
                               final String bccEmail,
                               final Map<String, Object> model); @Override void convertMessage(final Mail mail, final MimeMessage mimeMessage); @Override String convertMessageToTXT(final Mail mail); @Override String convertMessageToHTML(final Mail mail); }
MailComposerImpl implements MailComposer { String processTemplate(final List<String> mailTemplateChain, final String shopCode, final String locale, final String fileName, final String ext, final Map<String, Object> model) { return processTemplate(mailTemplateChain, shopCode, locale, fileName, ext, model, false); } MailComposerImpl(final MailTemplateResourcesProvider mailTemplateResourcesProvider,
                            final TemplateProcessor templateSupport); String getResourceExpression(); void setResourceExpression(final String resourceExpression); @Override void composeMessage(final Mail mail,
                               final String shopCode,
                               final String locale,
                               final List<String> mailTemplateChain,
                               final String templateName,
                               final String from,
                               final String toEmail,
                               final String ccEmail,
                               final String bccEmail,
                               final Map<String, Object> model); @Override void convertMessage(final Mail mail, final MimeMessage mimeMessage); @Override String convertMessageToTXT(final Mail mail); @Override String convertMessageToHTML(final Mail mail);  }