Search in sources :

Example 16 with AttributeEvaluator

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

the class MELAttributeEvaluatorTestCase method plainTextValue.

@Test
public void plainTextValue() {
    AttributeEvaluator attributeEvaluator = new AttributeEvaluator("attributeEvaluator");
    when(mockExpressionManager.isExpression("attributeEvaluator")).thenReturn(false);
    attributeEvaluator.initialize(mockExpressionManager);
    attributeEvaluator.resolveValue(event);
    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));
}
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 17 with AttributeEvaluator

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

the class QueueWriterMessageProcessor method initialise.

@Override
public void initialise() throws InitialisationException {
    if (attributeEvaluator == null) {
        String attribute = content == null ? "#[payload]" : content;
        if (contentJavaType != null) {
            attributeEvaluator = new AttributeEvaluator(attribute, fromType(contentJavaType));
        } else {
            attributeEvaluator = new AttributeEvaluator(attribute);
        }
    }
    attributeEvaluator.initialize(expressionManager);
    queueHandler = new TestConnectorQueueHandler(registry);
}
Also used : TestConnectorQueueHandler(org.mule.functional.api.component.TestConnectorQueueHandler) AttributeEvaluator(org.mule.runtime.core.privileged.util.AttributeEvaluator)

Example 18 with AttributeEvaluator

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

the class DWAttributeEvaluatorTestCase method getJavaStringFromStringJsonProperty.

@Test
public void getJavaStringFromStringJsonProperty() throws MuleException {
    AttributeEvaluator attributeEvaluator = getAttributeEvaluator("#[payload.host]", STRING);
    CoreEvent event = newEvent(HOST_PORT_JSON, APPLICATION_JSON);
    Object host = attributeEvaluator.resolveValue(event);
    assertThat(host, is("0.0.0.0"));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) AttributeEvaluator(org.mule.runtime.core.privileged.util.AttributeEvaluator) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 19 with AttributeEvaluator

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

the class DWAttributeEvaluatorTestCase method parseExpressionAreNotSupported.

@Test(expected = ExpressionRuntimeException.class)
public void parseExpressionAreNotSupported() throws MuleException {
    AttributeEvaluator attributeEvaluator = getAttributeEvaluator("invalid #['expression']");
    attributeEvaluator.resolveValue(newEvent());
}
Also used : AttributeEvaluator(org.mule.runtime.core.privileged.util.AttributeEvaluator) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 20 with AttributeEvaluator

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

the class DWAttributeEvaluatorTestCase method resolveStringValue.

@Test
public void resolveStringValue() throws MuleException {
    AttributeEvaluator attributeEvaluator = getAttributeEvaluator("#[payload.port]", STRING);
    String port = attributeEvaluator.resolveValue(newEvent(HOST_PORT_JSON, APPLICATION_JSON));
    assertThat(port, is("8081"));
}
Also used : 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