use of org.mule.runtime.core.internal.registry.MuleRegistry in project mule by mulesoft.
the class MuleMessageDataTypePropagationTestCase method maintainsDataTypeOnGetPayloadTransformation.
@Test
public void maintainsDataTypeOnGetPayloadTransformation() throws Exception {
InputStream payload = mock(InputStream.class);
Message message = Message.builder().value(payload).mediaType(APPLICATION_XML_CUSTOM).build();
MuleRegistry muleRegistry = mock(MuleRegistry.class);
when(muleContext.getRegistry()).thenReturn(muleRegistry);
Transformer transformer = mock(Transformer.class);
when(transformer.transform(anyObject(), anyObject())).thenReturn(TEST_PAYLOAD);
when(muleRegistry.lookupTransformer(any(), any())).thenReturn(transformer);
assertThat(message.getPayload().getDataType().getMediaType().getPrimaryType(), equalTo(APPLICATION_XML.getPrimaryType()));
assertThat(message.getPayload().getDataType().getMediaType().getSubType(), equalTo(APPLICATION_XML.getSubType()));
assertThat(message.getPayload().getDataType().getMediaType().getCharset().get(), equalTo(CUSTOM_ENCODING));
}
Aggregations