use of org.nhindirect.monitor.condition.TxTimeoutCondition in project nhin-d by DirectProject.
the class VariableTimeoutCondition_constructionTest method testConstruction.
@Test
public void testConstruction() {
TxTimeoutCondition cond1 = mock(TxTimeoutCondition.class);
TxTimeoutCondition cond2 = mock(TxTimeoutCondition.class);
VariableTimeoutCondition cond = new VariableTimeoutCondition(cond1, cond2);
assertEquals(cond1, cond.timelyExpression);
assertEquals(cond2, cond.generalExpression);
}
use of org.nhindirect.monitor.condition.TxTimeoutCondition in project nhin-d by DirectProject.
the class VariableTimeoutCondition_constructionTest method testConstruction_nullTimelyCondition_assertException.
@Test
public void testConstruction_nullTimelyCondition_assertException() {
TxTimeoutCondition cond = mock(TxTimeoutCondition.class);
boolean exceptionOccured = false;
try {
new VariableTimeoutCondition(null, cond);
} catch (IllegalArgumentException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.monitor.condition.TxTimeoutCondition in project nhin-d by DirectProject.
the class VariableTimeoutCondition_constructionTest method testConstruction_nullGeneralCondition_assertException.
@Test
public void testConstruction_nullGeneralCondition_assertException() {
TxTimeoutCondition cond = mock(TxTimeoutCondition.class);
boolean exceptionOccured = false;
try {
new VariableTimeoutCondition(cond, null);
} catch (IllegalArgumentException e) {
exceptionOccured = true;
}
assertTrue(exceptionOccured);
}
use of org.nhindirect.monitor.condition.TxTimeoutCondition in project nhin-d by DirectProject.
the class VariableTimeoutCondition_getTimeoutTest method testGetTimeoutTest_nullMessageToTrack_assertUsesGeneralCondtion.
@SuppressWarnings("unchecked")
@Test
public void testGetTimeoutTest_nullMessageToTrack_assertUsesGeneralCondtion() {
TxTimeoutCondition timelyCond = mock(TxTimeoutCondition.class);
TxTimeoutCondition generalCond = mock(TxTimeoutCondition.class);
VariableTimeoutCondition cond = new VariableTimeoutCondition(timelyCond, generalCond);
VariableTimeoutCondition spy = spy(cond);
when(spy.getMessageToTrack((Collection<Tx>) any())).thenReturn(null);
assertEquals(0, spy.getTimeout(new ArrayList<Tx>(), 1000));
verify(timelyCond, never()).getTimeout((ArrayList<Tx>) any(), eq((long) 1000));
verify(generalCond, times(1)).getTimeout((ArrayList<Tx>) any(), eq((long) 1000));
}
use of org.nhindirect.monitor.condition.TxTimeoutCondition 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