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());
}
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
}
}
}
}
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));
}
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);
}
}
}
}
}
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));
}
Aggregations