use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.
the class DWAttributeEvaluatorTestCase method resolveIntegerValueFromJavaString.
@Test
public void resolveIntegerValueFromJavaString() throws MuleException {
AttributeEvaluator attributeEvaluator = getAttributeEvaluator("#[payload]", DataType.NUMBER);
Object port = attributeEvaluator.resolveValue(newEvent("12", APPLICATION_JAVA));
assertThat(port, is(12));
}
use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.
the class DWAttributeEvaluatorTestCase method getJavaStringFromIntJsonProperty.
@Test
public void getJavaStringFromIntJsonProperty() throws MuleException {
AttributeEvaluator attributeEvaluator = getAttributeEvaluator("#[payload.port]", STRING);
CoreEvent event = newEvent(HOST_PORT_JSON, APPLICATION_JSON);
Object port = attributeEvaluator.resolveValue(event);
assertThat(port, is("8081"));
}
use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.
the class MELAttributeEvaluatorTestCase method parseStartsAndEndsWithExpression.
@Test
public void parseStartsAndEndsWithExpression() {
AttributeEvaluator attributeEvaluator = new AttributeEvaluator("#[mel:1]#[mel:2]");
attributeEvaluator.initialize(mockExpressionManager);
attributeEvaluator.resolveValue(event);
verify(mockExpressionManager).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 resolveIntegerWithNumericStringValue.
@Test
public void resolveIntegerWithNumericStringValue() {
AttributeEvaluator attributeEvaluator = new AttributeEvaluator("#[mel:expression]", NUMBER);
attributeEvaluator.initialize(mockExpressionManager);
final String expectedValue = "123";
doReturn(new TypedValue<>(Integer.parseInt(expectedValue), NUMBER)).when(mockExpressionManager).evaluate(anyString(), any(DataType.class), any(BindingContext.class), any(CoreEvent.class));
assertThat(attributeEvaluator.resolveValue(event), is(Integer.parseInt(expectedValue)));
}
use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.
the class MELAttributeEvaluatorTestCase method resolveBooleanWithBooleanValue.
@Test
public void resolveBooleanWithBooleanValue() {
AttributeEvaluator attributeEvaluator = new AttributeEvaluator("#[mel:expression]", BOOLEAN);
attributeEvaluator.initialize(mockExpressionManager);
final Boolean expectedValue = true;
doReturn(new TypedValue<>(expectedValue, fromObject(expectedValue))).when(mockExpressionManager).evaluate(anyString(), any(DataType.class), any(BindingContext.class), any(CoreEvent.class));
assertThat(attributeEvaluator.resolveValue(event), is(Boolean.valueOf(expectedValue)));
}
Aggregations