Search in sources :

Example 41 with WiserMessage

use of org.subethamail.wiser.WiserMessage in project Activiti by Activiti.

the class EmailServiceTaskTest method testSimpleTextMail.

@Deployment
public void testSimpleTextMail() throws Exception {
    String procId = runtimeService.startProcessInstanceByKey("simpleTextOnly").getId();
    List<WiserMessage> messages = wiser.getMessages();
    assertEquals(1, messages.size());
    WiserMessage message = messages.get(0);
    assertEmailSend(message, false, "Hello Kermit!", "This a text only e-mail.", "activiti@localhost", Arrays.asList("kermit@activiti.org"), null);
    assertProcessEnded(procId);
}
Also used : WiserMessage(org.subethamail.wiser.WiserMessage) Deployment(org.activiti.engine.test.Deployment)

Example 42 with WiserMessage

use of org.subethamail.wiser.WiserMessage in project Activiti by Activiti.

the class EmailServiceTaskTest 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 43 with WiserMessage

use of org.subethamail.wiser.WiserMessage in project Activiti by Activiti.

the class EmailServiceTaskTest method testTextMailWithDataSourceAttachment.

@Deployment
public void testTextMailWithDataSourceAttachment() throws Exception {
    String fileName = "file-name-to-be-displayed";
    String fileContent = "This is the file content";
    HashMap<String, Object> vars = new HashMap<String, Object>();
    vars.put("attachmentsBean", new AttachmentsBean());
    vars.put("fileContent", fileContent);
    vars.put("fileName", fileName);
    runtimeService.startProcessInstanceByKey("textMailWithDataSourceAttachment", 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(fileName, attachmentFileName);
}
Also used : HashMap(java.util.HashMap) MimeMultipart(javax.mail.internet.MimeMultipart) WiserMessage(org.subethamail.wiser.WiserMessage) Deployment(org.activiti.engine.test.Deployment)

Example 44 with WiserMessage

use of org.subethamail.wiser.WiserMessage in project Activiti by Activiti.

the class EmailSendTaskTest method testTextMailWithNotExistingFileAttachment.

@Deployment
public void testTextMailWithNotExistingFileAttachment() throws Exception {
    HashMap<String, Object> vars = new HashMap<String, Object>();
    vars.put("attachmentsBean", new AttachmentsBean());
    runtimeService.startProcessInstanceByKey("textMailWithNotExistingFileAttachment", vars);
    List<WiserMessage> messages = wiser.getMessages();
    assertEquals(1, messages.size());
    WiserMessage message = messages.get(0);
    assertFalse(message.getMimeMessage().getContent() instanceof MimeMultipart);
}
Also used : HashMap(java.util.HashMap) MimeMultipart(javax.mail.internet.MimeMultipart) WiserMessage(org.subethamail.wiser.WiserMessage) Deployment(org.activiti.engine.test.Deployment)

Example 45 with WiserMessage

use of org.subethamail.wiser.WiserMessage in project Activiti by Activiti.

the class EmailSendTaskTest method testTextMailWithFileAttachments.

@Deployment
public void testTextMailWithFileAttachments() throws Exception {
    HashMap<String, Object> vars = new HashMap<String, Object>();
    vars.put("attachmentsBean", new AttachmentsBean());
    runtimeService.startProcessInstanceByKey("textMailWithFileAttachments", vars);
    List<WiserMessage> messages = wiser.getMessages();
    assertEquals(1, messages.size());
    WiserMessage message = messages.get(0);
    MimeMultipart mm = (MimeMultipart) message.getMimeMessage().getContent();
    File[] files = new AttachmentsBean().getFiles();
    assertEquals(1 + files.length, mm.getCount());
    for (int i = 0; i < files.length; i++) {
        String attachmentFileName = mm.getBodyPart(1 + i).getDataHandler().getName();
        assertEquals(files[i].getName(), attachmentFileName);
    }
}
Also used : HashMap(java.util.HashMap) MimeMultipart(javax.mail.internet.MimeMultipart) WiserMessage(org.subethamail.wiser.WiserMessage) File(java.io.File) Deployment(org.activiti.engine.test.Deployment)

Aggregations

WiserMessage (org.subethamail.wiser.WiserMessage)67 MimeMessage (javax.mail.internet.MimeMessage)34 Test (org.junit.Test)27 HashMap (java.util.HashMap)26 Deployment (org.activiti.engine.test.Deployment)22 ArrayList (java.util.ArrayList)12 MimeMultipart (javax.mail.internet.MimeMultipart)12 Deployment (org.camunda.bpm.engine.test.Deployment)10 Date (java.util.Date)9 WorkItemImpl (org.drools.core.process.instance.impl.WorkItemImpl)6 AbstractBaseTest (org.jbpm.test.AbstractBaseTest)6 InputStreamReader (java.io.InputStreamReader)5 Reader (java.io.Reader)5 DefaultWorkItemManager (org.drools.core.process.instance.impl.DefaultWorkItemManager)5 CountDownTaskEventListener (org.jbpm.services.task.util.CountDownTaskEventListener)5 WorkItemManager (org.kie.api.runtime.process.WorkItemManager)5 InternalTask (org.kie.internal.task.api.model.InternalTask)5 File (java.io.File)4 LinkedHashSet (java.util.LinkedHashSet)4 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)4