use of org.mule.runtime.core.internal.transformer.expression.ExpressionTransformer in project mule by mulesoft.
the class ExpressionTransformerTestCase method testNullPayloadIsConsideredAsNullResultEL.
@Test
public void testNullPayloadIsConsideredAsNullResultEL() throws Exception {
ExpressionTransformer transformer = new ExpressionTransformer();
transformer.setMuleContext(muleContext);
transformer.setReturnSourceIfNull(true);
// MVL doesn't return NullPayload but rather null. So 'optional' needs to be true.
ExpressionArgument argument = new ExpressionArgument("test", "null", true);
argument.setMuleContext(muleContext);
transformer.addArgument(argument);
Object result = transformer.transformMessage(testEvent(), null);
assertTrue(result instanceof InternalMessage);
InternalMessage transformedMessage = (InternalMessage) result;
assertEquals(TEST_PAYLOAD, transformedMessage.getPayload().getValue());
}
use of org.mule.runtime.core.internal.transformer.expression.ExpressionTransformer in project mule by mulesoft.
the class ExpressionTransformerTestCase method testExpressionEvaluationClassLoaderEL.
@Test
public void testExpressionEvaluationClassLoaderEL() throws ClassNotFoundException, TransformerException {
ExpressionTransformer transformer = new ExpressionTransformer();
transformer.setMuleContext(muleContext);
ExpressionArgument argument = new ExpressionArgument("test", "mel:payload is org.MyClass", false);
argument.setMuleContext(muleContext);
transformer.addArgument(argument);
withContextClassLoader(new MyClassClassLoader(), () -> {
try {
transformer.initialise();
} catch (Exception e) {
fail(e.getMessage());
}
});
assertFalse((Boolean) transformer.transform("test"));
}
use of org.mule.runtime.core.internal.transformer.expression.ExpressionTransformer in project mule by mulesoft.
the class CoreComponentBuildingDefinitionProvider method getExpressionTransformerConfigurationFactory.
private ConfigurableInstanceFactory getExpressionTransformerConfigurationFactory() {
return getAbstractTransformerConfigurationFactory(parameters -> {
ExpressionTransformer expressionTransformer = new ExpressionTransformer();
Boolean returnSourceIfNull = (Boolean) parameters.get("returnSourceIfNull");
if (returnSourceIfNull != null) {
expressionTransformer.setReturnSourceIfNull(returnSourceIfNull);
}
return expressionTransformer;
});
}
Aggregations