use of org.nhindirect.monitor.condition.TxTimeoutCondition in project nhin-d by DirectProject.
the class BasicTxAggregator_getAggregationTimeTest method testIsComplete_txsExists_emptyInitialTimeProperty_assertNull.
@Test
public void testIsComplete_txsExists_emptyInitialTimeProperty_assertNull() {
TxTimeoutCondition condition = mock(TxTimeoutCondition.class);
BasicTxAggregator aggr = new BasicTxAggregator(null, condition);
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);
when(exchange.getProperty(Exchange.CREATED_TIMESTAMP, Date.class)).thenReturn(null);
assertNull(aggr.getAggregationTime(exchange));
verify(exchange, times(1)).getProperty(Exchange.CREATED_TIMESTAMP, Date.class);
}
use of org.nhindirect.monitor.condition.TxTimeoutCondition in project nhin-d by DirectProject.
the class VariableTimeoutCondition_getTimeoutTest method testGetTimeoutTest_timelyMessage_assertUsesTimelyCondtion.
@SuppressWarnings("unchecked")
@Test
public void testGetTimeoutTest_timelyMessage_assertUsesTimelyCondtion() {
TxTimeoutCondition timelyCond = mock(TxTimeoutCondition.class);
TxTimeoutCondition generalCond = mock(TxTimeoutCondition.class);
VariableTimeoutCondition cond = new VariableTimeoutCondition(timelyCond, generalCond);
VariableTimeoutCondition spy = spy(cond);
Tx tx = mock(Tx.class);
when(spy.getMessageToTrack((Collection<Tx>) any())).thenReturn(tx);
when(spy.isRelAndTimelyRequired((Tx) any())).thenReturn(true);
assertEquals(0, spy.getTimeout(new ArrayList<Tx>(), 1000));
verify(timelyCond, times(1)).getTimeout((ArrayList<Tx>) any(), eq((long) 1000));
verify(generalCond, never()).getTimeout((ArrayList<Tx>) any(), eq((long) 1000));
}
use of org.nhindirect.monitor.condition.TxTimeoutCondition in project nhin-d by DirectProject.
the class VariableTimeoutCondition_getTimeoutTest method testGetTimeoutTest_nonTimelyMessage_assertUsesGeneralCondtion.
@SuppressWarnings("unchecked")
@Test
public void testGetTimeoutTest_nonTimelyMessage_assertUsesGeneralCondtion() {
TxTimeoutCondition timelyCond = mock(TxTimeoutCondition.class);
TxTimeoutCondition generalCond = mock(TxTimeoutCondition.class);
VariableTimeoutCondition cond = new VariableTimeoutCondition(timelyCond, generalCond);
VariableTimeoutCondition spy = spy(cond);
Tx tx = mock(Tx.class);
when(spy.getMessageToTrack((Collection<Tx>) any())).thenReturn(tx);
when(spy.isRelAndTimelyRequired((Tx) any())).thenReturn(false);
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));
}
Aggregations