Search in sources :

Example 51 with TxDetail

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

the class TxUtil_isRelAndTimelyTest method testIsTimelyAndRequired_emptyDetails_assertFalse.

@Test
public void testIsTimelyAndRequired_emptyDetails_assertFalse() {
    Tx msg = new Tx(TxMessageType.IMF, new HashMap<String, TxDetail>());
    assertFalse(TxUtil.isReliableAndTimelyRequested(msg));
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 52 with TxDetail

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

the class DefaultTxDetailParser_getMessageDetails_OptionalInputsTest method testGetMessageDetailsFromInputStream_getDetailsFromCommonMessage.

@Test
public void testGetMessageDetailsFromInputStream_getDetailsFromCommonMessage() throws Exception {
    final MimeMessage msg = TestUtils.readMimeMessageFromFile("MessageWithAttachment.txt");
    final InputStream inStream = IOUtils.toInputStream(TestUtils.readMessageFromFile("MessageWithAttachment.txt"));
    try {
        final DefaultTxDetailParser parser = new DefaultTxDetailParser();
        final Map<String, TxDetail> details = parser.getMessageDetails(inStream);
        assertEquals(MailStandard.getHeader(msg, MailStandard.Headers.MessageID), details.get(TxDetailType.MSG_ID.getType()).getDetailValue());
        assertEquals(MailStandard.getHeader(msg, MailStandard.Headers.From).toLowerCase(Locale.getDefault()), details.get(TxDetailType.FROM.getType()).getDetailValue());
        assertEquals(MailStandard.getHeader(msg, MailStandard.Headers.To).toLowerCase(Locale.getDefault()), details.get(TxDetailType.RECIPIENTS.getType()).getDetailValue());
        assertEquals(MailStandard.getHeader(msg, MailStandard.Headers.Subject).toLowerCase(Locale.getDefault()), details.get(TxDetailType.SUBJECT.getType()).getDetailValue());
    } finally {
        IOUtils.closeQuietly(inStream);
    }
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) InputStream(java.io.InputStream) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 53 with TxDetail

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

the class DefaultTxDetailParser_getMessageDetails_OptionalInputsTest method testGetMessageDetails_getReportExtension_noDispostionOption.

@Test
public void testGetMessageDetails_getReportExtension_noDispostionOption() throws Exception {
    final MimeMessage msg = TestUtils.readMimeMessageFromFile("MDNMessage.txt");
    final DefaultTxDetailParser parser = new DefaultTxDetailParser();
    final Map<String, TxDetail> details = parser.getMessageDetails(msg);
    assertNull("X-DIRECT-FINAL-DESTINATION-DELIVERY", details.get(TxDetailType.DISPOSITION_OPTIONS.getType()));
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 54 with TxDetail

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

the class DefaultTxDetailParser_getMessageDetails_OptionalInputsTest method testGetMessageDetailsFromHeaders_getDetailsFromCommonMessage.

@Test
public void testGetMessageDetailsFromHeaders_getDetailsFromCommonMessage() throws Exception {
    final MimeMessage msg = TestUtils.readMimeMessageFromFile("MessageWithAttachment.txt");
    final InputStream inStream = IOUtils.toInputStream(TestUtils.readMessageFromFile("MessageWithAttachment.txt"));
    try {
        final InternetHeaders headers = new InternetHeaders(inStream);
        final DefaultTxDetailParser parser = new DefaultTxDetailParser();
        final Map<String, TxDetail> details = parser.getMessageDetails(headers);
        assertEquals(MailStandard.getHeader(msg, MailStandard.Headers.MessageID), details.get(TxDetailType.MSG_ID.getType()).getDetailValue());
        assertEquals(MailStandard.getHeader(msg, MailStandard.Headers.From).toLowerCase(Locale.getDefault()), details.get(TxDetailType.FROM.getType()).getDetailValue());
        assertEquals(MailStandard.getHeader(msg, MailStandard.Headers.To).toLowerCase(Locale.getDefault()), details.get(TxDetailType.RECIPIENTS.getType()).getDetailValue());
        assertEquals(MailStandard.getHeader(msg, MailStandard.Headers.Subject).toLowerCase(Locale.getDefault()), details.get(TxDetailType.SUBJECT.getType()).getDetailValue());
    } finally {
        IOUtils.closeQuietly(inStream);
    }
}
Also used : InternetHeaders(javax.mail.internet.InternetHeaders) MimeMessage(javax.mail.internet.MimeMessage) InputStream(java.io.InputStream) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 55 with TxDetail

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

the class DefaultTxDetailParser_getMimeMessageDetailsTest method testGetMessageDetails_senderExists.

@Test
public void testGetMessageDetails_senderExists() throws Exception {
    final MimeMessage msg = TestUtils.readMimeMessageFromFile("MessageWithAttachment.txt");
    msg.setHeader(MailStandard.Headers.Sender, "gm2552@cerner.com");
    final DefaultTxDetailParser parser = new DefaultTxDetailParser();
    final Map<String, TxDetail> details = parser.getMessageDetails(msg);
    assertEquals(MailStandard.getHeader(msg, MailStandard.Headers.Sender).toLowerCase(Locale.getDefault()), details.get(TxDetailType.SENDER.getType()).getDetailValue());
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) 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