use of org.nhindirect.monitor.condition.TxCompletionCondition in project nhin-d by DirectProject.
the class BasicTxAggregator_isCompleteTest method testIsComplete_emptyTxs_assertFalse.
@Test
public void testIsComplete_emptyTxs_assertFalse() {
TxCompletionCondition condition = mock(TxCompletionCondition.class);
BasicTxAggregator aggr = new BasicTxAggregator(condition, null);
Message msg = mock(Message.class);
when(msg.getBody(Collection.class)).thenReturn(null);
Exchange exchange = mock(Exchange.class);
when(exchange.getIn()).thenReturn(msg);
assertFalse(aggr.isAggregationComplete(exchange));
}
use of org.nhindirect.monitor.condition.TxCompletionCondition in project nhin-d by DirectProject.
the class BasicTxAggregator_aggregateTest method testAggregate_emptyExchanged_addTx.
@Test
public void testAggregate_emptyExchanged_addTx() {
TxTimeoutCondition timoutCondition = mock(TxTimeoutCondition.class);
TxCompletionCondition condition = mock(TxCompletionCondition.class);
BasicTxAggregator aggr = new BasicTxAggregator(condition, timoutCondition);
CamelContext context = mock(CamelContext.class);
DefaultExchange newExchange = new DefaultExchange(context);
Tx tx = mock(Tx.class);
newExchange.getIn().setBody(tx);
Exchange ex = aggr.aggregate(null, newExchange);
@SuppressWarnings("unchecked") Collection<Tx> txs = ex.getIn().getBody(Collection.class);
assertEquals(1, txs.size());
assertEquals(tx, txs.iterator().next());
}
use of org.nhindirect.monitor.condition.TxCompletionCondition in project nhin-d by DirectProject.
the class BasicTxAggregator_constructionTest method costructAggregator.
@Test
public void costructAggregator() {
TxTimeoutCondition timoutCondition = mock(TxTimeoutCondition.class);
TxCompletionCondition condition = mock(TxCompletionCondition.class);
BasicTxAggregator aggr = new BasicTxAggregator(condition, timoutCondition);
assertNotNull(aggr);
assertEquals(timoutCondition, aggr.timeoutCondition);
assertEquals(condition, aggr.completionCondition);
}
use of org.nhindirect.monitor.condition.TxCompletionCondition in project nhin-d by DirectProject.
the class BasicTxAggregator_isCompleteTest method testIsComplete_txsExists_assertTrue.
@SuppressWarnings("unchecked")
@Test
public void testIsComplete_txsExists_assertTrue() {
TxCompletionCondition condition = mock(TxCompletionCondition.class);
when(condition.isComplete((Collection<Tx>) any())).thenReturn(true);
BasicTxAggregator aggr = new BasicTxAggregator(condition, null);
Tx tx = mock(Tx.class);
Collection<Tx> oldTxs = new ArrayList<Tx>();
oldTxs.add(tx);
Message msg = mock(Message.class);
when(msg.getBody(Collection.class)).thenReturn(oldTxs);
Exchange exchange = mock(Exchange.class);
when(exchange.getIn()).thenReturn(msg);
assertTrue(aggr.isAggregationComplete(exchange));
}
use of org.nhindirect.monitor.condition.TxCompletionCondition in project nhin-d by DirectProject.
the class BasicTxAggregator_isCompleteTest method testIsComplete_txsExists_assertFalse.
@SuppressWarnings("unchecked")
@Test
public void testIsComplete_txsExists_assertFalse() {
TxCompletionCondition condition = mock(TxCompletionCondition.class);
when(condition.isComplete((Collection<Tx>) any())).thenReturn(false);
BasicTxAggregator aggr = new BasicTxAggregator(condition, null);
Tx tx = mock(Tx.class);
Collection<Tx> oldTxs = new ArrayList<Tx>();
oldTxs.add(tx);
Message msg = mock(Message.class);
when(msg.getBody(Collection.class)).thenReturn(oldTxs);
Exchange exchange = mock(Exchange.class);
when(exchange.getIn()).thenReturn(msg);
assertFalse(aggr.isAggregationComplete(exchange));
}
Aggregations