use of org.mule.runtime.core.api.transformer.MessageTransformerException in project mule by mulesoft.
the class TransformationServiceTestCase method failsOnConverterWhenSourceAndReturnTypeDoesNotMatchAndThereIsNoImplicitConversion2.
@Test
public void failsOnConverterWhenSourceAndReturnTypeDoesNotMatchAndThereIsNoImplicitConversion2() throws MuleException {
// Converter(B->C), payload A: FAIL
ByteArrayInputStream payload = new ByteArrayInputStream(TEST_PAYLOAD.getBytes());
DataType originalSourceType = DataType.fromType(payload.getClass());
Transformer converter1 = new MockConverterBuilder().from(originalSourceType).to(dataTypeC).build();
A transformedPayload = new A();
when(converter1.transform(any())).thenReturn(transformedPayload);
Message message = of(payload);
try {
transformationService.applyTransformers(message, null, converter1);
fail("Transformation is supposed to fail");
} catch (MessageTransformerException expected) {
assertThat(expected.getErrorMessage().getPayload().getValue(), is(transformedPayload));
}
}
Aggregations