use of org.mule.runtime.core.api.config.MuleConfiguration in project mule by mulesoft.
the class TransformationServiceNullTransformationTestCase method transformerIsNeverCalledWithANullValue.
@Test
public void transformerIsNeverCalledWithANullValue() throws MuleException {
MuleContext muleContext = mock(MuleContext.class);
MuleConfiguration muleConfiguration = mock(MuleConfiguration.class);
when(muleContext.getConfiguration()).thenReturn(muleConfiguration);
ExtendedTransformationService transformationService = new ExtendedTransformationService(muleContext);
Transformer transformer1 = mock(Transformer.class);
when(transformer1.transform(any(Object.class))).thenReturn(null);
when(transformer1.isSourceDataTypeSupported(any(DataType.class))).thenReturn(true);
when(transformer1.getReturnDataType()).thenReturn(DataType.OBJECT);
Transformer transformer2 = mock(Transformer.class);
when(transformer2.transform(any(Object.class))).thenReturn("foo");
when(transformer2.isSourceDataTypeSupported(any(DataType.class))).thenReturn(true);
when(transformer2.getReturnDataType()).thenReturn(DataType.OBJECT);
Message message = transformationService.applyTransformers(of(""), null, transformer1, transformer2);
assertEquals("foo", message.getPayload().getValue());
verify(transformer1, never()).transform(null);
verify(transformer1, never()).isAcceptNull();
verify(transformer2, never()).transform(null);
verify(transformer2, never()).isAcceptNull();
}
Aggregations