Package com.cedarsolutions.shared.domain.email

Examples of com.cedarsolutions.shared.domain.email.EmailTemplate


    /** Test sendEmail() for a plaintext template. */
    @Test public void testSendTemplatePlaintext() {
        Map<String, Object> context = new HashMap<String, Object>();

        EmailTemplate template = new EmailTemplate();
        template.setFormat(EmailFormat.PLAINTEXT);
        template.setSender(new EmailAddress("sender-name", "sender-address"));
        template.setReplyTo(new EmailAddress("reply-name", "reply-address"));
        template.setTemplateGroup("g");
        template.setTemplateName("n");
        template.setTemplateContext(context);

        ArgumentCaptor<EmailMessage> email = ArgumentCaptor.forClass(EmailMessage.class);

        GaeEmailService service = createService();
        Message message = mock(Message.class);
        when(service.getGaeEmailUtils().createMessage(isA(EmailMessage.class))).thenReturn(message);
        when(service.getTemplateService().renderTemplate("g", "n", SUBJECT, context)).thenReturn("subject-rendered");
        when(service.getTemplateService().renderTemplate("g", "n", PLAINTEXT, context)).thenReturn("plaintext-rendered");
        when(service.getTemplateService().renderTemplate("g", "n", HTML, context)).thenReturn("html-rendered");

        service.sendEmail(template);

        verify(service.getGaeEmailUtils()).sendMessage(message);
        verify(service.getGaeEmailUtils()).createMessage(email.capture());
        assertEquals(template.getFormat(), email.getValue().getFormat());
        assertEquals(template.getSender(), email.getValue().getSender());
        assertEquals(template.getReplyTo(), email.getValue().getReplyTo());
        assertEquals(template.getRecipients(), email.getValue().getRecipients());
        assertEquals("subject-rendered", email.getValue().getSubject());
        assertEquals("plaintext-rendered", email.getValue().getPlaintext());
        assertEquals(null, email.getValue().getHtml());
    }
View Full Code Here


    /** Test sendEmail() for a multipart template. */
    @Test public void testSendTemplateMultipart() {
        Map<String, Object> context = new HashMap<String, Object>();

        EmailTemplate template = new EmailTemplate();
        template.setFormat(EmailFormat.MULTIPART);
        template.setSender(new EmailAddress("sender-name", "sender-address"));
        template.setReplyTo(new EmailAddress("reply-name", "reply-address"));
        template.setTemplateGroup("g");
        template.setTemplateName("n");
        template.setTemplateContext(context);

        ArgumentCaptor<EmailMessage> email = ArgumentCaptor.forClass(EmailMessage.class);

        GaeEmailService service = createService();
        Message message = mock(Message.class);
        when(service.getGaeEmailUtils().createMessage(isA(EmailMessage.class))).thenReturn(message);
        when(service.getTemplateService().renderTemplate("g", "n", SUBJECT, context)).thenReturn("subject-rendered");
        when(service.getTemplateService().renderTemplate("g", "n", PLAINTEXT, context)).thenReturn("plaintext-rendered");
        when(service.getTemplateService().renderTemplate("g", "n", HTML, context)).thenReturn("html-rendered");

        service.sendEmail(template);

        verify(service.getGaeEmailUtils()).sendMessage(message);
        verify(service.getGaeEmailUtils()).createMessage(email.capture());
        assertEquals(template.getFormat(), email.getValue().getFormat());
        assertEquals(template.getSender(), email.getValue().getSender());
        assertEquals(template.getReplyTo(), email.getValue().getReplyTo());
        assertEquals(template.getRecipients(), email.getValue().getRecipients());
        assertEquals("subject-rendered", email.getValue().getSubject());
        assertEquals("plaintext-rendered", email.getValue().getPlaintext());
        assertEquals("html-rendered", email.getValue().getHtml());
    }
View Full Code Here

TOP

Related Classes of com.cedarsolutions.shared.domain.email.EmailTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.