Search in sources :

Example 61 with TxDetail

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

the class TestNonReliableMessageMonitorRoute method testSingleRecipMDNReceived_readFromMessages_assertConditionComplete.

@Test
public void testSingleRecipMDNReceived_readFromMessages_assertConditionComplete() throws Exception {
    final DefaultTxDetailParser parser = new DefaultTxDetailParser();
    final Map<String, TxDetail> imfDetails = parser.getMessageDetails(TestUtils.readMimeMessageFromFile("MessageFromCernerToAthena.txt"));
    final Map<String, TxDetail> mdnDetails = parser.getMessageDetails(TestUtils.readMimeMessageFromFile("MDNFromAthenaToCerner"));
    MockEndpoint mock = getMockEndpoint("mock:result");
    // send original message
    Tx originalMessage = new Tx(TxMessageType.IMF, imfDetails);
    template.sendBody("direct:start", originalMessage);
    // send MDN to original message
    Tx mdnMessage = new Tx(TxMessageType.MDN, mdnDetails);
    template.sendBody("direct:start", mdnMessage);
    List<Exchange> exchanges = mock.getReceivedExchanges();
    assertEquals(1, exchanges.size());
}
Also used : Exchange(org.apache.camel.Exchange) Tx(org.nhindirect.common.tx.model.Tx) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) TxDetail(org.nhindirect.common.tx.model.TxDetail) DefaultTxDetailParser(org.nhindirect.common.tx.impl.DefaultTxDetailParser) Test(org.junit.Test)

Example 62 with TxDetail

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

the class TimeoutDupStateManager method addNotificationForOriginalRecips.

/**
	 * Adds a duplication state entry for each recipient of the original message
	 * @param txs Collection of message transactions.  The original message must be present in the collection
	 * @throws DuplicateNotificationStateManagerException
	 */
public void addNotificationForOriginalRecips(Collection<Tx> txs) throws DuplicateNotificationStateManagerException {
    if (dao == null)
        throw new IllegalArgumentException("Dao cannot be null");
    if (txs == null)
        throw new IllegalArgumentException("Txs cannot be null");
    final Tx tx = AbstractCompletionCondition.getMessageToTrack(txs);
    if (tx != null && TxUtil.isReliableAndTimelyRequested(tx)) {
        final TxDetail recipDetail = tx.getDetail(TxDetailType.RECIPIENTS);
        final TxDetail msgId = tx.getDetail(TxDetailType.MSG_ID);
        if (recipDetail != null && msgId != null) {
            final String[] recips = recipDetail.getDetailValue().split(",");
            for (String recip : recips) {
                try {
                    final String normalizedFinalRecip = AbstractCompletionCondition.normalizeFinalRecip(recip);
                    dao.addNotification(msgId.getDetailValue(), normalizedFinalRecip);
                }///CLOVER:OFF
                 catch (NotificationDAOException e) {
                    LOGGER.warn("Can't add recipient " + recip + " for message id " + msgId.getDetailValue() + " to dup store.  Possibly already exists in dup store.");
                }
            ///CLOVER:ON
            }
        }
    }
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) TxDetail(org.nhindirect.common.tx.model.TxDetail) NotificationDAOException(org.nhindirect.monitor.dao.NotificationDAOException)

Example 63 with TxDetail

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

the class AbstractCompletionCondition_getMessageToTrackTest method testGetMessageToTrack_noIMF_assertNull.

@Test
public void testGetMessageToTrack_noIMF_assertNull() {
    ConditionAdapter condition = new ConditionAdapter();
    Tx tx = new Tx(TxMessageType.DSN, new HashMap<String, TxDetail>());
    List<Tx> txs = Arrays.asList(tx);
    assertNull(condition.getMessageToTrackInternal(txs));
}
Also used : Tx(org.nhindirect.common.tx.model.Tx) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 64 with TxDetail

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

the class DefaultDuplicateNotificationStateManager method addNotification.

/**
	 * {@inheritDoc}
	 */
@Override
public void addNotification(Tx notificationMessage) throws DuplicateNotificationStateManagerException {
    if (dao == null)
        throw new IllegalArgumentException("Dao cannot be null");
    if (notificationMessage == null)
        throw new IllegalArgumentException("Notification message cannot be null");
    final TxMessageType type = notificationMessage.getMsgType();
    if (type == TxMessageType.DSN || type == TxMessageType.MDN) {
        final TxDetail originalMessageIdDetail = notificationMessage.getDetail(TxDetailType.PARENT_MSG_ID);
        final TxDetail origRecips = notificationMessage.getDetail(TxDetailType.FINAL_RECIPIENTS);
        if (originalMessageIdDetail != null && origRecips != null) {
            for (String recipAddress : origRecips.getDetailValue().split(",")) {
                try {
                    dao.addNotification(originalMessageIdDetail.getDetailValue(), recipAddress);
                } catch (NotificationDAOException e) {
                    throw new DuplicateNotificationStateManagerException(e);
                }
            }
        }
    }
}
Also used : TxDetail(org.nhindirect.common.tx.model.TxDetail) NotificationDAOException(org.nhindirect.monitor.dao.NotificationDAOException) DuplicateNotificationStateManagerException(org.nhindirect.monitor.processor.DuplicateNotificationStateManagerException) TxMessageType(org.nhindirect.common.tx.model.TxMessageType)

Example 65 with TxDetail

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

the class VariableCompletionCondition_isTimelyAndRequiredTest method testIsTimelyAndRequired_emptyDetails_assertFalse.

@Test
public void testIsTimelyAndRequired_emptyDetails_assertFalse() {
    TxCompletionCondition cond1 = mock(TxCompletionCondition.class);
    TxCompletionCondition cond2 = mock(TxCompletionCondition.class);
    VariableCompletionCondition cond = new VariableCompletionCondition(cond1, cond2);
    Tx msg = new Tx(TxMessageType.IMF, new HashMap<String, TxDetail>());
    assertFalse(cond.isRelAndTimelyRequired(msg));
}
Also used : TxCompletionCondition(org.nhindirect.monitor.condition.TxCompletionCondition) Tx(org.nhindirect.common.tx.model.Tx) 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