use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class DefaultMuleMessageBuilderTestCase method mutateEntirePayload.
@Test
public void mutateEntirePayload() {
Message message = createTestMessage();
Message copy = new DefaultMessageBuilder(message).payload(new TypedValue<>(EMPTY_JSON, JSON_STRING)).build();
assertThat(copy.getPayload().getValue(), equalTo(EMPTY_JSON));
assertThat(copy.getPayload().getDataType().getType(), equalTo(String.class));
assertThat(copy.getPayload().getDataType().getMediaType(), is(APPLICATION_JSON));
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class DefaultMuleMessageTestCase method compatibilityToString.
@Test
public void compatibilityToString() {
Message message = InternalMessage.builder().payload(TypedValue.of("test")).attributes(new TypedValue<>("{}", JSON_STRING)).mediaType(TEXT).addInboundProperty("bar", "in").addOutboundProperty(FOO_PROPERTY, "out").exceptionPayload(new DefaultExceptionPayload(new NullPointerException("error"))).build();
assertThat(message.toString(), is("\n" + "org.mule.runtime.core.internal.message.DefaultMessageBuilder$MessageImplementation\n" + "{\n" + " payload=test\n" + " mediaType=text/plain\n" + " attributes={}\n" + " attributesMediaType=application/json\n" + " exceptionPayload:\n" + " message=error\n" + " exception=java.lang.NullPointerException: error\n" + " Message properties:\n" + " INBOUND scoped properties:\n" + " bar=in\n" + " OUTBOUND scoped properties:\n" + " foo=out\n" + "}"));
}
Aggregations