Search in sources :

Example 1 with DefaultDSNFailureTextBodyPartGenerator

use of org.nhindirect.common.mail.dsn.impl.DefaultDSNFailureTextBodyPartGenerator in project nhin-d by DirectProject.

the class DSNMessageGenerator_generateDSNFailureMessageTest method createGenerator.

DSNMessageGenerator createGenerator() {
    DSNGenerator dsnGenerator = new DSNGenerator("Not Delivered:");
    TxCompletionCondition checker = new GeneralCompletionCondition();
    DSNFailureTextBodyPartGenerator textGenerator = new DefaultDSNFailureTextBodyPartGenerator("", "", "", "", "", HumanReadableTextAssemblerFactory.getInstance());
    return new DSNMessageGenerator(dsnGenerator, "postmaster", checker, "JUnitMTA", textGenerator);
}
Also used : TxCompletionCondition(org.nhindirect.monitor.condition.TxCompletionCondition) GeneralCompletionCondition(org.nhindirect.monitor.condition.impl.GeneralCompletionCondition) DSNGenerator(org.nhindirect.common.mail.dsn.DSNGenerator) DefaultDSNFailureTextBodyPartGenerator(org.nhindirect.common.mail.dsn.impl.DefaultDSNFailureTextBodyPartGenerator) DSNFailureTextBodyPartGenerator(org.nhindirect.common.mail.dsn.DSNFailureTextBodyPartGenerator) DefaultDSNFailureTextBodyPartGenerator(org.nhindirect.common.mail.dsn.impl.DefaultDSNFailureTextBodyPartGenerator)

Example 2 with DefaultDSNFailureTextBodyPartGenerator

use of org.nhindirect.common.mail.dsn.impl.DefaultDSNFailureTextBodyPartGenerator in project nhin-d by DirectProject.

the class DNSGenerator_CreateDSNMessageTest method testCreateDSNMessage_createGeneralDSNMessage.

@Test
public void testCreateDSNMessage_createGeneralDSNMessage() throws Exception {
    final DSNGenerator dsnGenerator = new DSNGenerator("Not Delivered:");
    final DSNRecipientHeaders dsnRecipHeaders = new DSNRecipientHeaders(DSNAction.FAILED, DSNStatus.getStatus(DSNStatus.PERMANENT, DSNStatus.UNDEFINED_STATUS), new InternetAddress("ah4626@test.com"));
    final List<DSNRecipientHeaders> dsnHeaders = new ArrayList<DSNRecipientHeaders>();
    dsnHeaders.add(dsnRecipHeaders);
    final String originalMessageId = UUID.randomUUID().toString();
    final DSNMessageHeaders messageDSNHeaders = new DSNMessageHeaders("DirectJUNIT", originalMessageId, MtaNameType.DNS);
    List<Address> faileRecips = new ArrayList<Address>();
    faileRecips.add(new InternetAddress("ah4626@test.com"));
    final DefaultDSNFailureTextBodyPartGenerator textGenerator = new DefaultDSNFailureTextBodyPartGenerator("", "", "", "", "", HumanReadableTextAssemblerFactory.getInstance());
    final MimeBodyPart textBodyPart = textGenerator.generate(new InternetAddress("gm2552@test.com"), faileRecips, null);
    MimeMessage dsnMessage = dsnGenerator.createDSNMessage(new InternetAddress("gm2552@test.com"), "test", new InternetAddress("postmaster@test.com"), dsnHeaders, messageDSNHeaders, textBodyPart);
    assertNotNull(dsnMessage);
    assertEquals("postmaster@test.com", MailStandard.getHeader(dsnMessage, MailStandard.Headers.From));
    assertEquals("gm2552@test.com", MailStandard.getHeader(dsnMessage, MailStandard.Headers.To));
    assertTrue(MailStandard.getHeader(dsnMessage, MailStandard.Headers.Subject).startsWith("Not Delivered:"));
    assertTrue(!MailStandard.getHeader(dsnMessage, MailStandard.Headers.Date).isEmpty());
}
Also used : InternetAddress(javax.mail.internet.InternetAddress) Address(javax.mail.Address) InternetAddress(javax.mail.internet.InternetAddress) MimeMessage(javax.mail.internet.MimeMessage) ArrayList(java.util.ArrayList) DefaultDSNFailureTextBodyPartGenerator(org.nhindirect.common.mail.dsn.impl.DefaultDSNFailureTextBodyPartGenerator) MimeBodyPart(javax.mail.internet.MimeBodyPart) Test(org.junit.Test)

Aggregations

DefaultDSNFailureTextBodyPartGenerator (org.nhindirect.common.mail.dsn.impl.DefaultDSNFailureTextBodyPartGenerator)2 ArrayList (java.util.ArrayList)1 Address (javax.mail.Address)1 InternetAddress (javax.mail.internet.InternetAddress)1 MimeBodyPart (javax.mail.internet.MimeBodyPart)1 MimeMessage (javax.mail.internet.MimeMessage)1 Test (org.junit.Test)1 DSNFailureTextBodyPartGenerator (org.nhindirect.common.mail.dsn.DSNFailureTextBodyPartGenerator)1 DSNGenerator (org.nhindirect.common.mail.dsn.DSNGenerator)1 TxCompletionCondition (org.nhindirect.monitor.condition.TxCompletionCondition)1 GeneralCompletionCondition (org.nhindirect.monitor.condition.impl.GeneralCompletionCondition)1