Search in sources :

Example 46 with TxDetail

use of org.nhindirect.common.tx.model.TxDetail in project nhin-d by DirectProject.

the class DefaultTxDetailParser_getMimeMessageDetailsTest method testGetMessageDetails_ToAndCC.

@Test
public void testGetMessageDetails_ToAndCC() throws Exception {
    final MimeMessage msg = TestUtils.readMimeMessageFromFile("MessageWithAttachment.txt");
    msg.setHeader(MailStandard.Headers.To, "gm2552@cerner.com");
    msg.setHeader(MailStandard.Headers.CC, "ah4626@cerner.com");
    final DefaultTxDetailParser parser = new DefaultTxDetailParser();
    final Map<String, TxDetail> details = parser.getMessageDetails(msg);
    assertEquals("gm2552@cerner.com,ah4626@cerner.com", details.get(TxDetailType.RECIPIENTS.getType()).getDetailValue());
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 47 with TxDetail

use of org.nhindirect.common.tx.model.TxDetail in project nhin-d by DirectProject.

the class DefaultTxDetailParser_getMimeMessageDetailsTest method testGetMessageDetails_generalDNSMessage_noOrigMessageId.

@Test
public void testGetMessageDetails_generalDNSMessage_noOrigMessageId() throws Exception {
    final MimeMessage msg = TestUtils.readMimeMessageFromFile("DSNMessageOrigInReplyTo.txt");
    msg.setHeader(MailStandard.Headers.InReplyTo, "");
    final DefaultTxDetailParser parser = new DefaultTxDetailParser();
    final Map<String, TxDetail> details = parser.getMessageDetails(msg);
    assertNull(details.get(TxDetailType.PARENT_MSG_ID.getType()));
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 48 with TxDetail

use of org.nhindirect.common.tx.model.TxDetail in project nhin-d by DirectProject.

the class TestUtils method makeReliableMessage.

public static Tx makeReliableMessage(TxMessageType type, String msgId, String parentId, String from, String recip, String finalRecip, String action, String disposition) {
    Map<String, TxDetail> details = new HashMap<String, TxDetail>();
    if (msgId != null && !msgId.isEmpty())
        details.put(TxDetailType.MSG_ID.getType(), new TxDetail(TxDetailType.MSG_ID, msgId));
    if (parentId != null && !parentId.isEmpty())
        details.put(TxDetailType.PARENT_MSG_ID.getType(), new TxDetail(TxDetailType.PARENT_MSG_ID, parentId));
    if (from != null && !from.isEmpty())
        details.put(TxDetailType.FROM.getType(), new TxDetail(TxDetailType.FROM, from));
    if (recip != null && !recip.isEmpty())
        details.put(TxDetailType.RECIPIENTS.getType(), new TxDetail(TxDetailType.RECIPIENTS, recip));
    if (finalRecip != null && !finalRecip.isEmpty())
        details.put(TxDetailType.FINAL_RECIPIENTS.getType(), new TxDetail(TxDetailType.FINAL_RECIPIENTS, finalRecip));
    if (action != null && !action.isEmpty())
        details.put(TxDetailType.DSN_ACTION.getType(), new TxDetail(TxDetailType.DSN_ACTION, action));
    if (disposition != null && !disposition.isEmpty())
        details.put(TxDetailType.DISPOSITION.getType(), new TxDetail(TxDetailType.DISPOSITION, disposition));
    details.put(TxDetailType.DISPOSITION_OPTIONS.getType(), new TxDetail(TxDetailType.DISPOSITION_OPTIONS, "X-DIRECT-FINAL-DESTINATION-DELIVERY"));
    return new Tx(type, details);
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) HashMap(java.util.HashMap) TxDetail(org.nhindirect.common.tx.model.TxDetail)

Example 49 with TxDetail

use of org.nhindirect.common.tx.model.TxDetail in project nhin-d by DirectProject.

the class TxUtil_isRelAndTimelyTest method testIsTimelyAndRequired_NoMNDOptionDetails_assertFalse.

@Test
public void testIsTimelyAndRequired_NoMNDOptionDetails_assertFalse() {
    Map<String, TxDetail> details = new HashMap<String, TxDetail>();
    details.put(TxDetailType.FROM.getType(), new TxDetail(TxDetailType.FROM, "me@test.com"));
    Tx msg = new Tx(TxMessageType.IMF, details);
    assertFalse(TxUtil.isReliableAndTimelyRequested(msg));
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) HashMap(java.util.HashMap) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 50 with TxDetail

use of org.nhindirect.common.tx.model.TxDetail in project nhin-d by DirectProject.

the class TxUtil_isRelAndTimelyTest method testIsTimelyAndRequired_MDNOptionNotForTimely_assertFalse.

@Test
public void testIsTimelyAndRequired_MDNOptionNotForTimely_assertFalse() {
    Map<String, TxDetail> details = new HashMap<String, TxDetail>();
    details.put(TxDetailType.DISPOSITION_OPTIONS.getType(), new TxDetail(TxDetailType.DISPOSITION_OPTIONS, "X-NOT-TIMELY"));
    Tx msg = new Tx(TxMessageType.IMF, details);
    assertFalse(TxUtil.isReliableAndTimelyRequested(msg));
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) HashMap(java.util.HashMap) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Aggregations

TxDetail (org.nhindirect.common.tx.model.TxDetail)70 Test (org.junit.Test)50 Tx (org.nhindirect.common.tx.model.Tx)35 MimeMessage (javax.mail.internet.MimeMessage)32 HashMap (java.util.HashMap)20 Exchange (org.apache.camel.Exchange)10 CamelContext (org.apache.camel.CamelContext)9 DefaultExchange (org.apache.camel.impl.DefaultExchange)9 ArrayList (java.util.ArrayList)7 TxMessageType (org.nhindirect.common.tx.model.TxMessageType)6 NotificationDAOException (org.nhindirect.monitor.dao.NotificationDAOException)5 InputStream (java.io.InputStream)4 Address (javax.mail.Address)4 InternetAddress (javax.mail.internet.InternetAddress)4 DefaultTxDetailParser (org.nhindirect.common.tx.impl.DefaultTxDetailParser)4 TxCompletionCondition (org.nhindirect.monitor.condition.TxCompletionCondition)4 Header (javax.mail.Header)3 MessagingException (javax.mail.MessagingException)3 MimeBodyPart (javax.mail.internet.MimeBodyPart)3 DSNMessageHeaders (org.nhindirect.common.mail.dsn.DSNMessageHeaders)3