use of org.nhindirect.common.tx.model.Tx in project nhin-d by DirectProject.
the class TxResource_suppressNotificationTest method testSuppressNotification_mgrException_assert500StatusCode.
@Test
public void testSuppressNotification_mgrException_assert500StatusCode() throws Exception {
Tx tx = mock(Tx.class);
DuplicateNotificationStateManager dupMgr = mock(DuplicateNotificationStateManager.class);
when(dupMgr.suppressNotification(tx)).thenThrow(new DuplicateNotificationStateManagerException());
TxsResource resource = new TxsResource(null, dupMgr);
Response res = resource.supressNotification(tx);
assertEquals(500, res.getStatus());
}
use of org.nhindirect.common.tx.model.Tx in project nhin-d by DirectProject.
the class TestFailedAddUpdateExchangeMonitorRoute method testSingleRecipMDNReceived_assertConditionComplete.
@SuppressWarnings("unchecked")
@Test
public void testSingleRecipMDNReceived_assertConditionComplete() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
// send original message
final String originalMessageId = UUID.randomUUID().toString();
Tx originalMessage = TestUtils.makeMessage(TxMessageType.IMF, originalMessageId, "", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com,ah4626@direct.securehealthemail.com", "");
template.sendBody("direct:start", originalMessage);
// send MDN to original messages
Tx mdnMessage = TestUtils.makeMessage(TxMessageType.MDN, UUID.randomUUID().toString(), originalMessageId, "gm2552@direct.securehealthemail.com", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com");
template.sendBody("direct:start", mdnMessage);
mdnMessage = TestUtils.makeMessage(TxMessageType.MDN, UUID.randomUUID().toString(), originalMessageId, "ah4626@direct.securehealthemail.com", "gm2552@cerner.com", "ah4626@direct.securehealthemail.com");
template.sendBody("direct:start", mdnMessage);
List<Exchange> exchanges = mock.getReceivedExchanges();
assertEquals(1, exchanges.size());
// validate the content of the exchange
Collection<Tx> exBody = (Collection<Tx>) exchanges.iterator().next().getIn().getBody();
assertEquals(3, exBody.size());
}
use of org.nhindirect.common.tx.model.Tx in project nhin-d by DirectProject.
the class TestMultithreadedAddUpdateFailureMonitoringRoute method testMultithreadedMDNResponseHandling_assertAllMDNsHandled.
@SuppressWarnings("unchecked")
@Test
public void testMultithreadedMDNResponseHandling_assertAllMDNsHandled() throws Exception {
final StringBuilder recipBuilder = new StringBuilder();
final Collection<String> recips = new ArrayList<String>();
// create a list of 100 recipients
for (int i = 0; i < 100; ++i) {
final String recip = "recip" + (i + 1) + "@test.com";
recips.add(recip);
recipBuilder.append(recip);
if (i != 99)
recipBuilder.append(",");
}
MockEndpoint mock = getMockEndpoint("mock:result");
// send original message
final String originalMessageId = UUID.randomUUID().toString();
Tx originalMessage = TestUtils.makeMessage(TxMessageType.IMF, originalMessageId, "", "gm2552@cerner.com", recipBuilder.toString(), "");
template.sendBody("seda:start", originalMessage);
// now send the recipient MDN messages
for (String recip : recips) {
// send MDN to original messages
Tx mdnMessage = TestUtils.makeMessage(TxMessageType.MDN, UUID.randomUUID().toString(), originalMessageId, recip, "gm2552@cerner.com", recip);
template.sendBody("seda:start", mdnMessage);
}
boolean exchangeFound = false;
int cnt = 0;
List<Exchange> exchanges = null;
while (cnt < 10) {
exchanges = mock.getReceivedExchanges();
if (exchanges.size() == 1) {
exchangeFound = true;
break;
}
++cnt;
Thread.sleep(2000);
}
assertTrue(exchangeFound);
// validate the content of the exchange
Collection<Tx> exBody = (Collection<Tx>) exchanges.iterator().next().getIn().getBody();
assertEquals(101, exBody.size());
}
use of org.nhindirect.common.tx.model.Tx in project nhin-d by DirectProject.
the class TestRecoveryMonitorRoute method testRecoverFromRepository.
@Test
public void testRecoverFromRepository() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
boolean exchangeFound = false;
int cnt = 0;
List<Exchange> exchanges = null;
while (cnt < 10) {
exchanges = mock.getReceivedExchanges();
if (exchanges.size() == 1) {
exchangeFound = true;
break;
}
++cnt;
Thread.sleep(2000);
}
assertTrue(exchangeFound);
Tx originalMessage = (Tx) exchanges.iterator().next().getIn().getBody();
assertEquals("gm2552@cerner.com", originalMessage.getDetail(TxDetailType.FROM).getDetailValue());
// make sure everything got confirmed
final AggregationDAO dao = (AggregationDAO) context.getRegistry().lookup("aggregationDAO");
assertEquals(0, dao.getAggregationKeys().size());
assertEquals(0, dao.getAggregationCompletedKeys().size());
}
use of org.nhindirect.common.tx.model.Tx in project nhin-d by DirectProject.
the class TestRecoveryMonitorRoute method postProcessTest.
@Override
public void postProcessTest() throws Exception {
super.postProcessTest();
final AggregationDAO dao = (AggregationDAO) context.getRegistry().lookup("shortRecoveryIntervalAggregationDAO");
dao.purgeAll();
assertEquals(0, dao.getAggregationKeys().size());
assertEquals(0, dao.getAggregationCompletedKeys().size());
// pre populate some recovery data
// send original message
final String originalMessageId = UUID.randomUUID().toString();
final Tx originalMessage = TestUtils.makeMessage(TxMessageType.IMF, originalMessageId, "", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com,ah4626@direct.securehealthemail.com", "");
final Exchange exchange = new DefaultExchange(context);
exchange.getIn().setBody(originalMessage);
final ConcurrentJPAAggregationRepository repo = (ConcurrentJPAAggregationRepository) context.getRegistry().lookup("monitoringRepo");
repo.add(context, originalMessageId, exchange);
repo.remove(context, originalMessageId, exchange);
// lock the row to create a delay and ensure we recover
// exchange ids that return null at some point
repo.recover(context, exchange.getExchangeId());
}
Aggregations