use of org.mule.runtime.api.streaming.object.CursorIteratorProvider in project mule by mulesoft.
the class ObjectStreamingExtensionTestCase method getObjectStreamWithTargetVariable.
@Test
@Description("Stores an object stream in a variable leaving without modifying the original payload")
public void getObjectStreamWithTargetVariable() throws Exception {
CoreEvent event = flowRunner("getStreamWithTarget").keepStreamsOpen().withPayload(data).run();
assertThat(event.getVariables().get(MY_STREAM_VAR).getValue(), is(instanceOf(CursorIteratorProvider.class)));
assertThat(IteratorUtils.toList(((CursorIteratorProvider) event.getVariables().get(MY_STREAM_VAR).getValue()).openCursor()), equalTo(data));
assertThat(event.getMessage().getPayload().getValue(), is(instanceOf(List.class)));
assertThat(event.getMessage().getPayload().getValue(), equalTo(data));
}
use of org.mule.runtime.api.streaming.object.CursorIteratorProvider 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));
}
Aggregations