Search in sources :

Example 61 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class ExtendedExpressionLanguageAdapterTestCase method variablesMutation.

@Test
@Description("Verifies that variables can be modified under MVEL but not DW.")
public void variablesMutation() throws Exception {
    CoreEvent event = testEvent();
    CoreEvent.Builder builder1 = builder(event);
    TypedValue result = expressionLanguageAdapter.evaluate(melify("flowVars.put(\'key\',\'value\')"), event, builder1, TEST_CONNECTOR_LOCATION, emptyBindingContext);
    assertThat(result.getValue(), is(nullValue()));
    assertThat(builder1.build().getVariables().keySet(), contains("key"));
    CoreEvent.Builder builder2 = builder(event);
    TypedValue result2 = expressionLanguageAdapter.evaluate("vars.put(\'key\',\'value\')", event, builder2, TEST_CONNECTOR_LOCATION, emptyBindingContext);
    assertThat(result2.getValue(), is(nullValue()));
    assertThat(builder2.build().getVariables().keySet(), not(contains("key")));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) TypedValue(org.mule.runtime.api.metadata.TypedValue) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 62 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class ExtendedExpressionLanguageAdapterTestCase method payloadMutation.

@Test
@Description("Verifies that the payload can be modified under MVEL but not DW.")
public void payloadMutation() throws Exception {
    CoreEvent event = eventBuilder(muleContext).message(of(1)).build();
    CoreEvent.Builder builder1 = builder(event);
    String expression = "payload = 3";
    TypedValue result = expressionLanguageAdapter.evaluate(melify(expression), event, builder1, TEST_CONNECTOR_LOCATION, emptyBindingContext);
    assertThat(result.getValue(), is(1));
    assertThat(builder1.build().getMessage().getPayload().getValue(), is(3));
    CoreEvent.Builder builder2 = builder(event);
    expectedException.expect(ExpressionRuntimeException.class);
    expressionLanguageAdapter.evaluate(expression, event, builder2, TEST_CONNECTOR_LOCATION, emptyBindingContext);
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) TypedValue(org.mule.runtime.api.metadata.TypedValue) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 63 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class DefaultExpressionManagerMelDefaultTestCase method parseLogStream.

@Test
@Description("Verifies that streams are logged in DW but not in MVEL.")
public void parseLogStream() throws MuleException {
    ByteArrayInputStream stream = new ByteArrayInputStream("hello".getBytes());
    CoreEvent event = getEventBuilder().message(Message.of(stream)).build();
    assertThat(expressionManager.parseLogTemplate("this is #[dw:payload]", event, TEST_CONNECTOR_LOCATION, NULL_BINDING_CONTEXT), is("this is hello"));
    assertThat(expressionManager.parseLogTemplate("this is #[payload]", event, TEST_CONNECTOR_LOCATION, NULL_BINDING_CONTEXT), both(startsWith("this is ")).and(containsString(stream.getClass().getSimpleName())));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 64 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class DefaultExpressionManagerMelDefaultTestCase method simpleCustomVariable.

@Test
@Description("Verifies that custom variables are considered.")
public void simpleCustomVariable() {
    Object object = new Object();
    BindingContext context = builder().addBinding(MY_VAR, new TypedValue(object, OBJECT)).build();
    assertThat(expressionManager.evaluate("#[myVar]", context).getValue(), equalTo(object));
}
Also used : BindingContext(org.mule.runtime.api.el.BindingContext) TypedValue(org.mule.runtime.api.metadata.TypedValue) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 65 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class DefaultExpressionManagerMelDefaultTestCase method flowVars.

@Test
@Description("Verifies that flowVars work, returning null for non existent ones and it's value for those that do.")
public void flowVars() throws MuleException {
    CoreEvent.Builder eventBuilder = CoreEvent.builder(testEvent());
    String flowVars = "flowVars.myVar";
    assertThat(expressionManager.evaluate(flowVars, eventBuilder.build()).getValue(), nullValue());
    String value = "Leda";
    eventBuilder.addVariable(MY_VAR, value);
    assertThat(expressionManager.evaluate(flowVars, eventBuilder.build()).getValue(), is(value));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Matchers.containsString(org.hamcrest.Matchers.containsString) Description(io.qameta.allure.Description) Test(org.junit.Test)

Aggregations

Description (io.qameta.allure.Description)117 Test (org.junit.Test)111 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)41 Matchers.containsString (org.hamcrest.Matchers.containsString)15 Message (org.mule.runtime.api.message.Message)13 TypedValue (org.mule.runtime.api.metadata.TypedValue)13 RoutingPair (org.mule.runtime.core.internal.routing.ForkJoinStrategy.RoutingPair)12 MessageProcessorChain (org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain)12 OperationParameters (org.mule.runtime.extension.api.client.OperationParameters)12 Matchers.anyString (org.mockito.Matchers.anyString)8 List (java.util.List)7 MavenConfiguration (org.mule.maven.client.api.model.MavenConfiguration)7 Processor (org.mule.runtime.core.api.processor.Processor)7 RemoteRepository (org.mule.maven.client.api.model.RemoteRepository)6 Event (org.mule.runtime.api.event.Event)6 ReactiveProcessor (org.mule.runtime.core.api.processor.ReactiveProcessor)6 BaseEventContext (org.mule.runtime.core.privileged.event.BaseEventContext)6 InternalProcessor (org.mule.runtime.core.privileged.processor.InternalProcessor)6 SmallTest (org.mule.tck.size.SmallTest)6 TestTransaction (org.mule.tck.testmodels.mule.TestTransaction)6