use of org.subethamail.wiser.WiserMessage in project Activiti by Activiti.
the class EmailServiceTaskTest method testTextMailWithFileAttachment.
@Deployment
public void testTextMailWithFileAttachment() throws Exception {
HashMap<String, Object> vars = new HashMap<String, Object>();
vars.put("attachmentsBean", new AttachmentsBean());
runtimeService.startProcessInstanceByKey("textMailWithFileAttachment", vars);
List<WiserMessage> messages = wiser.getMessages();
assertEquals(1, messages.size());
WiserMessage message = messages.get(0);
MimeMultipart mm = (MimeMultipart) message.getMimeMessage().getContent();
assertEquals(2, mm.getCount());
String attachmentFileName = mm.getBodyPart(1).getDataHandler().getName();
assertEquals(new AttachmentsBean().getFile().getName(), attachmentFileName);
}
use of org.subethamail.wiser.WiserMessage in project Activiti by Activiti.
the class EmailSendTaskTest method testTextMailExpressions.
@Deployment
public void testTextMailExpressions() throws Exception {
String sender = "mispiggy@activiti.org";
String recipient = "fozziebear@activiti.org";
String recipientName = "Mr. Fozzie";
String subject = "Fozzie, you should see this!";
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("sender", sender);
vars.put("recipient", recipient);
vars.put("recipientName", recipientName);
vars.put("subject", subject);
runtimeService.startProcessInstanceByKey("textMailExpressions", vars);
List<WiserMessage> messages = wiser.getMessages();
assertEquals(1, messages.size());
WiserMessage message = messages.get(0);
assertEmailSend(message, false, subject, "Hello " + recipientName + ", this is an e-mail", sender, Arrays.asList(recipient), null);
}
use of org.subethamail.wiser.WiserMessage in project Activiti by Activiti.
the class EmailSendTaskTest method testSimpleTextMailMultipleRecipients.
@Deployment
public void testSimpleTextMailMultipleRecipients() {
runtimeService.startProcessInstanceByKey("simpleTextOnlyMultipleRecipients");
// 3 recipients == 3 emails in wiser with different receivers
List<WiserMessage> messages = wiser.getMessages();
assertEquals(3, messages.size());
// sort recipients for easy assertion
List<String> recipients = new ArrayList<String>();
for (WiserMessage message : messages) {
recipients.add(message.getEnvelopeReceiver());
}
Collections.sort(recipients);
assertEquals("fozzie@activiti.org", recipients.get(0));
assertEquals("kermit@activiti.org", recipients.get(1));
assertEquals("mispiggy@activiti.org", recipients.get(2));
}
use of org.subethamail.wiser.WiserMessage in project Activiti by Activiti.
the class EmailSendTaskTest method testSendEmail.
@Deployment
public void testSendEmail() throws Exception {
String from = "ordershipping@activiti.org";
boolean male = true;
String recipientName = "John Doe";
String recipient = "johndoe@alfresco.com";
Date now = new Date();
String orderId = "123456";
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("sender", from);
vars.put("recipient", recipient);
vars.put("recipientName", recipientName);
vars.put("male", male);
vars.put("now", now);
vars.put("orderId", orderId);
runtimeService.startProcessInstanceByKey("sendMailExample", vars);
List<WiserMessage> messages = wiser.getMessages();
assertEquals(1, messages.size());
WiserMessage message = messages.get(0);
MimeMessage mimeMessage = message.getMimeMessage();
assertEquals("Your order " + orderId + " has been shipped", mimeMessage.getHeader("Subject", null));
assertEquals(from, mimeMessage.getHeader("From", null));
assertTrue(mimeMessage.getHeader("To", null).contains(recipient));
}
use of org.subethamail.wiser.WiserMessage in project Activiti by Activiti.
the class EmailServiceTaskTest method testSendEmail.
@Deployment
public void testSendEmail() throws Exception {
String from = "ordershipping@activiti.org";
boolean male = true;
String recipientName = "John Doe";
String recipient = "johndoe@alfresco.com";
Date now = new Date();
String orderId = "123456";
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("sender", from);
vars.put("recipient", recipient);
vars.put("recipientName", recipientName);
vars.put("male", male);
vars.put("now", now);
vars.put("orderId", orderId);
runtimeService.startProcessInstanceByKey("sendMailExample", vars);
List<WiserMessage> messages = wiser.getMessages();
assertEquals(1, messages.size());
WiserMessage message = messages.get(0);
MimeMessage mimeMessage = message.getMimeMessage();
assertEquals("Your order " + orderId + " has been shipped", mimeMessage.getHeader("Subject", null));
assertEquals(from, mimeMessage.getHeader("From", null));
assertTrue(mimeMessage.getHeader("To", null).contains(recipient));
}
Aggregations