Search in sources :

Example 11 with TxCompletionCondition

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));
}
Also used : TxCompletionCondition(org.nhindirect.monitor.condition.TxCompletionCondition) Exchange(org.apache.camel.Exchange) Message(org.apache.camel.Message) Test(org.junit.Test)

Example 12 with TxCompletionCondition

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());
}
Also used : TxCompletionCondition(org.nhindirect.monitor.condition.TxCompletionCondition) CamelContext(org.apache.camel.CamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) Tx(org.nhindirect.common.tx.model.Tx) TxTimeoutCondition(org.nhindirect.monitor.condition.TxTimeoutCondition) Test(org.junit.Test)

Example 13 with TxCompletionCondition

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);
}
Also used : TxCompletionCondition(org.nhindirect.monitor.condition.TxCompletionCondition) TxTimeoutCondition(org.nhindirect.monitor.condition.TxTimeoutCondition) Test(org.junit.Test)

Example 14 with TxCompletionCondition

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));
}
Also used : TxCompletionCondition(org.nhindirect.monitor.condition.TxCompletionCondition) Exchange(org.apache.camel.Exchange) Tx(org.nhindirect.common.tx.model.Tx) Message(org.apache.camel.Message) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 15 with TxCompletionCondition

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));
}
Also used : TxCompletionCondition(org.nhindirect.monitor.condition.TxCompletionCondition) Exchange(org.apache.camel.Exchange) Tx(org.nhindirect.common.tx.model.Tx) Message(org.apache.camel.Message) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

TxCompletionCondition (org.nhindirect.monitor.condition.TxCompletionCondition)21 Test (org.junit.Test)20 Tx (org.nhindirect.common.tx.model.Tx)14 Exchange (org.apache.camel.Exchange)5 ArrayList (java.util.ArrayList)4 TxDetail (org.nhindirect.common.tx.model.TxDetail)4 HashMap (java.util.HashMap)3 Message (org.apache.camel.Message)3 TxTimeoutCondition (org.nhindirect.monitor.condition.TxTimeoutCondition)3 CamelContext (org.apache.camel.CamelContext)2 DefaultExchange (org.apache.camel.impl.DefaultExchange)2 DSNFailureTextBodyPartGenerator (org.nhindirect.common.mail.dsn.DSNFailureTextBodyPartGenerator)1 DSNGenerator (org.nhindirect.common.mail.dsn.DSNGenerator)1 DefaultDSNFailureTextBodyPartGenerator (org.nhindirect.common.mail.dsn.impl.DefaultDSNFailureTextBodyPartGenerator)1 GeneralCompletionCondition (org.nhindirect.monitor.condition.impl.GeneralCompletionCondition)1