use of org.mule.mvel2.compiler.CompiledExpression in project mule by mulesoft.
the class PropertyEnricherDataTypePropagatorTestCase method propagatesDataTypeForInlinedInvocationProperty.
@Test
public void propagatesDataTypeForInlinedInvocationProperty() throws Exception {
final DataType expectedDataType = DataType.builder().type(String.class).mediaType(JSON).charset(CUSTOM_ENCODING).build();
MVELExpressionLanguage expressionLanguage = new MVELExpressionLanguage(muleContext);
final CompiledExpression compiledExpression = (CompiledExpression) compileExpression("foo = 'unused'", new ParserContext(expressionLanguage.getParserConfiguration()));
PrivilegedEvent testEvent = this.<PrivilegedEvent.Builder>getEventBuilder().message(of(TEST_MESSAGE)).addVariable("foo", "bar").build();
final PrivilegedEvent.Builder builder = PrivilegedEvent.builder(testEvent);
dataTypePropagator.propagate(testEvent, builder, new TypedValue<>(TEST_MESSAGE, expectedDataType), compiledExpression);
assertThat(builder.build().getVariables().get("foo").getDataType(), like(String.class, JSON, CUSTOM_ENCODING));
}
use of org.mule.mvel2.compiler.CompiledExpression in project mule by mulesoft.
the class PropertyExpressionDataTypeResolverTestCase method returnsInlineSessionPropertyDataType.
@Test
public void returnsInlineSessionPropertyDataType() throws Exception {
final String expression = "foo";
final DataType expectedDataType = DataType.builder().type(String.class).mediaType(JSON).charset(CUSTOM_ENCODING).build();
MVELExpressionLanguage expressionLanguage = new MVELExpressionLanguage(muleContext);
final CompiledExpression compiledExpression = (CompiledExpression) compileExpression(expression, new ParserContext(expressionLanguage.getParserConfiguration()));
((PrivilegedEvent) testEvent()).getSession().setProperty("foo", EXPRESSION_VALUE, expectedDataType);
assertThat(expressionDataTypeResolver.resolve((PrivilegedEvent) testEvent(), compiledExpression), like(String.class, JSON, CUSTOM_ENCODING));
}
Aggregations