Search in sources :

Example 1 with ExtendedTransformationService

use of org.mule.runtime.core.privileged.transformer.ExtendedTransformationService in project mule by mulesoft.

the class MuleMessageDataTypePropagationTestCase method setUp.

@Before
public void setUp() throws Exception {
    when(muleContext.getConfiguration().getDefaultEncoding()).thenReturn(DEFAULT_ENCODING.name());
    registerIntoMockContext(muleContext, OBJECT_DEFAULT_RETRY_POLICY_TEMPLATE, mock(RetryPolicyTemplate.class));
    transformationService = new ExtendedTransformationService(muleContext);
}
Also used : RetryPolicyTemplate(org.mule.runtime.core.api.retry.policy.RetryPolicyTemplate) ExtendedTransformationService(org.mule.runtime.core.privileged.transformer.ExtendedTransformationService) Before(org.junit.Before)

Example 2 with ExtendedTransformationService

use of org.mule.runtime.core.privileged.transformer.ExtendedTransformationService in project mule by mulesoft.

the class PipelineMessageNotificationTestCase method createMocks.

@Before
public void createMocks() throws Exception {
    muleContext.dispose();
    muleContext = mockContextWithServices();
    when(muleContext.getStatistics()).thenReturn(new AllStatistics());
    when(muleContext.getConfiguration()).thenReturn(new DefaultMuleConfiguration());
    notificationFirer = ((MuleContextWithRegistries) muleContext).getRegistry().lookupObject(NotificationDispatcher.class);
    when(muleContext.getDefaultErrorHandler(empty())).thenReturn(new ErrorHandlerFactory().createDefault(notificationFirer));
    mockErrorTypeLocator();
    when(muleContext.getTransformationService()).thenReturn(new ExtendedTransformationService(muleContext));
}
Also used : ExtendedTransformationService(org.mule.runtime.core.privileged.transformer.ExtendedTransformationService) AllStatistics(org.mule.runtime.core.api.management.stats.AllStatistics) DefaultMuleConfiguration(org.mule.runtime.core.api.config.DefaultMuleConfiguration) MuleContextWithRegistries(org.mule.runtime.core.internal.context.MuleContextWithRegistries) NotificationDispatcher(org.mule.runtime.api.notification.NotificationDispatcher) ErrorHandlerFactory(org.mule.runtime.core.internal.exception.ErrorHandlerFactory) Before(org.junit.Before)

Example 3 with ExtendedTransformationService

use of org.mule.runtime.core.privileged.transformer.ExtendedTransformationService 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)

Example 4 with ExtendedTransformationService

use of org.mule.runtime.core.privileged.transformer.ExtendedTransformationService in project mule by mulesoft.

the class TransformationServiceTestCase method setUp.

@Before
public void setUp() throws Exception {
    when(muleContext.getDataTypeConverterResolver()).thenReturn(conversionResolver);
    this.transformationService = new ExtendedTransformationService(muleContext);
}
Also used : ExtendedTransformationService(org.mule.runtime.core.privileged.transformer.ExtendedTransformationService) Before(org.junit.Before)

Aggregations

ExtendedTransformationService (org.mule.runtime.core.privileged.transformer.ExtendedTransformationService)4 Before (org.junit.Before)3 Test (org.junit.Test)1 Message (org.mule.runtime.api.message.Message)1 DataType (org.mule.runtime.api.metadata.DataType)1 NotificationDispatcher (org.mule.runtime.api.notification.NotificationDispatcher)1 DefaultMuleConfiguration (org.mule.runtime.core.api.config.DefaultMuleConfiguration)1 MuleConfiguration (org.mule.runtime.core.api.config.MuleConfiguration)1 AllStatistics (org.mule.runtime.core.api.management.stats.AllStatistics)1 RetryPolicyTemplate (org.mule.runtime.core.api.retry.policy.RetryPolicyTemplate)1 Transformer (org.mule.runtime.core.api.transformer.Transformer)1 MuleContextWithRegistries (org.mule.runtime.core.internal.context.MuleContextWithRegistries)1 ErrorHandlerFactory (org.mule.runtime.core.internal.exception.ErrorHandlerFactory)1 SmallTest (org.mule.tck.size.SmallTest)1