Search in sources :

Example 11 with AttributeEvaluator

use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.

the class MELAttributeEvaluatorTestCase method parse.

@Test
public void parse() {
    AttributeEvaluator attributeEvaluator = new AttributeEvaluator("1#[mel:2]3#[mel:4]5");
    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));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) DataType(org.mule.runtime.api.metadata.DataType) AttributeEvaluator(org.mule.runtime.core.privileged.util.AttributeEvaluator) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 12 with AttributeEvaluator

use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.

the class MELAttributeEvaluatorTestCase method parenthesesInExpression.

@Test
public void parenthesesInExpression() {
    when(mockExpressionManager.evaluate(anyString(), any(CoreEvent.class))).thenReturn(new TypedValue(null, OBJECT));
    AttributeEvaluator attributeEvaluator = new AttributeEvaluator("#[mel:(1)]");
    attributeEvaluator.initialize(mockExpressionManager);
    attributeEvaluator.resolveValue(event);
    verify(mockExpressionManager, never()).parse(anyString(), any(CoreEvent.class), any());
    verify(mockExpressionManager).evaluate(anyString(), any(CoreEvent.class));
    verify(mockExpressionManager, never()).evaluate(anyString(), any(DataType.class), any(), any(CoreEvent.class));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) DataType(org.mule.runtime.api.metadata.DataType) AttributeEvaluator(org.mule.runtime.core.privileged.util.AttributeEvaluator) TypedValue(org.mule.runtime.api.metadata.TypedValue) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 13 with AttributeEvaluator

use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.

the class MELAttributeEvaluatorTestCase method expressionValueNoEvaluator.

@Test
public void expressionValueNoEvaluator() {
    String attributeValue = "#[mel:express]";
    when(mockExpressionManager.evaluate(eq(attributeValue), any(CoreEvent.class))).thenReturn(new TypedValue(null, OBJECT));
    when(mockExpressionManager.isExpression(attributeValue)).thenReturn(true);
    AttributeEvaluator attributeEvaluator = new AttributeEvaluator(attributeValue);
    attributeEvaluator.initialize(mockExpressionManager);
    attributeEvaluator.resolveValue(event);
    verify(mockExpressionManager, never()).parse(anyString(), any(CoreEvent.class), any());
    verify(mockExpressionManager).evaluate(anyString(), any(CoreEvent.class));
    verify(mockExpressionManager, never()).evaluate(anyString(), any(DataType.class), any(), any(CoreEvent.class));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) DataType(org.mule.runtime.api.metadata.DataType) Matchers.anyString(org.mockito.Matchers.anyString) AttributeEvaluator(org.mule.runtime.core.privileged.util.AttributeEvaluator) TypedValue(org.mule.runtime.api.metadata.TypedValue) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 14 with AttributeEvaluator

use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.

the class MELAttributeEvaluatorTestCase method expressionValue.

@Test
public void expressionValue() {
    String attributeValue = "#[mel:eval:express]";
    when(mockExpressionManager.evaluate(eq(attributeValue), any(CoreEvent.class))).thenReturn(new TypedValue(null, OBJECT));
    when(mockExpressionManager.isExpression(attributeValue)).thenReturn(true);
    AttributeEvaluator attributeEvaluator = new AttributeEvaluator(attributeValue);
    attributeEvaluator.initialize(mockExpressionManager);
    attributeEvaluator.resolveValue(event);
    verify(mockExpressionManager, never()).parse(anyString(), any(CoreEvent.class), any());
    verify(mockExpressionManager).evaluate(anyString(), any(CoreEvent.class));
    verify(mockExpressionManager, never()).evaluate(anyString(), any(DataType.class), any(), any(CoreEvent.class));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) DataType(org.mule.runtime.api.metadata.DataType) Matchers.anyString(org.mockito.Matchers.anyString) AttributeEvaluator(org.mule.runtime.core.privileged.util.AttributeEvaluator) TypedValue(org.mule.runtime.api.metadata.TypedValue) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 15 with AttributeEvaluator

use of org.mule.runtime.core.privileged.util.AttributeEvaluator in project mule by mulesoft.

the class MELAttributeEvaluatorTestCase method testParseStartsWithExpression.

@Test
public void testParseStartsWithExpression() {
    AttributeEvaluator attributeEvaluator = new AttributeEvaluator("#[mel:1]234#[mel:5]");
    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));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) DataType(org.mule.runtime.api.metadata.DataType) AttributeEvaluator(org.mule.runtime.core.privileged.util.AttributeEvaluator) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Aggregations

AttributeEvaluator (org.mule.runtime.core.privileged.util.AttributeEvaluator)35 Test (org.junit.Test)30 SmallTest (org.mule.tck.size.SmallTest)30 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)18 DataType (org.mule.runtime.api.metadata.DataType)13 BindingContext (org.mule.runtime.api.el.BindingContext)6 Matchers.anyString (org.mockito.Matchers.anyString)4 TypedValue (org.mule.runtime.api.metadata.TypedValue)3 InputStream (java.io.InputStream)2 Map (java.util.Map)2 List (java.util.List)1 TestConnectorQueueHandler (org.mule.functional.api.component.TestConnectorQueueHandler)1 WildcardAttributeEvaluator (org.mule.runtime.core.api.util.WildcardAttributeEvaluator)1