use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.
the class MELAttributeEvaluatorTestCase method resolveIntegerWithNumericValue.
@Test
public void resolveIntegerWithNumericValue() {
AttributeEvaluator attributeEvaluator = new AttributeEvaluator("#[mel:expression]", NUMBER);
attributeEvaluator.initialize(mockExpressionManager);
final long expectedValue = 1234l;
doReturn(new TypedValue<>(expectedValue, fromObject(expectedValue))).when(mockExpressionManager).evaluate(anyString(), any(DataType.class), any(BindingContext.class), any(CoreEvent.class));
assertThat(attributeEvaluator.resolveValue(event), is(expectedValue));
}
use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.
the class MELAttributeEvaluatorTestCase method resolveIntegerWithNoNumericValue.
@Test(expected = ExpressionRuntimeException.class)
public void resolveIntegerWithNoNumericValue() {
AttributeEvaluator attributeEvaluator = new AttributeEvaluator("#[mel:expression]", NUMBER);
attributeEvaluator.initialize(mockExpressionManager);
doThrow(ExpressionRuntimeException.class).when(mockExpressionManager).evaluate(anyString(), any(DataType.class), any(BindingContext.class), any(CoreEvent.class));
attributeEvaluator.resolveValue(event);
}
use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.
the class MELAttributeEvaluatorTestCase method nullAttributeValue.
@Test
public void nullAttributeValue() {
final AttributeEvaluator nullAttributeEvaluator = new AttributeEvaluator(null, OBJECT);
nullAttributeEvaluator.initialize(mockExpressionManager);
doReturn(new TypedValue<>(null, OBJECT)).when(mockExpressionManager).evaluate(anyString(), any(DataType.class), any(BindingContext.class), any(CoreEvent.class));
assertThat(nullAttributeEvaluator.resolveValue(event), nullValue());
verify(mockExpressionManager, never()).parse(anyString(), any(CoreEvent.class), any());
verify(mockExpressionManager, never()).evaluate(anyString(), any(CoreEvent.class));
verify(mockExpressionManager, never()).evaluate(anyString(), any(DataType.class), any(), any(CoreEvent.class));
}
use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.
the class MELAttributeEvaluatorTestCase method resolveBooleanWithBooleanStringValue.
@Test
public void resolveBooleanWithBooleanStringValue() {
AttributeEvaluator attributeEvaluator = new AttributeEvaluator("#[mel:expression]", BOOLEAN);
attributeEvaluator.initialize(mockExpressionManager);
final String expectedValue = "true";
doReturn(new TypedValue<>(Boolean.valueOf(expectedValue), BOOLEAN)).when(mockExpressionManager).evaluate(anyString(), any(DataType.class), any(BindingContext.class), any(CoreEvent.class));
assertThat(attributeEvaluator.resolveValue(event), is(Boolean.valueOf(expectedValue)));
}
use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.
the class AbstractAddVariablePropertyProcessor method initialise.
@Override
public void initialise() throws InitialisationException {
identifierEvaluator.initialize(muleContext.getExpressionManager());
valueEvaluator = new AttributeEvaluator(value, getReturnDataType());
valueEvaluator.initialize(muleContext.getExpressionManager());
}
Aggregations