use of org.nhindirect.common.tx.model.Tx in project nhin-d by DirectProject.
the class ExchangeToTxCollectionConverter_toTxCollectionTest method testToTxCollection_convertExchangeToTxCollection.
@Test
public void testToTxCollection_convertExchangeToTxCollection() {
Collection<Tx> txs = new ArrayList<Tx>();
Tx tx = mock(Tx.class);
txs.add(tx);
Exchange exchange = new DefaultExchange(mock(CamelContext.class));
exchange.getIn().setBody(txs);
Collection<Tx> retrievedTxs = ExchangeToTxCollectionConverter.toTxCollection(exchange);
assertEquals(txs, retrievedTxs);
}
use of org.nhindirect.common.tx.model.Tx in project nhin-d by DirectProject.
the class TimelyAndReliableCompletionCondition_isCompleteTest method testIsComplete_noFinalRecips_assertFalse.
@Test
public void testIsComplete_noFinalRecips_assertFalse() {
TimelyAndReliableCompletionCondition condition = new TimelyAndReliableCompletionCondition();
Map<String, TxDetail> details = new HashMap<String, TxDetail>();
String msgId = UUID.randomUUID().toString();
details.put(TxDetailType.MSG_ID.getType(), new TxDetail(TxDetailType.MSG_ID, msgId));
Tx tx = new Tx(TxMessageType.IMF, details);
List<Tx> txs = Arrays.asList(tx);
assertFalse(condition.isComplete(txs));
}
use of org.nhindirect.common.tx.model.Tx in project nhin-d by DirectProject.
the class TimelyAndReliableCompletionCondition_isCompleteTest method testIsComplete_failedDSNAction_finalRecipNotInOriginalMessage_assertFalse.
@Test
public void testIsComplete_failedDSNAction_finalRecipNotInOriginalMessage_assertFalse() {
TimelyAndReliableCompletionCondition condition = new TimelyAndReliableCompletionCondition();
// original message
final String originalMessageId = UUID.randomUUID().toString();
Tx originalMessage = TestUtils.makeMessage(TxMessageType.IMF, originalMessageId, "", "gm2552@cerner.com", "gm2552@direct.securehealthemail.com", "");
// MDN to original message, no reliable headers
Tx mdnMessage = TestUtils.makeMessage(TxMessageType.DSN, UUID.randomUUID().toString(), originalMessageId, "gm2552@direct.securehealthemail.com", "gm2552@cerner.com", "me@test.com", DSNStandard.DSNAction.FAILED.toString(), "");
List<Tx> txs = Arrays.asList(originalMessage, mdnMessage);
assertFalse(condition.isComplete(txs));
}
use of org.nhindirect.common.tx.model.Tx in project nhin-d by DirectProject.
the class VariableCompletionCondition_isCompleteTest method testIsComplete_isNotTimely_assertNotComplete.
@SuppressWarnings("unchecked")
@Test
public void testIsComplete_isNotTimely_assertNotComplete() {
TxCompletionCondition timelyCond = mock(TxCompletionCondition.class);
when(timelyCond.isComplete((Collection<Tx>) any())).thenReturn(true);
TxCompletionCondition generalCond = mock(TxCompletionCondition.class);
VariableCompletionCondition cond = new VariableCompletionCondition(timelyCond, generalCond);
VariableCompletionCondition spy = spy(cond);
Tx msgToTrack = mock(Tx.class);
when(spy.getMessageToTrackInternal((Collection<Tx>) any())).thenReturn(msgToTrack);
when(spy.isRelAndTimelyRequired((Tx) any())).thenReturn(false);
assertFalse(spy.isComplete(null));
verify(timelyCond, never()).isComplete((Collection<Tx>) any());
verify(generalCond, times(1)).isComplete((Collection<Tx>) any());
}
use of org.nhindirect.common.tx.model.Tx in project nhin-d by DirectProject.
the class VariableCompletionCondition_isCompleteTest method testIsComplete_isNotTimely_assertComplete.
@SuppressWarnings("unchecked")
@Test
public void testIsComplete_isNotTimely_assertComplete() {
TxCompletionCondition timelyCond = mock(TxCompletionCondition.class);
TxCompletionCondition generalCond = mock(TxCompletionCondition.class);
when(generalCond.isComplete((Collection<Tx>) any())).thenReturn(true);
VariableCompletionCondition cond = new VariableCompletionCondition(timelyCond, generalCond);
VariableCompletionCondition spy = spy(cond);
Tx msgToTrack = mock(Tx.class);
when(spy.getMessageToTrackInternal((Collection<Tx>) any())).thenReturn(msgToTrack);
when(spy.isRelAndTimelyRequired((Tx) any())).thenReturn(false);
assertTrue(spy.isComplete(null));
verify(timelyCond, never()).isComplete((Collection<Tx>) any());
verify(generalCond, times(1)).isComplete((Collection<Tx>) any());
}
Aggregations