use of org.nhindirect.common.tx.model.Tx in project nhin-d by DirectProject.
the class TxUtil method isReliableAndTimelyRequested.
/**
* Determines if the message is requesting timely and reliable delivery. This is determined by
* the existence of the X-DIRECT-FINAL-DESTINATION-DELIVERY message disposition option on the original message.
* @param msg The message that is being inspected for timely and reliable messaging.
* @return true if the original message indicates that it requires timely and reliable delivery; false otherwise
*/
public static boolean isReliableAndTimelyRequested(MimeMessage msg) {
if (msg == null)
return false;
final TxDetailParser parser = new DefaultTxDetailParser();
final Map<String, TxDetail> details = parser.getMessageDetails(msg);
final Tx tx = new Tx(getMessageType(msg), details);
return isReliableAndTimelyRequested(tx);
}
use of org.nhindirect.common.tx.model.Tx 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));
}
use of org.nhindirect.common.tx.model.Tx 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));
}
use of org.nhindirect.common.tx.model.Tx in project nhin-d by DirectProject.
the class DSNMessageGenerator_generateDSNFailureMessageTest method testGenerateDSNFailureMessage_fromJson_incomingAndCompleteRecips.
@Test
public void testGenerateDSNFailureMessage_fromJson_incomingAndCompleteRecips() throws Exception {
Exchange exchange = new DefaultExchange(mock(CamelContext.class));
final String json = FileUtils.readFileToString(new File("./src/test/resources/json/multiRecipEmailSingleDNSAndMDN.json"));
final ObjectMapper jsonMapper = new ObjectMapper();
jsonMapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false);
List<Tx> txs = jsonMapper.readValue(json, TypeFactory.collectionType(ArrayList.class, Tx.class));
DSNMessageGenerator generator = createGenerator();
generator.generateDSNFailureMessage(txs, exchange);
MimeMessage dsnMessage = (MimeMessage) exchange.getIn().getBody();
assertNotNull(dsnMessage);
ByteArrayOutputStream oStr = new ByteArrayOutputStream();
dsnMessage.writeTo(oStr);
final String dsnStr = new String(oStr.toByteArray());
assertTrue(dsnStr.contains("gm2552@direct.securehealthemail.com"));
assertFalse(dsnStr.contains("test@aol.com"));
}
use of org.nhindirect.common.tx.model.Tx in project nhin-d by DirectProject.
the class TestTimeoutToDupStateManager method testTimeoutReliableMessage_conditionNotComplete_assertDupAdded.
@Test
public void testTimeoutReliableMessage_conditionNotComplete_assertDupAdded() throws Exception {
NotificationDuplicationDAO dao = context.getRegistry().lookup("notificationDuplicationDAO", NotificationDuplicationDAO.class);
assertNotNull(dao);
purgeNotifDAO(dao);
MockEndpoint mock = getMockEndpoint("mock:result");
// send original message
final String originalMessageId = UUID.randomUUID().toString();
Tx originalMessage = TestUtils.makeReliableMessage(TxMessageType.IMF, originalMessageId, "", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com", "", "", "");
template.sendBody("direct:start", originalMessage);
// no MDN sent... messages should timeout after 2 seconds
// sleep 3 seconds to make sure it completes
Thread.sleep(3000);
List<Exchange> exchanges = mock.getReceivedExchanges();
assertEquals(1, exchanges.size());
Exchange exchange = exchanges.iterator().next();
// make sure there is only 1 message in the exchange
MimeMessage message = exchange.getIn().getBody(MimeMessage.class);
assertNotNull(message);
assertEquals("timeout", exchange.getProperty(Exchange.AGGREGATED_COMPLETED_BY));
Set<String> addresses = dao.getReceivedAddresses(originalMessageId + "\t" + message.getMessageID(), Arrays.asList("gm2552@direct.securehealthemail.com"));
assertEquals(1, addresses.size());
assertTrue(addresses.contains("gm2552@direct.securehealthemail.com"));
addresses = dao.getReceivedAddresses(originalMessageId, Arrays.asList("gm2552@direct.securehealthemail.com"));
assertEquals(1, addresses.size());
assertTrue(addresses.contains("gm2552@direct.securehealthemail.com"));
}
Aggregations