use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class DataWeaveExpressionLanguageAdaptorTestCase method accessRegistryBean.
@Test
public void accessRegistryBean() throws MuleException {
CoreEvent event = testEvent();
when(registry.lookupByName("myBean")).thenReturn(of(new MyBean("DataWeave")));
TypedValue evaluate = expressionLanguage.evaluate("app.registry.myBean.name", event, BindingContext.builder().build());
assertThat(evaluate.getValue(), is("DataWeave"));
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class DataWeaveExpressionLanguageAdaptorTestCase method accessRegistryCglibAnnotatedBean.
@Test
public void accessRegistryCglibAnnotatedBean() throws Exception {
CoreEvent event = testEvent();
MyBean annotatedMyBean = (MyBean) addAnnotationsToClass(MyBean.class).newInstance();
annotatedMyBean.setName("DataWeave");
when(registry.lookupByName("myBean")).thenReturn(of(annotatedMyBean));
TypedValue evaluate = expressionLanguage.evaluate("app.registry.myBean", DataType.fromType(MyBean.class), event, fromSingleComponent("flow"), BindingContext.builder().build(), false);
assertThat(evaluate.getValue(), is(instanceOf(MyBean.class)));
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class DataWeaveExpressionLanguageAdaptorTestCase method variablesBindings.
@Test
public void variablesBindings() throws Exception {
CoreEvent event = getEventWithError(empty());
String var1 = "var1";
String var2 = "var2";
when(event.getVariables().keySet()).thenReturn(Sets.newHashSet(var1, var2));
TypedValue varValue = new TypedValue<>(null, OBJECT);
when(event.getVariables()).thenReturn(ImmutableMap.<String, TypedValue<?>>builder().put(var1, varValue).put(var2, varValue).build());
TypedValue result = expressionLanguage.evaluate(VARS, event, BindingContext.builder().build());
assertThat(result.getValue(), is(instanceOf(Map.class)));
assertThat((Map<String, TypedValue>) result.getValue(), hasEntry(var1, varValue));
assertThat((Map<String, TypedValue>) result.getValue(), hasEntry(var2, varValue));
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class DataWeaveExpressionLanguageAdaptorTestCase method accessMuleVersion.
@Test
public void accessMuleVersion() throws MuleException {
CoreEvent event = testEvent();
when(registry.lookupByName("myBean")).thenReturn(of(new MyBean("DataWeave")));
TypedValue evaluate = expressionLanguage.evaluate("mule.version", event, BindingContext.builder().build());
assertThat(evaluate.getValue(), is(MuleManifest.getProductVersion()));
}
use of org.mule.runtime.api.metadata.TypedValue in project mule by mulesoft.
the class DataWeaveExpressionLanguageAdaptorTestCase method withPrefixExpression.
@Test
public void withPrefixExpression() throws Exception {
TypedValue result = expressionLanguage.evaluate("#[dw:\"hey\"]", testEvent(), BindingContext.builder().build());
assertThat(result.getValue(), is("hey"));
assertThat(result.getDataType(), is(assignableTo(STRING)));
}
Aggregations