Search in sources :

Example 6 with TxDetail

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

the class TxUtil_isRelAndTimelyTest method testIsTimelyAndRequired_MDNOptionForTimely_assertTrue.

@Test
public void testIsTimelyAndRequired_MDNOptionForTimely_assertTrue() {
    Map<String, TxDetail> details = new HashMap<String, TxDetail>();
    details.put(TxDetailType.DISPOSITION_OPTIONS.getType(), new TxDetail(TxDetailType.DISPOSITION_OPTIONS, MDNStandard.DispositionOption_TimelyAndReliable));
    Tx msg = new Tx(TxMessageType.IMF, details);
    assertTrue(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 7 with TxDetail

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

the class TxUtil_isRelAndTimelyTest method testIsTimelyAndRequired_caseInsensitiveOption_MDNOptionForTimely_assertTrue.

@Test
public void testIsTimelyAndRequired_caseInsensitiveOption_MDNOptionForTimely_assertTrue() {
    Map<String, TxDetail> details = new HashMap<String, TxDetail>();
    details.put(TxDetailType.DISPOSITION_OPTIONS.getType(), new TxDetail(TxDetailType.DISPOSITION_OPTIONS, MDNStandard.DispositionOption_TimelyAndReliable.toLowerCase()));
    Tx msg = new Tx(TxMessageType.IMF, details);
    assertTrue(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 8 with TxDetail

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

the class DefaultTxDetailParser_getMessageDetails_OptionalInputsTest method testGetMessageDetails_getReportExtension_lowercaseOption_assertdispostionOption.

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

Example 9 with TxDetail

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

the class DefaultTxDetailParser_getMessageDetails_OptionalInputsTest method testGetMessageDetails_getReportExtension_dispostionOption.

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

Example 10 with TxDetail

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

the class DefaultTxDetailParser_getMimeMessageDetailsTest method testGetMessageDetails_mutlipleFroms.

@Test
public void testGetMessageDetails_mutlipleFroms() throws Exception {
    final MimeMessage msg = TestUtils.readMimeMessageFromFile("MessageWithAttachment.txt");
    msg.setHeader(MailStandard.Headers.From, "gm2552@cerner.com,ah4626@cerner.com");
    final DefaultTxDetailParser parser = new DefaultTxDetailParser();
    final Map<String, TxDetail> details = parser.getMessageDetails(msg);
    assertEquals(MailStandard.getHeader(msg, MailStandard.Headers.From).toLowerCase(Locale.getDefault()), details.get(TxDetailType.FROM.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