use of org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext in project mule by mulesoft.
the class MVELExpressionLanguageContextTestCase method testGetVariableResolver.
@Test
public void testGetVariableResolver() {
MuleBaseVariableResolverFactory resoverFactory = new MVELExpressionLanguageContext(parserConfig, muleContext);
resoverFactory.addResolver("foo", new SimpleValueResolver("val"));
assertNotNull(resoverFactory.getVariableResolver("foo"));
assertEquals("val", resoverFactory.getVariableResolver("foo").getValue());
assertNull(resoverFactory.getVariableResolver("bar"));
}
use of org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext in project mule by mulesoft.
the class MVELExpressionLanguageContextTestCase method testGetVariableResolverNextFactory.
@Test
public void testGetVariableResolverNextFactory() {
parserConfig.addImport(String.class);
MuleBaseVariableResolverFactory resoverFactory = new MVELExpressionLanguageContext(parserConfig, muleContext);
resoverFactory.setNextFactory(new MapVariableResolverFactory(Collections.singletonMap("foo", "val")));
assertNotNull(resoverFactory.getVariableResolver("foo"));
assertEquals("val", resoverFactory.getVariableResolver("foo").getValue());
assertNull(resoverFactory.getVariableResolver("bar"));
}
use of org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext in project mule by mulesoft.
the class AbstractVarAssignmentDataTypePropagatorTestCase method createMvelExpressionLanguageContext.
protected MVELExpressionLanguageContext createMvelExpressionLanguageContext(PrivilegedEvent testEvent, PrivilegedEvent.Builder builder, ParserConfiguration parserConfiguration) {
final MVELExpressionLanguageContext context = new MVELExpressionLanguageContext(parserConfiguration, muleContext);
final StaticVariableResolverFactory staticContext = new StaticVariableResolverFactory(parserConfiguration, muleContext);
final GlobalVariableResolverFactory globalContext = new GlobalVariableResolverFactory(emptyMap(), emptyMap(), parserConfiguration, muleContext);
final DelegateVariableResolverFactory innerDelegate = new DelegateVariableResolverFactory(globalContext, new VariableVariableResolverFactory(parserConfiguration, muleContext, testEvent, builder));
final DelegateVariableResolverFactory delegate = new DelegateVariableResolverFactory(staticContext, new MessageVariableResolverFactory(parserConfiguration, muleContext, testEvent, builder, innerDelegate));
context.setNextFactory(new CachedMapVariableResolverFactory(emptyMap(), delegate));
return context;
}
use of org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext in project mule by mulesoft.
the class AbstractVarExpressionDataTypeResolverTestCase method doVarDataTypeTest.
protected void doVarDataTypeTest(String expression) throws Exception {
DataType expectedDataType = DataType.builder().type(String.class).mediaType(JSON).charset(CUSTOM_ENCODING).build();
PrivilegedEvent event = setVariable((PrivilegedEvent) testEvent(), EXPRESSION_VALUE, expectedDataType);
final ParserConfiguration parserConfiguration = MVELExpressionLanguage.createParserConfiguration(Collections.EMPTY_MAP);
final MVELExpressionLanguageContext context = createMvelExpressionLanguageContext(event, parserConfiguration);
CompiledExpression compiledExpression = (CompiledExpression) compileExpression(expression, new ParserContext(parserConfiguration));
// Expression must be executed, otherwise the variable accessor is not properly configured
MVEL.executeExpression(compiledExpression, context);
assertThat(expressionDataTypeResolver.resolve(event, compiledExpression), like(String.class, JSON, CUSTOM_ENCODING));
}
use of org.mule.runtime.core.internal.el.mvel.MVELExpressionLanguageContext in project mule by mulesoft.
the class DateTimeExpressionLanguageFunctionTestCase method setup.
@Before
public void setup() throws InitialisationException {
ParserConfiguration parserConfiguration = new ParserConfiguration();
expressionExecutor = new MVELExpressionExecutor(parserConfiguration);
context = new MVELExpressionLanguageContext(parserConfiguration, Mockito.mock(MuleContext.class));
dateTimeFunction = new DateTimeExpressionLanguageFuntion();
context.declareFunction("dateTime", dateTimeFunction);
}
Aggregations