java.util.stream.StreamTestDataProvider Java Examples
The following examples show how to use
java.util.stream.StreamTestDataProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SliceOpTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class, groups = { "serialization-hostile" }) public void testSkipOps(String name, TestData.OfRef<Integer> data) { List<Integer> skips = sizes(data.size()); for (int s : skips) { setContext("skip", s); testSliceMulti(data, sliceSize(data.size(), s), st -> st.skip(s), st -> st.skip(s), st -> st.skip(s), st -> st.skip(s)); testSliceMulti(data, sliceSize(sliceSize(data.size(), s), s/2), st -> st.skip(s).skip(s / 2), st -> st.skip(s).skip(s / 2), st -> st.skip(s).skip(s / 2), st -> st.skip(s).skip(s / 2)); } }
Example #2
Source File: SliceOpTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class, groups = { "serialization-hostile" }) public void testSkipLimitOps(String name, TestData.OfRef<Integer> data) { List<Integer> skips = sizes(data.size()); List<Integer> limits = skips; for (int s : skips) { setContext("skip", s); for (int l : limits) { setContext("limit", l); testSliceMulti(data, sliceSize(sliceSize(data.size(), s), 0, l), st -> st.skip(s).limit(l), st -> st.skip(s).limit(l), st -> st.skip(s).limit(l), st -> st.skip(s).limit(l)); } } }
Example #3
Source File: SliceOpTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class, groups = { "serialization-hostile" }) public void testSkipOps(String name, TestData.OfRef<Integer> data) { List<Integer> skips = sizes(data.size()); for (int s : skips) { setContext("skip", s); testSliceMulti(data, sliceSize(data.size(), s), st -> st.skip(s), st -> st.skip(s), st -> st.skip(s), st -> st.skip(s)); testSliceMulti(data, sliceSize(sliceSize(data.size(), s), s/2), st -> st.skip(s).skip(s / 2), st -> st.skip(s).skip(s / 2), st -> st.skip(s).skip(s / 2), st -> st.skip(s).skip(s / 2)); } }
Example #4
Source File: TabulatorsTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testSimpleGroupBy(String name, TestData.OfRef<Integer> data) throws ReflectiveOperationException { Function<Integer, Integer> classifier = i -> i % 3; // Single-level groupBy exerciseMapTabulation(data, groupingBy(classifier), new GroupedMapAssertion<>(classifier, HashMap.class, new ListAssertion<>())); exerciseMapTabulation(data, groupingByConcurrent(classifier), new GroupedMapAssertion<>(classifier, ConcurrentHashMap.class, new ListAssertion<>())); // With explicit constructors exerciseMapTabulation(data, groupingBy(classifier, TreeMap::new, toCollection(HashSet::new)), new GroupedMapAssertion<>(classifier, TreeMap.class, new CollectionAssertion<Integer>(HashSet.class, false))); exerciseMapTabulation(data, groupingByConcurrent(classifier, ConcurrentSkipListMap::new, toCollection(HashSet::new)), new GroupedMapAssertion<>(classifier, ConcurrentSkipListMap.class, new CollectionAssertion<Integer>(HashSet.class, false))); }
Example #5
Source File: TabulatorsTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testSimpleGroupBy(String name, TestData.OfRef<Integer> data) throws ReflectiveOperationException { Function<Integer, Integer> classifier = i -> i % 3; // Single-level groupBy exerciseMapTabulation(data, groupingBy(classifier), new GroupedMapAssertion<>(classifier, HashMap.class, new ListAssertion<>())); exerciseMapTabulation(data, groupingByConcurrent(classifier), new GroupedMapAssertion<>(classifier, ConcurrentHashMap.class, new ListAssertion<>())); // With explicit constructors exerciseMapTabulation(data, groupingBy(classifier, TreeMap::new, toCollection(HashSet::new)), new GroupedMapAssertion<>(classifier, TreeMap.class, new CollectionAssertion<Integer>(HashSet.class, false))); exerciseMapTabulation(data, groupingByConcurrent(classifier, ConcurrentSkipListMap::new, toCollection(HashSet::new)), new GroupedMapAssertion<>(classifier, ConcurrentSkipListMap.class, new CollectionAssertion<Integer>(HashSet.class, false))); }
Example #6
Source File: GroupByOpTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testOps(String name, TestData.OfRef<Integer> data) { // @@@ More things to test here: // - Every value in data is present in right bucket // - Total number of values equals size of data for (MapperData<Integer, ?> md : getMapperData(data)) { Collector<Integer, ?, Map<Object, List<Integer>>> tab = Collectors.groupingBy(md.m); Map<Object, List<Integer>> result = withData(data) .terminal(s -> s, s -> s.collect(tab)) .resultAsserter((act, exp, ord, par) -> { if (par & !ord) { GroupByOpTest.assertMultiMapEquals(act, exp); } else { GroupByOpTest.assertObjectEquals(act, exp); } }) .exercise(); assertEquals(result.keySet().size(), md.expectedSize); } }
Example #7
Source File: TabulatorsTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testTwoLevelPartition(String name, TestData.OfRef<Integer> data) throws ReflectiveOperationException { Predicate<Integer> classifier = i -> i % 3 == 0; Predicate<Integer> classifier2 = i -> i % 7 == 0; // Two level partition exerciseMapTabulation(data, partitioningBy(classifier, partitioningBy(classifier2)), new PartitionAssertion<>(classifier, new PartitionAssertion(classifier2, new ListAssertion<>()))); // Two level partition with reduce exerciseMapTabulation(data, partitioningBy(classifier, reducing(0, Integer::sum)), new PartitionAssertion<>(classifier, new ReduceAssertion<>(0, LambdaTestHelpers.identity(), Integer::sum))); }
Example #8
Source File: TabulatorsTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testTwoLevelPartition(String name, TestData.OfRef<Integer> data) throws ReflectiveOperationException { Predicate<Integer> classifier = i -> i % 3 == 0; Predicate<Integer> classifier2 = i -> i % 7 == 0; // Two level partition exerciseMapTabulation(data, partitioningBy(classifier, partitioningBy(classifier2)), new PartitionAssertion<>(classifier, new PartitionAssertion(classifier2, new ListAssertion<>()))); // Two level partition with reduce exerciseMapTabulation(data, partitioningBy(classifier, reducing(0, Integer::sum)), new PartitionAssertion<>(classifier, new ReduceAssertion<>(0, LambdaTestHelpers.identity(), Integer::sum))); }
Example #9
Source File: SliceOpTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class, groups = { "serialization-hostile" }) public void testSkipOps(String name, TestData.OfRef<Integer> data) { List<Integer> skips = sizes(data.size()); for (int s : skips) { setContext("skip", s); testSliceMulti(data, sliceSize(data.size(), s), st -> st.skip(s), st -> st.skip(s), st -> st.skip(s), st -> st.skip(s)); testSliceMulti(data, sliceSize(sliceSize(data.size(), s), s/2), st -> st.skip(s).skip(s / 2), st -> st.skip(s).skip(s / 2), st -> st.skip(s).skip(s / 2), st -> st.skip(s).skip(s / 2)); } }
Example #10
Source File: GroupByOpTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testOps(String name, TestData.OfRef<Integer> data) { // @@@ More things to test here: // - Every value in data is present in right bucket // - Total number of values equals size of data for (MapperData<Integer, ?> md : getMapperData(data)) { Collector<Integer, ?, Map<Object, List<Integer>>> tab = Collectors.groupingBy(md.m); Map<Object, List<Integer>> result = withData(data) .terminal(s -> s, s -> s.collect(tab)) .resultAsserter((act, exp, ord, par) -> { if (par & !ord) { GroupByOpTest.assertMultiMapEquals(act, exp); } else { GroupByOpTest.assertObjectEquals(act, exp); } }) .exercise(); assertEquals(result.keySet().size(), md.expectedSize); } }
Example #11
Source File: GroupByOpTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testOps(String name, TestData.OfRef<Integer> data) { // @@@ More things to test here: // - Every value in data is present in right bucket // - Total number of values equals size of data for (MapperData<Integer, ?> md : getMapperData(data)) { Collector<Integer, ?, Map<Object, List<Integer>>> tab = Collectors.groupingBy(md.m); Map<Object, List<Integer>> result = withData(data) .terminal(s -> s, s -> s.collect(tab)) .resultAsserter((act, exp, ord, par) -> { if (par & !ord) { GroupByOpTest.assertMultiMapEquals(act, exp); } else { GroupByOpTest.assertObjectEquals(act, exp); } }) .exercise(); assertEquals(result.keySet().size(), md.expectedSize); } }
Example #12
Source File: TabulatorsTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testTwoLevelPartition(String name, TestData.OfRef<Integer> data) throws ReflectiveOperationException { Predicate<Integer> classifier = i -> i % 3 == 0; Predicate<Integer> classifier2 = i -> i % 7 == 0; // Two level partition exerciseMapTabulation(data, partitioningBy(classifier, partitioningBy(classifier2)), new PartitionAssertion<>(classifier, new PartitionAssertion(classifier2, new ListAssertion<>()))); // Two level partition with reduce exerciseMapTabulation(data, partitioningBy(classifier, reducing(0, Integer::sum)), new PartitionAssertion<>(classifier, new ReduceAssertion<>(0, LambdaTestHelpers.identity(), Integer::sum))); }
Example #13
Source File: SliceOpTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class, groups = { "serialization-hostile" }) public void testSkipLimitOps(String name, TestData.OfRef<Integer> data) { List<Integer> skips = sizes(data.size()); List<Integer> limits = skips; for (int s : skips) { setContext("skip", s); for (int l : limits) { setContext("limit", l); testSliceMulti(data, sliceSize(sliceSize(data.size(), s), 0, l), st -> st.skip(s).limit(l), st -> st.skip(s).limit(l), st -> st.skip(s).limit(l), st -> st.skip(s).limit(l)); } } }
Example #14
Source File: TabulatorsTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testSimpleGroupBy(String name, TestData.OfRef<Integer> data) throws ReflectiveOperationException { Function<Integer, Integer> classifier = i -> i % 3; // Single-level groupBy exerciseMapTabulation(data, groupingBy(classifier), new GroupedMapAssertion<>(classifier, HashMap.class, new ListAssertion<>())); exerciseMapTabulation(data, groupingByConcurrent(classifier), new GroupedMapAssertion<>(classifier, ConcurrentHashMap.class, new ListAssertion<>())); // With explicit constructors exerciseMapTabulation(data, groupingBy(classifier, TreeMap::new, toCollection(HashSet::new)), new GroupedMapAssertion<>(classifier, TreeMap.class, new CollectionAssertion<Integer>(HashSet.class, false))); exerciseMapTabulation(data, groupingByConcurrent(classifier, ConcurrentSkipListMap::new, toCollection(HashSet::new)), new GroupedMapAssertion<>(classifier, ConcurrentSkipListMap.class, new CollectionAssertion<Integer>(HashSet.class, false))); }
Example #15
Source File: TabulatorsTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testSimpleGroupBy(String name, TestData.OfRef<Integer> data) throws ReflectiveOperationException { Function<Integer, Integer> classifier = i -> i % 3; // Single-level groupBy exerciseMapTabulation(data, groupingBy(classifier), new GroupedMapAssertion<>(classifier, HashMap.class, new ListAssertion<>())); exerciseMapTabulation(data, groupingByConcurrent(classifier), new GroupedMapAssertion<>(classifier, ConcurrentHashMap.class, new ListAssertion<>())); // With explicit constructors exerciseMapTabulation(data, groupingBy(classifier, TreeMap::new, toCollection(HashSet::new)), new GroupedMapAssertion<>(classifier, TreeMap.class, new CollectionAssertion<Integer>(HashSet.class, false))); exerciseMapTabulation(data, groupingByConcurrent(classifier, ConcurrentSkipListMap::new, toCollection(HashSet::new)), new GroupedMapAssertion<>(classifier, ConcurrentSkipListMap.class, new CollectionAssertion<Integer>(HashSet.class, false))); }
Example #16
Source File: SliceOpTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class, groups = { "serialization-hostile" }) public void testSkipOps(String name, TestData.OfRef<Integer> data) { List<Integer> skips = sizes(data.size()); for (int s : skips) { setContext("skip", s); testSliceMulti(data, sliceSize(data.size(), s), st -> st.skip(s), st -> st.skip(s), st -> st.skip(s), st -> st.skip(s)); testSliceMulti(data, sliceSize(sliceSize(data.size(), s), s/2), st -> st.skip(s).skip(s / 2), st -> st.skip(s).skip(s / 2), st -> st.skip(s).skip(s / 2), st -> st.skip(s).skip(s / 2)); } }
Example #17
Source File: ConcatOpTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testOps(String name, TestData.OfRef<Integer> data) { exerciseOpsInt(data, s -> Stream.concat(s, data.stream()), s -> IntStream.concat(s, data.stream().mapToInt(Integer::intValue)), s -> LongStream.concat(s, data.stream().mapToLong(Integer::longValue)), s -> DoubleStream.concat(s, data.stream().mapToDouble(Integer::doubleValue))); }
Example #18
Source File: ReduceTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testOps(String name, TestData.OfRef<Integer> data) { assertEquals(0, (int) exerciseTerminalOps(data, s -> s.filter(pFalse), s -> s.reduce(0, rPlus, rPlus))); Optional<Integer> seedless = exerciseTerminalOps(data, s -> s.reduce(rPlus)); Integer folded = exerciseTerminalOps(data, s -> s.reduce(0, rPlus, rPlus)); assertEquals(folded, seedless.orElse(0)); seedless = exerciseTerminalOps(data, s -> s.reduce(rMin)); folded = exerciseTerminalOps(data, s -> s.reduce(Integer.MAX_VALUE, rMin, rMin)); assertEquals(folded, seedless.orElse(Integer.MAX_VALUE)); seedless = exerciseTerminalOps(data, s -> s.reduce(rMax)); folded = exerciseTerminalOps(data, s -> s.reduce(Integer.MIN_VALUE, rMax, rMax)); assertEquals(folded, seedless.orElse(Integer.MIN_VALUE)); seedless = exerciseTerminalOps(data, s -> s.map(mDoubler), s -> s.reduce(rPlus)); folded = exerciseTerminalOps(data, s -> s.map(mDoubler), s -> s.reduce(0, rPlus, rPlus)); assertEquals(folded, seedless.orElse(0)); seedless = exerciseTerminalOps(data, s -> s.map(mDoubler), s -> s.reduce(rMin)); folded = exerciseTerminalOps(data, s -> s.map(mDoubler), s -> s.reduce(Integer.MAX_VALUE, rMin, rMin)); assertEquals(folded, seedless.orElse(Integer.MAX_VALUE)); seedless = exerciseTerminalOps(data, s -> s.map(mDoubler), s -> s.reduce(rMax)); folded = exerciseTerminalOps(data, s -> s.map(mDoubler), s -> s.reduce(Integer.MIN_VALUE, rMax, rMax)); assertEquals(folded, seedless.orElse(Integer.MIN_VALUE)); }
Example #19
Source File: MatchOpTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testStream(String name, TestData.OfRef<Integer> data) { for (Predicate<Integer> p : INTEGER_PREDICATES) { setContext("p", p); for (Kind kind : Kind.values()) { setContext("kind", kind); exerciseTerminalOps(data, this.<Integer>kinds().get(kind).apply(p)); exerciseTerminalOps(data, s -> s.filter(pFalse), this.<Integer>kinds().get(kind).apply(p)); exerciseTerminalOps(data, s -> s.filter(pEven), this.<Integer>kinds().get(kind).apply(p)); } } }
Example #20
Source File: CountTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testOps(String name, TestData.OfRef<Integer> data) { AtomicLong expectedCount = new AtomicLong(); data.stream().forEach(e -> expectedCount.incrementAndGet()); withData(data). terminal(Stream::count). expectedResult(expectedCount.get()). exercise(); }
Example #21
Source File: DistinctOpTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testDistinctSorted(String name, TestData.OfRef<Integer> data) { Collection<Integer> result = withData(data) .stream(s -> s.distinct().sorted(), new CollectorOps.TestParallelSizedOp<>()) .exercise(); assertUnique(result); assertSorted(result); }
Example #22
Source File: DistinctOpTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "withNull:StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testOpWithNull(String name, TestData.OfRef<Integer> data) { Collection<Integer> node = exerciseOps(data, Stream::distinct); assertUnique(node); node = withData(data). stream(s -> s.unordered().distinct()). exercise(); assertUnique(node); node = exerciseOps(data, s -> s.distinct().distinct()); assertUnique(node); }
Example #23
Source File: TabulatorsTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testSimplePartition(String name, TestData.OfRef<Integer> data) throws ReflectiveOperationException { Predicate<Integer> classifier = i -> i % 3 == 0; // Single-level partition to downstream List exerciseMapTabulation(data, partitioningBy(classifier), new PartitionAssertion<>(classifier, new ListAssertion<>())); exerciseMapTabulation(data, partitioningBy(classifier, toList()), new PartitionAssertion<>(classifier, new ListAssertion<>())); }
Example #24
Source File: SequentialOpTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings({"rawtypes", "unchecked"}) @Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testMixedSeqPar(String name, TestData.OfRef<Integer> data) { Function<Integer, Integer> id = LambdaTestHelpers.identity(); UnaryOperator<Stream<Integer>>[] changers = new UnaryOperator[] { (UnaryOperator<Stream<Integer>>) s -> s, (UnaryOperator<Stream<Integer>>) s -> s.sequential(), (UnaryOperator<Stream<Integer>>) s -> s.parallel(), (UnaryOperator<Stream<Integer>>) s -> s.unordered() }; UnaryOperator<Stream<Integer>>[] stuff = new UnaryOperator[] { (UnaryOperator<Stream<Integer>>) s -> s, (UnaryOperator<Stream<Integer>>) s -> s.map(id), (UnaryOperator<Stream<Integer>>) s -> s.sorted(Comparator.naturalOrder()), (UnaryOperator<Stream<Integer>>) s -> s.map(id).sorted(Comparator.naturalOrder()).map(id), (UnaryOperator<Stream<Integer>>) s -> s.filter(LambdaTestHelpers.pEven).sorted(Comparator.naturalOrder()).map(id), }; for (int c1Index = 0; c1Index < changers.length; c1Index++) { setContext("c1Index", c1Index); UnaryOperator<Stream<Integer>> c1 = changers[c1Index]; for (int s1Index = 0; s1Index < stuff.length; s1Index++) { setContext("s1Index", s1Index); UnaryOperator<Stream<Integer>> s1 = stuff[s1Index]; for (int c2Index = 0; c2Index < changers.length; c2Index++) { setContext("c2Index", c2Index); UnaryOperator<Stream<Integer>> c2 = changers[c2Index]; for (int s2Index = 0; s2Index < stuff.length; s2Index++) { setContext("s2Index", s2Index); UnaryOperator<Stream<Integer>> s2 = stuff[s2Index]; UnaryOperator<Stream<Integer>> composed = s -> s2.apply(c2.apply(s1.apply(c1.apply(s)))); exerciseOps(data, composed); } } } } }
Example #25
Source File: MatchOpTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testStream(String name, TestData.OfRef<Integer> data) { for (Predicate<Integer> p : INTEGER_PREDICATES) { setContext("p", p); for (Kind kind : Kind.values()) { setContext("kind", kind); exerciseTerminalOps(data, this.<Integer>kinds().get(kind).apply(p)); exerciseTerminalOps(data, s -> s.filter(pFalse), this.<Integer>kinds().get(kind).apply(p)); exerciseTerminalOps(data, s -> s.filter(pEven), this.<Integer>kinds().get(kind).apply(p)); } } }
Example #26
Source File: DistinctOpTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testDistinctDistinct(String name, TestData.OfRef<Integer> data) { Collection<Integer> result = exerciseOpsInt( data, s -> s.distinct().distinct(), s -> s.distinct().distinct(), s -> s.distinct().distinct(), s -> s.distinct().distinct()); assertUnique(result); }
Example #27
Source File: CountTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testOps(String name, TestData.OfRef<Integer> data) { AtomicLong expectedCount = new AtomicLong(); data.stream().forEach(e -> expectedCount.incrementAndGet()); withData(data). terminal(Stream::count). expectedResult(expectedCount.get()). exercise(); }
Example #28
Source File: DistinctOpTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testOp(String name, TestData.OfRef<Integer> data) { Collection<Integer> result = exerciseOpsInt( data, Stream::distinct, IntStream::distinct, LongStream::distinct, DoubleStream::distinct); assertUnique(result); assertTrue((data.size() > 0) ? result.size() > 0 : result.size() == 0); assertTrue(result.size() <= data.size()); }
Example #29
Source File: ConcatOpTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testOps(String name, TestData.OfRef<Integer> data) { exerciseOpsInt(data, s -> Stream.concat(s, data.stream()), s -> IntStream.concat(s, data.stream().mapToInt(Integer::intValue)), s -> LongStream.concat(s, data.stream().mapToLong(Integer::longValue)), s -> DoubleStream.concat(s, data.stream().mapToDouble(Integer::doubleValue))); }
Example #30
Source File: MatchOpTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class) public void testStream(String name, TestData.OfRef<Integer> data) { for (Predicate<Integer> p : INTEGER_PREDICATES) { setContext("p", p); for (Kind kind : Kind.values()) { setContext("kind", kind); exerciseTerminalOps(data, this.<Integer>kinds().get(kind).apply(p)); exerciseTerminalOps(data, s -> s.filter(pFalse), this.<Integer>kinds().get(kind).apply(p)); exerciseTerminalOps(data, s -> s.filter(pEven), this.<Integer>kinds().get(kind).apply(p)); } } }