org.subethamail.wiser.WiserMessage Java Examples

The following examples show how to use org.subethamail.wiser.WiserMessage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmailSendTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testTextMailWithFileAttachmentsByPath() throws Exception {
  HashMap<String, Object> vars = new HashMap<String, Object>();
  vars.put("attachmentsBean", new AttachmentsBean());
  runtimeService.startProcessInstanceByKey("textMailWithFileAttachmentsByPath", 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);
  }
}
 
Example #2
Source File: EmailServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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("[email protected]", recipients.get(0));
  assertEquals("[email protected]", recipients.get(1));
  assertEquals("[email protected]", recipients.get(2));
}
 
Example #3
Source File: MailerImplTest.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@Test
void testInlineAttachment() throws MessagingException, IOException {
    String cid = UUID.randomUUID().toString() + "@acme";
    mailer.send(Mail.withHtml(TO, "Test", "testInlineAttachment")
            .addInlineAttachment("inline.txt", "my inlined text".getBytes(StandardCharsets.UTF_8), TEXT_CONTENT_TYPE, cid))
            .await().indefinitely();
    assertThat(wiser.getMessages()).hasSize(1);
    WiserMessage actual = wiser.getMessages().get(0);
    assertThat(getContent(actual)).contains("testInlineAttachment");
    MimeMessage msg = actual.getMimeMessage();
    assertThat(msg.getSubject()).isEqualTo("Test");
    assertThat(msg.getFrom()[0].toString()).isEqualTo(FROM);

    String value = getInlineAttachment("<" + cid + ">", (MimeMultipart) actual.getMimeMessage().getContent());
    assertThat(value).isEqualTo("my inlined text");
}
 
Example #4
Source File: MailerImplTest.java    From quarkus with Apache License 2.0 6 votes vote down vote up
@Test
void testAttachmentsLegacy() throws MessagingException, IOException {
    legacyMailer.send(Mail.withText(TO, "Test", "Simple Test")
            .addAttachment("some-data.txt", "Hello".getBytes(StandardCharsets.UTF_8), TEXT_CONTENT_TYPE)
            .addAttachment("some-data-2.txt", "Hello 2".getBytes(StandardCharsets.UTF_8), TEXT_CONTENT_TYPE))
            .toCompletableFuture().join();
    assertThat(wiser.getMessages()).hasSize(1);
    WiserMessage actual = wiser.getMessages().get(0);
    assertThat(getContent(actual)).contains("Simple Test");
    MimeMessage msg = actual.getMimeMessage();
    assertThat(msg.getSubject()).isEqualTo("Test");
    assertThat(msg.getFrom()[0].toString()).isEqualTo(FROM);
    String value = getAttachment("some-data.txt", (MimeMultipart) actual.getMimeMessage().getContent());
    assertThat(value).isEqualTo("Hello");
    value = getAttachment("some-data-2.txt", (MimeMultipart) actual.getMimeMessage().getContent());
    assertThat(value).isEqualTo("Hello 2");
}
 
Example #5
Source File: EmailServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testSimpleTextMailForNonExistentTenant() throws Exception {
  String tenantId = "nonExistentTenant";

  org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/activiti5/engine/test/bpmn/mail/EmailSendTaskTest.testSimpleTextMail.bpmn20.xml")
      .tenantId(tenantId)
      .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE)
      .deploy();
  String procId = runtimeService.startProcessInstanceByKeyAndTenantId("simpleTextOnly", tenantId).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("[email protected]"), null);
  assertProcessEnded(procId);

  repositoryService.deleteDeployment(deployment.getId(), true);
}
 
Example #6
Source File: EmailSendTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #7
Source File: EmailSendTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testTextMailWithFileAttachmentsByPath() throws Exception {
  HashMap<String, Object> vars = new HashMap<String, Object>();
  vars.put("attachmentsBean", new AttachmentsBean());
  runtimeService.startProcessInstanceByKey("textMailWithFileAttachmentsByPath", 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);
  }
}
 
Example #8
Source File: EmailSendTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #9
Source File: EmailServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testSimpleTextMailWhenMultiTenant() throws Exception {
  String tenantId = "myEmailTenant";

  org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment()
      .addClasspathResource("org/activiti5/engine/test/bpmn/mail/EmailSendTaskTest.testSimpleTextMail.bpmn20.xml")
      .tenantId(tenantId)
      .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE)
      .deploy();
  String procId = runtimeService.startProcessInstanceByKeyAndTenantId("simpleTextOnly", tenantId).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.", "[email protected]",
      Arrays.asList("[email protected]"), null);
  assertProcessEnded(procId);

  repositoryService.deleteDeployment(deployment.getId(), true);
}
 
Example #10
Source File: AsyncEmailTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testSimpleTextMail() throws Exception {
  String procId = runtimeService.startProcessInstanceByKey("simpleTextOnly").getId();

  List<WiserMessage> messages = wiser.getMessages();
  assertEquals(0, messages.size());

  waitForJobExecutorToProcessAllJobs(5000L, 25L);

  messages = wiser.getMessages();
  assertEquals(1, messages.size());

  WiserMessage message = messages.get(0);
  EmailServiceTaskTest.assertEmailSend(message, false, "Hello Kermit!", "This a text only e-mail.", "activiti@localhost", Collections.singletonList("[email protected]"), null);
  assertProcessEnded(procId);
}
 
