use of org.mule.runtime.core.internal.enricher.MessageEnricher.EnrichExpressionPair in project mule by mulesoft.
the class MessageEnricherTestCase method doNotImplicitlyEnrichMessageProperties.
@Test
public void doNotImplicitlyEnrichMessageProperties() throws Exception {
MessageEnricher enricher = baseEnricher();
enricher.addEnrichExpressionPair(new EnrichExpressionPair("#[mel:message.outboundProperties.myHeader]"));
enricher.setEnrichmentMessageProcessor((InternalTestProcessor) event -> CoreEvent.builder(event).message(InternalMessage.builder(event.getMessage()).addInboundProperty("foo", "bar").build()).build());
Message out = process(enricher, testEvent()).getMessage();
assertNull(((InternalMessage) out).getOutboundProperty("foo"));
}
use of org.mule.runtime.core.internal.enricher.MessageEnricher.EnrichExpressionPair in project mule by mulesoft.
the class MessageEnricherTestCase method doNotImplicitlyEnrichSessionVariable.
@Test
public void doNotImplicitlyEnrichSessionVariable() throws Exception {
MessageEnricher enricher = baseEnricher();
enricher.addEnrichExpressionPair(new EnrichExpressionPair("#[mel:message.outboundProperties.myHeader]"));
enricher.setEnrichmentMessageProcessor((InternalTestProcessor) event -> {
((PrivilegedEvent) event).getSession().setProperty("sessionFoo", "bar");
return event;
});
CoreEvent out = process(enricher, testEvent());
assertNull(((PrivilegedEvent) out).getSession().getProperty("sessionFoo"));
}
use of org.mule.runtime.core.internal.enricher.MessageEnricher.EnrichExpressionPair in project mule by mulesoft.
the class MessageEnricherTestCase method doNotImplicitlyEnrichMessagePayload.
@Test
public void doNotImplicitlyEnrichMessagePayload() throws Exception {
MessageEnricher enricher = baseEnricher();
enricher.addEnrichExpressionPair(new EnrichExpressionPair("#[mel:message.outboundProperties.myHeader]"));
enricher.setEnrichmentMessageProcessor((InternalTestProcessor) event -> CoreEvent.builder(event).message(InternalMessage.builder(event.getMessage()).value("enriched").build()).build());
Message out = process(enricher, testEvent()).getMessage();
assertEquals(TEST_PAYLOAD, out.getPayload().getValue());
}
use of org.mule.runtime.core.internal.enricher.MessageEnricher.EnrichExpressionPair in project mule by mulesoft.
the class MessageEnricherTestCase method enrichSessionVariable.
@Test
public void enrichSessionVariable() throws Exception {
MessageEnricher enricher = baseEnricher();
enricher.addEnrichExpressionPair(new EnrichExpressionPair("#[mel:sessionVars['foo']]"));
enricher.setEnrichmentMessageProcessor((InternalTestProcessor) event -> CoreEvent.builder(event).message(InternalMessage.builder(event.getMessage()).value("bar").build()).build());
CoreEvent out = process(enricher, testEvent());
assertEquals("bar", ((PrivilegedEvent) out).getSession().getProperty("foo"));
}
use of org.mule.runtime.core.internal.enricher.MessageEnricher.EnrichExpressionPair in project mule by mulesoft.
the class MessageEnricherTestCase method testEnrichHeaderWithPayload.
@Test
public void testEnrichHeaderWithPayload() throws Exception {
MessageEnricher enricher = createEnricher();
enricher.addEnrichExpressionPair(new EnrichExpressionPair("#[mel:message.outboundProperties.myHeader]"));
enricher.setEnrichmentMessageProcessor((InternalTestProcessor) event -> CoreEvent.builder(event).message(InternalMessage.builder(event.getMessage()).value(TEST_PAYLOAD).build()).build());
initialiseIfNeeded(enricher, muleContext);
Message result = process(enricher, testEvent()).getMessage();
assertEquals(TEST_PAYLOAD, ((InternalMessage) result).getOutboundProperty("myHeader"));
assertEquals(TEST_PAYLOAD, result.getPayload().getValue());
}
Aggregations