use of org.mule.runtime.core.api.transformer.Transformer 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));
}
use of org.mule.runtime.core.api.transformer.Transformer in project mule by mulesoft.
the class MuleRegistryHelperTransformersAsObjectsTestCase method testRegisterTransformersAsNamedObjects.
@Test
public void testRegisterTransformersAsNamedObjects() throws Exception {
Transformer transformer1 = muleRegistryHelper.lookupTransformer(DataType.STRING, APPLE_DATA_TYPE);
Transformer transformer2 = muleRegistryHelper.lookupTransformer(APPLE_DATA_TYPE, DataType.STRING);
assertEquals(stringToApple, transformer1);
assertEquals(appleToString, transformer2);
}
Aggregations