use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class ExtendedExpressionLanguageAdapterTestCase method flowNameVariable.
@Test
@Description("Verifies that the Flow name variable works for MVEL and DW.")
public void flowNameVariable() throws MuleException {
String expression = "flow.name";
String myFlowName = "myFlowName";
TypedValue mvelResult = expressionLanguageAdapter.evaluate(melify(expression), testEvent(), fromSingleComponent(myFlowName), emptyBindingContext);
assertThat(mvelResult.getValue(), is(myFlowName));
TypedValue dwResult = expressionLanguageAdapter.evaluate(expression, testEvent(), fromSingleComponent(myFlowName), emptyBindingContext);
assertThat(dwResult.getValue(), is(myFlowName));
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class DefaultExpressionManagerMelDefaultTestCase method transformation.
@Test
@Description("Verifies that a simple transformation works. MVEL ignores expectedDataType")
public void transformation() throws MuleException {
String expression = "payload";
TypedValue result = expressionManager.evaluate(expression, BYTE_ARRAY, builder().build(), testEvent());
assertThat(result.getValue(), is(TEST_PAYLOAD));
assertThat(result.getDataType(), is(STRING));
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class DefaultExpressionManagerMelDefaultTestCase 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 org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class GlobalBindingContextProviderTestCase method variable.
@Test
public void variable() {
TypedValue result = muleContext.getExpressionManager().evaluate("number");
assertThat(result.getValue(), is(1));
assertThat(result.getDataType(), is(assignableTo(NUMBER)));
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class MessageContextTestCase method payloadAsType.
@Test
public void payloadAsType() throws Exception {
InternalMessage transformedMessage = mock(InternalMessage.class, RETURNS_DEEP_STUBS);
final TypedValue<Object> expectedPayload = new TypedValue<>(new Object(), OBJECT);
when(transformedMessage.getPayload()).thenReturn(expectedPayload);
TransformationService transformationService = mock(TransformationService.class);
muleContext.setTransformationService(transformationService);
when(transformationService.transform(any(InternalMessage.class), any(DataType.class))).thenReturn(transformedMessage);
assertSame(transformedMessage.getPayload().getValue(), evaluate("message.payloadAs(org.mule.tck.testmodels.fruit.Banana)", event));
}
Aggregations