@Test public void testOnMessage0() throws Exception { final CacheManager cacheManager = mockery.mock(CacheManager.class); final Cache cache = mockery.mock(Cache.class); mockery.checking(new Expectations() {{ allowing(cacheManager).getCache("contentService-templateSupport"); will(returnValue(cache)); allowing(cache).get(with(any(String.class))); will(returnValue(null)); allowing(cache).put(with(any(String.class)), with(any(Object.class))); }}); final TemplateProcessor templates = new MailComposerTemplateSupportGroovyImpl(new GroovySimpleTemplateSupportImpl(cacheManager)); final MailService mailService = (MailService) ctx().getBean("mailService"); final MailTemplateResourcesProvider mailTemplateResourcesProvider = mockery.mock(MailTemplateResourcesProvider.class); final List<String> templateChain = Collections.singletonList("SHOIP1/mail/"); mockery.checking(new Expectations() {{ oneOf(mailTemplateResourcesProvider).getTemplate(templateChain, "SHOIP1", "en", "customerChangePassword", ".txt"); will(returnValue(IOUtils.toString(new FileInputStream(new File("src/test/resources/mailtemplates/SHOIP1/customerChangePassword/customerChangePassword.txt")), "UTF-8"))); oneOf(mailTemplateResourcesProvider).getTemplate(templateChain, "SHOIP1", "en", "customerChangePassword", ".html"); will(returnValue(IOUtils.toString(new FileInputStream(new File("src/test/resources/mailtemplates/SHOIP1/customerChangePassword/customerChangePassword.html")), "UTF-8"))); oneOf(mailTemplateResourcesProvider).getTemplate(templateChain, "SHOIP1", "en", "customerChangePassword", ".properties"); will(returnValue(IOUtils.toString(new FileInputStream(new File("src/test/resources/mailtemplates/SHOIP1/customerChangePassword/customerChangePassword.properties")), "UTF-8"))); }}); final MailComposerImpl mailComposer = new MailComposerImpl(mailTemplateResourcesProvider, templates); RegistrationMessage registrationMessage = createRegistrationMessage(templateChain); new CustomerRegistrationMessageListener( mailService, mailComposer, registrationMessage ).run(); final List<Mail> mail = mailService.findAll(); assertEquals(1, mail.size()); final Mail email = mail.get(0); assertTrue(email.getHtmlVersion().contains("neWpaSswOrd")); assertTrue(email.getHtmlVersion().contains("Mr")); assertTrue(email.getHtmlVersion().contains("Bender")); assertTrue(email.getHtmlVersion().contains("Bending")); assertTrue(email.getHtmlVersion().contains("Rodrigez")); assertTrue(email.getHtmlVersion().contains("Gadget universe")); assertTrue(email.getHtmlVersion().contains("somegadget.com")); assertEquals(email.getFrom(), "noreply@shop.com"); assertEquals(email.getSubject(), "Password has been changed"); mockery.assertIsSatisfied(); }
@Override public void run() { try { LOG.info("CustomerRegistrationMessageListener#onMessage response : {}", objectMessage); if (objectMessage.getMailTemplatePathChain() != null) { processMessage(objectMessage); } } catch (Exception e) { LOG.error(Markers.alert(), "Customer registration email error " + objectMessage + ", cause: " + e.getMessage(), e); throw new RuntimeException(e); } }
CustomerRegistrationMessageListener implements Runnable { @Override public void run() { try { LOG.info("CustomerRegistrationMessageListener#onMessage response : {}", objectMessage); if (objectMessage.getMailTemplatePathChain() != null) { processMessage(objectMessage); } } catch (Exception e) { LOG.error(Markers.alert(), "Customer registration email error " + objectMessage + ", cause: " + e.getMessage(), e); throw new RuntimeException(e); } } }
CustomerRegistrationMessageListener implements Runnable { @Override public void run() { try { LOG.info("CustomerRegistrationMessageListener#onMessage response : {}", objectMessage); if (objectMessage.getMailTemplatePathChain() != null) { processMessage(objectMessage); } } catch (Exception e) { LOG.error(Markers.alert(), "Customer registration email error " + objectMessage + ", cause: " + e.getMessage(), e); throw new RuntimeException(e); } } CustomerRegistrationMessageListener(final MailService mailService,
                                               final MailComposer mailComposer,
                                               final RegistrationMessage objectMessage); }
CustomerRegistrationMessageListener implements Runnable { @Override public void run() { try { LOG.info("CustomerRegistrationMessageListener#onMessage response : {}", objectMessage); if (objectMessage.getMailTemplatePathChain() != null) { processMessage(objectMessage); } } catch (Exception e) { LOG.error(Markers.alert(), "Customer registration email error " + objectMessage + ", cause: " + e.getMessage(), e); throw new RuntimeException(e); } } CustomerRegistrationMessageListener(final MailService mailService,
                                               final MailComposer mailComposer,
                                               final RegistrationMessage objectMessage); @Override void run(); }
CustomerRegistrationMessageListener implements Runnable { @Override public void run() { try { LOG.info("CustomerRegistrationMessageListener#onMessage response : {}", objectMessage); if (objectMessage.getMailTemplatePathChain() != null) { processMessage(objectMessage); } } catch (Exception e) { LOG.error(Markers.alert(), "Customer registration email error " + objectMessage + ", cause: " + e.getMessage(), e); throw new RuntimeException(e); } } CustomerRegistrationMessageListener(final MailService mailService,
                                               final MailComposer mailComposer,
                                               final RegistrationMessage objectMessage); @Override void run();  }