use of org.apache.camel.CamelContext in project nhin-d by DirectProject.
the class MessageIdCorrelationExpression_evaluateTest method testEvaluate_DSNMessage_parentMsgIdExists_assertMessageIdEvaluated.
@Test
public void testEvaluate_DSNMessage_parentMsgIdExists_assertMessageIdEvaluated() {
MessageIdCorrelationExpression exp = new MessageIdCorrelationExpression();
String msgId = UUID.randomUUID().toString();
Map<String, TxDetail> details = new HashMap<String, TxDetail>();
details.put(TxDetailType.PARENT_MSG_ID.getType(), new TxDetail(TxDetailType.PARENT_MSG_ID, msgId));
Tx tx = new Tx(TxMessageType.DSN, details);
CamelContext context = mock(CamelContext.class);
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setBody(tx);
assertEquals(msgId, exp.evaluate(exchange, String.class));
}
use of org.apache.camel.CamelContext in project nhin-d by DirectProject.
the class MessageIdCorrelationExpression_evaluateTest method testEvaluate_MDNMessage_noParentMsgId_assertNullId.
@Test
public void testEvaluate_MDNMessage_noParentMsgId_assertNullId() {
MessageIdCorrelationExpression exp = new MessageIdCorrelationExpression();
Map<String, TxDetail> details = new HashMap<String, TxDetail>();
details.put(TxDetailType.FROM.getType(), new TxDetail(TxDetailType.FROM, "me@test.com"));
Tx tx = new Tx(TxMessageType.MDN, details);
CamelContext context = mock(CamelContext.class);
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setBody(tx);
assertNull(exp.evaluate(exchange, String.class));
}
use of org.apache.camel.CamelContext in project nhin-d by DirectProject.
the class MessageIdCorrelationExpression_evaluateTest method testEvaluate_DNSMessage_noParentMsgId_assertNullId.
@Test
public void testEvaluate_DNSMessage_noParentMsgId_assertNullId() {
MessageIdCorrelationExpression exp = new MessageIdCorrelationExpression();
Map<String, TxDetail> details = new HashMap<String, TxDetail>();
details.put(TxDetailType.FROM.getType(), new TxDetail(TxDetailType.FROM, "me@test.com"));
Tx tx = new Tx(TxMessageType.MDN, details);
CamelContext context = mock(CamelContext.class);
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setBody(tx);
assertNull(exp.evaluate(exchange, String.class));
}
use of org.apache.camel.CamelContext in project nhin-d by DirectProject.
the class MessageIdCorrelationExpression_evaluateTest method testEvaluate_MDNMessage_parentMsgIdExists_assertMessageIdEvaluated.
@Test
public void testEvaluate_MDNMessage_parentMsgIdExists_assertMessageIdEvaluated() {
MessageIdCorrelationExpression exp = new MessageIdCorrelationExpression();
String msgId = UUID.randomUUID().toString();
Map<String, TxDetail> details = new HashMap<String, TxDetail>();
details.put(TxDetailType.PARENT_MSG_ID.getType(), new TxDetail(TxDetailType.PARENT_MSG_ID, msgId));
Tx tx = new Tx(TxMessageType.MDN, details);
CamelContext context = mock(CamelContext.class);
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setBody(tx);
assertEquals(msgId, exp.evaluate(exchange, String.class));
}
use of org.apache.camel.CamelContext 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