Search in sources :

Example 1 with QualifiedName

use of org.mule.weave.v2.model.structure.QualifiedName in project mule by mulesoft.

the class DataWeaveExpressionLanguageAdaptorTestCase method entrySetFunction.

@Test
public void entrySetFunction() throws Exception {
    final String key = "foo";
    final String value = "bar";
    CoreEvent event = eventBuilder(muleContext).message(Message.builder().value(singletonMap(key, value)).build()).build();
    TypedValue result = expressionLanguage.evaluate("dw::core::Objects::entrySet(payload)", event, BindingContext.builder().build());
    assertThat(result.getValue(), instanceOf(List.class));
    assertThat(((List) result.getValue()).get(0), instanceOf(Map.class));
    Map entry = (Map) ((List) result.getValue()).get(0);
    assertThat(entry.get("key"), instanceOf(QualifiedName.class));
    assertThat(((QualifiedName) entry.get("key")).name(), equalTo(key));
    assertThat(entry.get("value"), equalTo(value));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) QualifiedName(org.mule.weave.v2.model.structure.QualifiedName) Arrays.asList(java.util.Arrays.asList) List(java.util.List) Matchers.containsString(org.hamcrest.Matchers.containsString) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Collections.singletonMap(java.util.Collections.singletonMap) Collections.unmodifiableMap(java.util.Collections.unmodifiableMap) TypedValue(org.mule.runtime.api.metadata.TypedValue) Test(org.junit.Test)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 Arrays.asList (java.util.Arrays.asList)1 Collections.singletonMap (java.util.Collections.singletonMap)1 Collections.unmodifiableMap (java.util.Collections.unmodifiableMap)1 List (java.util.List)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Test (org.junit.Test)1 TypedValue (org.mule.runtime.api.metadata.TypedValue)1 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)1 QualifiedName (org.mule.weave.v2.model.structure.QualifiedName)1