Search in sources :

Example 6 with WiserMessage

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);
}
Also used : HashMap(java.util.HashMap) MimeMultipart(javax.mail.internet.MimeMultipart) WiserMessage(org.subethamail.wiser.WiserMessage) Deployment(org.activiti.engine.test.Deployment)

Example 7 with WiserMessage

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);
}
Also used : HashMap(java.util.HashMap) WiserMessage(org.subethamail.wiser.WiserMessage) Deployment(org.activiti.engine.test.Deployment)

Example 8 with WiserMessage

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));
}
Also used : ArrayList(java.util.ArrayList) WiserMessage(org.subethamail.wiser.WiserMessage) Deployment(org.activiti.engine.test.Deployment)

Example 9 with WiserMessage

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));
}
Also used : HashMap(java.util.HashMap) MimeMessage(javax.mail.internet.MimeMessage) WiserMessage(org.subethamail.wiser.WiserMessage) Date(java.util.Date) Deployment(org.activiti.engine.test.Deployment)

Example 10 with WiserMessage

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));
}
Also used : HashMap(java.util.HashMap) MimeMessage(javax.mail.internet.MimeMessage) WiserMessage(org.subethamail.wiser.WiserMessage) Date(java.util.Date) Deployment(org.activiti.engine.test.Deployment)

Aggregations

WiserMessage (org.subethamail.wiser.WiserMessage)34 Deployment (org.activiti.engine.test.Deployment)22 HashMap (java.util.HashMap)16 MimeMultipart (javax.mail.internet.MimeMultipart)12 MimeMessage (javax.mail.internet.MimeMessage)11 Test (org.junit.Test)8 File (java.io.File)4 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 EmailMessage (org.sonar.plugins.emailnotifications.api.EmailMessage)2 Issue (org.sonar.wsclient.issue.Issue)2 Issues (org.sonar.wsclient.issue.Issues)2 PostRequest (org.sonarqube.ws.client.PostRequest)2 SonarScanner (com.sonar.orchestrator.build.SonarScanner)1 BeforeClass (org.junit.BeforeClass)1 QualityGate (org.sonar.wsclient.qualitygate.QualityGate)1 WsClient (org.sonarqube.ws.client.WsClient)1 Wiser (org.subethamail.wiser.Wiser)1 ItUtils.newAdminWsClient (util.ItUtils.newAdminWsClient)1 ItUtils.newUserWsClient (util.ItUtils.newUserWsClient)1