Example #11
Source File: AsyncEmailTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testSimpleTextMailSendTask() throws Exception {
  runtimeService.startProcessInstanceByKey("simpleTextOnly");

  List<WiserMessage> messages = wiser.getMessages();
  assertEquals(0, messages.size());

  waitForJobExecutorToProcessAllJobs(5000L, 25L);

  messages = wiser.getMessages();
  assertEquals(1, messages.size());

  WiserMessage message = messages.get(0);
  EmailServiceTaskTest.assertEmailSend(message, false, "Hello Kermit!", "This a text only e-mail.", "activiti@localhost", Collections.singletonList(
          "[email protected]"), null);
}
 
Example #12
Source File: AsyncEmailTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testSimpleTextMail() throws Exception {
  String procId = runtimeService.startProcessInstanceByKey("simpleTextOnly").getId();
  
  List<WiserMessage> messages = wiser.getMessages();
  assertEquals(0, messages.size());
  
  waitForJobExecutorToProcessAllJobs(5000L, 25L);
  
  messages = wiser.getMessages();
  assertEquals(1, messages.size());
  
  WiserMessage message = messages.get(0);
  EmailServiceTaskTest.assertEmailSend(message, false, "Hello Kermit!", "This a text only e-mail.", "activiti@localhost",
          Arrays.asList("[email protected]"), null);
  assertProcessEnded(procId);
}
 
Example #13
Source File: AsyncEmailTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testSimpleTextMailSendTask() throws Exception {
  runtimeService.startProcessInstanceByKey("simpleTextOnly");
  
  List<WiserMessage> messages = wiser.getMessages();
  assertEquals(0, messages.size());
  
  waitForJobExecutorToProcessAllJobs(5000L, 25L);
  
  messages = wiser.getMessages();
  assertEquals(1, messages.size());
  
  WiserMessage message = messages.get(0);
  EmailServiceTaskTest.assertEmailSend(message, false, "Hello Kermit!", "This a text only e-mail.", "activiti@localhost",
          Arrays.asList("[email protected]"), null);
}
 
Example #14
Source File: EmailSendTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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);
  }
}
 
Example #15
Source File: EmailSendTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testTextMailExpressions() throws Exception {
  
  String sender = "[email protected]";
  String recipient = "[email protected]";
  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);
}
 
Example #16
Source File: EmailSendTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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("[email protected]", recipients.get(0));
  assertEquals("[email protected]", recipients.get(1));
  assertEquals("[email protected]", recipients.get(2));
}
 
Example #17
Source File: EmailServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testSimpleTextMailWhenMultiTenant() throws Exception {
  String tenantId = "myEmailTenant";

  org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment()
      .addClasspathResource("org/activiti/engine/test/bpmn/mail/EmailSendTaskTest.testSimpleTextMail.bpmn20.xml").tenantId(tenantId).deploy();
  String procId = runtimeService.startProcessInstanceByKeyAndTenantId("simpleTextOnly", tenantId).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.", "[email protected]", Collections.singletonList(
                          "[email protected]"), null);
  assertProcessEnded(procId);

  repositoryService.deleteDeployment(deployment.getId(), true);
}
 
Example #18
Source File: EmailServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void testSimpleTextMailForNonExistentTenant() throws Exception {
  String tenantId = "nonExistentTenant";

  org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment()
      .addClasspathResource("org/activiti/engine/test/bpmn/mail/EmailSendTaskTest.testSimpleTextMail.bpmn20.xml").tenantId(tenantId).deploy();
  String procId = runtimeService.startProcessInstanceByKeyAndTenantId("simpleTextOnly", tenantId).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", Collections.singletonList(
                          "[email protected]"), null);
  assertProcessEnded(procId);

  repositoryService.deleteDeployment(deployment.getId(), true);
}
 
Example #19
Source File: EmailServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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("[email protected]", recipients.get(0));
  assertEquals("[email protected]", recipients.get(1));
  assertEquals("[email protected]", recipients.get(2));
}
 
Example #20
Source File: EmailServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testTextMailExpressions() throws Exception {

  String sender = "[email protected]";
  String recipient = "[email protected]";
  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, Collections.singletonList(
                          recipient), null);
}
 
Example #21
Source File: EmailSendTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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);
  }
}
 
Example #22
Source File: EmailServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testTextMailExpressions() throws Exception {

  String sender = "[email protected]";
  String recipient = "[email protected]";
  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);
}
 
Example #23
Source File: EmailServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #24
Source File: EmailServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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);
  }
}
 
Example #25
Source File: EmailServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testTextMailWithFileAttachmentsByPath() throws Exception {
  HashMap<String, Object> vars = new HashMap<String, Object>();
  vars.put("attachmentsBean", new AttachmentsBean());
  runtimeService.startProcessInstanceByKey("textMailWithFileAttachmentsByPath", 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);
  }
}
 
Example #26
Source File: EmailServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #27
Source File: EmailServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testTextMailWithFileAttachmentsByPath() throws Exception {
  HashMap<String, Object> vars = new HashMap<String, Object>();
  vars.put("attachmentsBean", new AttachmentsBean());
  runtimeService.startProcessInstanceByKey("textMailWithFileAttachmentsByPath", 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);
  }
}
 
Example #28
Source File: EmailServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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);
  }
}
 
Example #29
Source File: EmailSendTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment
public void testTextMailExpressions() throws Exception {

  String sender = "[email protected]";
  String recipient = "[email protected]";
  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,
                  Collections.singletonList(recipient), null);
}
 
Example #30
Source File: EmailSendTaskTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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("[email protected]", recipients.get(0));
  assertEquals("[email protected]", recipients.get(1));
  assertEquals("[email protected]", recipients.get(2));
}