use of org.mule.runtime.api.message.Message 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.api.message.Message 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.api.message.Message 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());
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class DefaultMuleMessageBuilderTestCase method createAPIMessageViaMessageInterfaceFromCopy.
@Test
public void createAPIMessageViaMessageInterfaceFromCopy() {
org.mule.runtime.api.message.Message message;
message = org.mule.runtime.api.message.Message.builder().value(TEST_PAYLOAD).build();
org.mule.runtime.api.message.Message messageCopy;
messageCopy = org.mule.runtime.api.message.Message.builder(message).value(true).attributesValue(BASE_ATTRIBUTES).build();
assertThat(messageCopy.getPayload().getValue(), is(true));
assertThat(messageCopy.getPayload().getDataType(), is(BOOLEAN));
assertThat(messageCopy.getAttributes().getValue(), is(BASE_ATTRIBUTES));
assertThat(messageCopy.getAttributes().getDataType(), is(BASE_ATTRIBUTES_DATATYPE));
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class DefaultMuleMessageBuilderTestCase method nullPayload.
@Test
public void nullPayload() {
Message message = of(null);
assertThat(message.getPayload().getDataType().getType(), equalTo(Object.class));
}
Aggregations