use of io.qameta.allure.Description in project mule by mulesoft.
the class DefaultExpressionManagerTestCase 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 #[payload]", event, TEST_CONNECTOR_LOCATION, NULL_BINDING_CONTEXT), is("this is hello"));
assertThat(expressionManager.parseLogTemplate("this is #[mel: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 DefaultExpressionManagerTestCase method parse.
@Test
@Description("Verifies that parsing works for plain String scenarios.")
public void parse() throws MuleException {
String expression = "this is a test";
assertThat(expressionManager.parse(expression, testEvent(), TEST_CONNECTOR_LOCATION), is(expression));
}
use of io.qameta.allure.Description in project mule by mulesoft.
the class DefaultExpressionManagerTestCase method transformationNotNeeded.
@Test
@Description("Verifies that a simple transformation works even when it's not required.")
public void transformationNotNeeded() throws MuleException {
String expression = "payload";
TypedValue result = expressionManager.evaluate(expression, STRING, builder().build(), testEvent());
assertThat(result.getValue(), is(TEST_PAYLOAD));
assertThat(result.getDataType(), is(STRING));
}
use of io.qameta.allure.Description in project mule by mulesoft.
the class DefaultExpressionManagerTestCase method transformation.
@Test
@Description("Verifies that a simple transformation works.")
public void transformation() throws MuleException {
String expression = "payload";
TypedValue result = expressionManager.evaluate(expression, BYTE_ARRAY, builder().build(), testEvent());
assertThat(result.getValue(), is(TEST_PAYLOAD.getBytes()));
assertThat(result.getDataType(), is(BYTE_ARRAY));
}
use of io.qameta.allure.Description in project mule by mulesoft.
the class DefaultExpressionManagerTestCase method globals.
@Test
@Description("Verifies that global bindings can be added.")
public void globals() {
DataType integerType = fromType(Integer.class);
ExpressionFunction multiply = new ExpressionFunction() {
@Override
public Object call(Object[] objects, BindingContext bindingContext) {
return ((Integer) objects[0]) * ((Integer) objects[1]);
}
@Override
public Optional<DataType> returnType() {
return of(integerType);
}
@Override
public List<FunctionParameter> parameters() {
return asList(new FunctionParameter("x", integerType), new FunctionParameter("y", integerType));
}
};
BindingContext globalContext = builder().addBinding("aNum", new TypedValue<>(4, fromType(Integer.class))).addBinding("times", new TypedValue<>(multiply, fromFunction(multiply))).build();
expressionManager.addGlobalBindings(globalContext);
TypedValue result = expressionManager.evaluate("aNum times 5");
assertThat(result.getValue(), is(20));
expressionManager.addGlobalBindings(builder().addBinding("otherNum", new TypedValue(3, integerType)).build());
result = expressionManager.evaluate("(times(7, 3) + otherNum) / aNum");
assertThat(result.getValue(), is(6));
}
Aggregations