Search in sources :

Example 96 with Exchange

use of org.apache.camel.Exchange in project nhin-d by DirectProject.

the class MessageIdCorrelationExpression_evaluateTest method testEvaluate_IMFMessage_noMsgId_assertNullId.

@Test
public void testEvaluate_IMFMessage_noMsgId_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.IMF, details);
    CamelContext context = mock(CamelContext.class);
    Exchange exchange = new DefaultExchange(context);
    exchange.getIn().setBody(tx);
    assertNull(exp.evaluate(exchange, String.class));
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Tx(org.nhindirect.common.tx.model.Tx) HashMap(java.util.HashMap) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 97 with Exchange

use of org.apache.camel.Exchange 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));
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Tx(org.nhindirect.common.tx.model.Tx) HashMap(java.util.HashMap) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 98 with Exchange

use of org.apache.camel.Exchange 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));
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Tx(org.nhindirect.common.tx.model.Tx) HashMap(java.util.HashMap) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 99 with Exchange

use of org.apache.camel.Exchange 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));
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Tx(org.nhindirect.common.tx.model.Tx) HashMap(java.util.HashMap) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 100 with Exchange

use of org.apache.camel.Exchange 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));
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Tx(org.nhindirect.common.tx.model.Tx) HashMap(java.util.HashMap) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Aggregations

Exchange (org.apache.camel.Exchange)3446 Test (org.junit.Test)1735 Processor (org.apache.camel.Processor)1405 RouteBuilder (org.apache.camel.builder.RouteBuilder)666 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)640 DefaultExchange (org.apache.camel.impl.DefaultExchange)473 Message (org.apache.camel.Message)379 Endpoint (org.apache.camel.Endpoint)235 HashMap (java.util.HashMap)190 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)155 Producer (org.apache.camel.Producer)150 File (java.io.File)120 ArrayList (java.util.ArrayList)117 CamelContext (org.apache.camel.CamelContext)117 List (java.util.List)99 Map (java.util.Map)96 ProducerTemplate (org.apache.camel.ProducerTemplate)94 IOException (java.io.IOException)92 Tx (org.nhindirect.common.tx.model.Tx)83 Predicate (org.apache.camel.Predicate)78