use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class EventBenchmark method createMuleEventWithFlowVarsAndProperties.
private CoreEvent createMuleEventWithFlowVarsAndProperties(int numProperties) {
InternalMessage.Builder builder = InternalMessage.builder().value(PAYLOAD);
for (int i = 1; i <= numProperties; i++) {
builder.addInboundProperty("InBoUnDpRoPeRtYkEy" + i, "val");
}
Message message = builder.build();
CoreEvent event = createMuleEvent(message, numProperties);
return event;
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class DefaultMessageContextTestCase method overrideCorrelationIdInContextSequence.
@Test
public void overrideCorrelationIdInContextSequence() {
final Message message = of(TEST_PAYLOAD);
final CoreEvent event = InternalEvent.builder(executionContextWithCorrelation).message(message).correlationId(CUSTOM_CORRELATION_ID).groupCorrelation(Optional.of(GroupCorrelation.of(6))).build();
assertThat(event.getCorrelationId(), is(CUSTOM_CORRELATION_ID));
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class DefaultMessageContextTestCase method correlationIdInContext.
@Test
public void correlationIdInContext() {
final Message message = of(TEST_PAYLOAD);
final CoreEvent event = InternalEvent.builder(executionContextWithCorrelation).message(message).build();
assertThat(event.getCorrelationId(), is(CUSTOM_CORRELATION_ID));
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class MessagingExceptionTestCase method payloadInfoException.
@Test
@Ignore("MULE-10266 review how the transformationService is obtained when building an exception.")
public void payloadInfoException() throws Exception {
MuleException.verboseExceptions = true;
CoreEvent testEvent = mock(CoreEvent.class);
Object payload = mock(Object.class);
// This has to be done this way since mockito doesn't allow to verify toString()
when(payload.toString()).then(new FailAnswer("toString() expected not to be called."));
Message muleMessage = of(payload);
when(transformationService.transform(muleMessage, DataType.STRING)).thenThrow(new TransformerException(createStaticMessage("exception thrown")));
when(testEvent.getMessage()).thenReturn(muleMessage);
MessagingException e = new MessagingException(createStaticMessage(message), testEvent);
assertThat(e.getInfo().get(PAYLOAD_INFO_KEY), is(TransformerException.class.getName() + " while getting payload: exception thrown"));
}
use of org.mule.runtime.api.message.Message in project mule by mulesoft.
the class MessagingExceptionTestCase method payloadInfoConsumable.
@Test
public void payloadInfoConsumable() throws Exception {
MuleException.verboseExceptions = true;
CoreEvent testEvent = mock(CoreEvent.class);
when(testEvent.getError()).thenReturn(empty());
final ByteArrayInputStream payload = new ByteArrayInputStream(new byte[] {});
Message muleMessage = of(payload);
when(testEvent.getMessage()).thenReturn(muleMessage);
MessagingException e = new MessagingException(createStaticMessage(message), testEvent);
assertThat((String) e.getInfo().get(PAYLOAD_INFO_KEY), containsString(ByteArrayInputStream.class.getName() + "@"));
verify(transformationService, never()).transform(muleMessage, DataType.STRING);
}
Aggregations