Search in sources :

Example 11 with MuleConfiguration

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();
}
Also used : MuleConfiguration(org.mule.runtime.core.api.config.MuleConfiguration) ExtendedTransformationService(org.mule.runtime.core.privileged.transformer.ExtendedTransformationService) Transformer(org.mule.runtime.core.api.transformer.Transformer) Message(org.mule.runtime.api.message.Message) DataType(org.mule.runtime.api.metadata.DataType) Test(org.junit.Test) SmallTest(org.mule.tck.size.SmallTest)

Aggregations

MuleConfiguration (org.mule.runtime.core.api.config.MuleConfiguration)11 Before (org.junit.Before)4 Test (org.junit.Test)4 DefaultMuleConfiguration (org.mule.runtime.core.api.config.DefaultMuleConfiguration)4 SmallTest (org.mule.tck.size.SmallTest)3 Registry (org.mule.runtime.api.artifact.Registry)2 MuleContextWithRegistries (org.mule.runtime.core.internal.context.MuleContextWithRegistries)2 AfterClass (org.junit.AfterClass)1 ComponentLocation (org.mule.runtime.api.component.location.ComponentLocation)1 ErrorType (org.mule.runtime.api.message.ErrorType)1 Message (org.mule.runtime.api.message.Message)1 DataType (org.mule.runtime.api.metadata.DataType)1 MuleContext (org.mule.runtime.core.api.MuleContext)1 ConfigurationException (org.mule.runtime.core.api.config.ConfigurationException)1 FlowConstruct (org.mule.runtime.core.api.construct.FlowConstruct)1 ExceptionContextProvider (org.mule.runtime.core.api.execution.ExceptionContextProvider)1 ProcessingStrategyFactory (org.mule.runtime.core.api.processor.strategy.ProcessingStrategyFactory)1 Transformer (org.mule.runtime.core.api.transformer.Transformer)1 DefaultQueueConfiguration (org.mule.runtime.core.api.util.queue.DefaultQueueConfiguration)1 DefaultMuleContext (org.mule.runtime.core.internal.context.DefaultMuleContext)1