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")));
}
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);
}
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())));
}
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));
}
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));
}
Aggregations