Search in sources :

Example 6 with CollectionDataType

use of org.mule.runtime.api.metadata.CollectionDataType in project mule by mulesoft.

the class StreamingUtilsTestCase method consumeTypedRepeatableIteratorPayload.

@Test
@Description("Test that repeatable iterator is consumed into a list while maintaining the collection data type")
public void consumeTypedRepeatableIteratorPayload() throws Exception {
    CursorIteratorProvider payload = asCursorProvider(TEST_LIST);
    DataType dataType = DataType.builder().collectionType(ArrayList.class).itemType(String.class).build();
    CoreEvent event = consumeRepeatablePayload(getEventBuilder().message(Message.builder().payload(new TypedValue<>(payload, dataType)).build()).build());
    assertConsumedObjectStream(payload, event);
    dataType = event.getMessage().getPayload().getDataType();
    assertThat(dataType, is(instanceOf(CollectionDataType.class)));
    assertThat(((CollectionDataType) dataType).getItemDataType(), equalTo(STRING));
}
Also used : InMemoryCursorIteratorProvider(org.mule.runtime.core.internal.streaming.object.InMemoryCursorIteratorProvider) CursorIteratorProvider(org.mule.runtime.api.streaming.object.CursorIteratorProvider) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) DataType(org.mule.runtime.api.metadata.DataType) CollectionDataType(org.mule.runtime.api.metadata.CollectionDataType) Description(io.qameta.allure.Description) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Aggregations

CollectionDataType (org.mule.runtime.api.metadata.CollectionDataType)6 DataType (org.mule.runtime.api.metadata.DataType)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 SmallTest (org.mule.tck.size.SmallTest)4 List (java.util.List)3 Message (org.mule.runtime.api.message.Message)3 TypeToken (com.google.common.reflect.TypeToken)2 MapDataType (org.mule.runtime.api.metadata.MapDataType)2 TypedValue (org.mule.runtime.api.metadata.TypedValue)2 CursorIteratorProvider (org.mule.runtime.api.streaming.object.CursorIteratorProvider)2 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)2 Description (io.qameta.allure.Description)1 Duration.ofMillis (java.time.Duration.ofMillis)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Optional.empty (java.util.Optional.empty)1