use of io.crate.testing.BatchIteratorTester in project crate by crate.
the class AsyncOperationBatchIteratorTest method runTest.
private void runTest(Supplier<BatchIterator> sourceSupplier) throws Exception {
Supplier<BatchIterator> biSupplier = () -> {
BatchIterator source = sourceSupplier.get();
Input<?> input = source.rowData().get(0);
BatchAccumulator<Row, Iterator<? extends Row>> accumulator = new DummyBatchAccumulator(input);
return new AsyncOperationBatchIterator(source, 1, accumulator);
};
List<Object[]> expectedResult = new ArrayList<>();
for (int i = 0; i < 10; i++) {
expectedResult.add(new Object[] { i * 3 });
}
BatchIteratorTester tester = new BatchIteratorTester(biSupplier);
tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
use of io.crate.testing.BatchIteratorTester in project crate by crate.
the class CollectingBatchIteratorTest method testCollectingBatchIterator.
@Test
public void testCollectingBatchIterator() throws Exception {
BatchIteratorTester tester = new BatchIteratorTester(() -> CollectingBatchIterator.summingLong(TestingBatchIterators.range(0L, 10L)));
tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
use of io.crate.testing.BatchIteratorTester in project crate by crate.
the class CompositeBatchIteratorTest method testCompositeBatchIterator.
@Test
public void testCompositeBatchIterator() throws Exception {
BatchIteratorTester tester = new BatchIteratorTester(() -> new CompositeBatchIterator(TestingBatchIterators.range(0, 5), TestingBatchIterators.range(5, 10)));
tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
use of io.crate.testing.BatchIteratorTester in project crate by crate.
the class CompositeBatchIteratorTest method testCompositeBatchIteratorWithBatchedSources.
@Test
public void testCompositeBatchIteratorWithBatchedSources() throws Exception {
List<Object[]> expectedResult = new ArrayList<>();
// consumes the unbatched/loaded iterator first
expectedResult.add(new Object[] { 5 });
expectedResult.add(new Object[] { 6 });
expectedResult.add(new Object[] { 7 });
expectedResult.add(new Object[] { 8 });
expectedResult.add(new Object[] { 9 });
expectedResult.add(new Object[] { 0 });
expectedResult.add(new Object[] { 1 });
expectedResult.add(new Object[] { 2 });
expectedResult.add(new Object[] { 3 });
expectedResult.add(new Object[] { 4 });
BatchIteratorTester tester = new BatchIteratorTester(() -> new CompositeBatchIterator(new CloseAssertingBatchIterator(new BatchSimulatingIterator(TestingBatchIterators.range(0, 5), 2, 6, null)), TestingBatchIterators.range(5, 10)));
tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
use of io.crate.testing.BatchIteratorTester in project crate by crate.
the class FilteringBatchIteratorTest method testFilteringBatchIterator.
@Test
public void testFilteringBatchIterator() throws Exception {
List<Object[]> expectedResult = IntStream.iterate(0, l -> l + 2).limit(10).mapToObj(l -> new Object[] { l }).collect(Collectors.toList());
BatchIteratorTester tester = new BatchIteratorTester(() -> new FilteringBatchIterator(TestingBatchIterators.range(0, 20), evenRow));
tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
Aggregations