use of org.nhindirect.monitor.condition.TxCompletionCondition in project nhin-d by DirectProject.
the class VariableCompletionCondition_constructionTest method testConstruction_nullTimelyCondition_assertException.
@Test
public void testConstruction_nullTimelyCondition_assertException() {
TxCompletionCondition cond = mock(TxCompletionCondition.class);
boolean exceptionOccured = false;
try {
new VariableCompletionCondition(null, cond);
} catch (IllegalArgumentException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.monitor.condition.TxCompletionCondition in project nhin-d by DirectProject.
the class VariableCompletionCondition_constructionTest method testConstruction_nullGeneralCondition_assertException.
@Test
public void testConstruction_nullGeneralCondition_assertException() {
TxCompletionCondition cond = mock(TxCompletionCondition.class);
boolean exceptionOccured = false;
try {
new VariableCompletionCondition(cond, null);
} catch (IllegalArgumentException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.monitor.condition.TxCompletionCondition 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.monitor.condition.TxCompletionCondition 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());
}
use of org.nhindirect.monitor.condition.TxCompletionCondition in project nhin-d by DirectProject.
the class BasicTxAggregator_aggregateTest method testAggregate_singleEntryExchanged_addSingleTx.
@Test
public void testAggregate_singleEntryExchanged_addSingleTx() {
TxTimeoutCondition timoutCondition = mock(TxTimeoutCondition.class);
TxCompletionCondition condition = mock(TxCompletionCondition.class);
BasicTxAggregator aggr = new BasicTxAggregator(condition, timoutCondition);
CamelContext context = mock(CamelContext.class);
DefaultExchange oldExchange = new DefaultExchange(context);
Tx tx = mock(Tx.class);
Collection<Tx> oldTxs = new ArrayList<Tx>();
oldTxs.add(tx);
oldExchange.getIn().setBody(oldTxs);
DefaultExchange newExchange = new DefaultExchange(context);
tx = mock(Tx.class);
newExchange.getIn().setBody(tx);
Exchange ex = aggr.aggregate(oldExchange, newExchange);
@SuppressWarnings("unchecked") Collection<Tx> txs = ex.getIn().getBody(Collection.class);
assertEquals(2, txs.size());
}
Aggregations