use of org.mule.runtime.api.metadata.MediaType in project mule by mulesoft.
the class OperationMessageProcessorTestCase method operationReturnsOperationResultWhichKeepsNoValues.
@Test
public void operationReturnsOperationResultWhichKeepsNoValues() throws Exception {
Object payload = new Object();
MediaType mediaType = ANY.withCharset(getDefaultEncoding(context));
Object attributes = mock(Object.class);
when(operationExecutor.execute(any(ExecutionContext.class))).thenReturn(just(builder().output(payload).mediaType(mediaType).attributes(attributes).build()));
Message message = messageProcessor.process(event).getMessage();
assertThat(message, is(notNullValue()));
assertThat(message.getPayload().getValue(), is(sameInstance(payload)));
assertThat(message.getAttributes().getValue(), is(sameInstance(attributes)));
assertThat(message.getPayload().getDataType().getMediaType(), is(mediaType));
}
use of org.mule.runtime.api.metadata.MediaType in project mule by mulesoft.
the class OperationMessageProcessorTestCase method operationReturnsOperationResultButKeepsAttributes.
@Test
public void operationReturnsOperationResultButKeepsAttributes() throws Exception {
Object payload = new Object();
MediaType mediaType = ANY.withCharset(getDefaultEncoding(context));
when(operationExecutor.execute(any(ExecutionContext.class))).thenReturn(just(builder().output(payload).mediaType(mediaType).build()));
event = CoreEvent.builder(event).message(Message.builder().value("").attributesValue(mock(Object.class)).build()).build();
Message message = messageProcessor.process(event).getMessage();
assertThat(message, is(notNullValue()));
assertThat(message.getPayload().getValue(), is(sameInstance(payload)));
assertThat(message.getAttributes().getValue(), is(nullValue()));
assertThat(message.getPayload().getDataType().getMediaType(), equalTo(mediaType));
}
use of org.mule.runtime.api.metadata.MediaType in project mule by mulesoft.
the class MuleMessageDataTypePropagationTestCase method setsCustomPropertyDataType.
@Test
public void setsCustomPropertyDataType() throws Exception {
MediaType mediaType = APPLICATION_XML_CUSTOM;
InternalMessage message = InternalMessage.builder().value(TEST_PAYLOAD).addOutboundProperty(TEST_PROPERTY, TEST_PAYLOAD, mediaType).build();
assertOutboundPropertyDataType(message, DataType.builder(STRING).mediaType(mediaType).build());
}
Aggregations