Package com.google.common.testing
Class CollectorTester<T,A,R>
java.lang.Object
com.google.common.testing.CollectorTester<T,A,R>
Tester for
Collector
implementations.
Example usage:
CollectorTester.of(Collectors.summingInt(Integer::parseInt)) .expectCollects(3, "1", "2") .expectCollects(10, "1", "4", "3", "2") .expectCollects(5, "-3", "0", "8");
- Since:
- 21.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enum
Different orderings for combining the elements of an input array, which must all produce the same result. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
CollectorTester
(Collector<T, A, R> collector, BiPredicate<? super R, ? super R> equivalence) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
assertEquivalent
(R expected, R actual) private void
doExpectCollects
(R expectedResult, List<T> inputs) final CollectorTester
<T, A, R> expectCollects
(R expectedResult, T... inputs) Verifies that the specified expected result is always produced by collecting the specified inputs, regardless of how the elements are divided.static <T,
A, R> CollectorTester <T, A, R> Creates aCollectorTester
for the specifiedCollector
.static <T,
A, R> CollectorTester <T, A, R> of
(Collector<T, A, R> collector, BiPredicate<? super R, ? super R> equivalence) Creates aCollectorTester
for the specifiedCollector
.
-
Field Details
-
collector
-
equivalence
-
-
Constructor Details
-
CollectorTester
-
-
Method Details
-
of
Creates aCollectorTester
for the specifiedCollector
. The result of theCollector
will be compared to the expected value usingObject.equals(java.lang.Object)
. -
of
public static <T,A, CollectorTester<T,R> A, ofR> (Collector<T, A, R> collector, BiPredicate<? super R, ? super R> equivalence) Creates aCollectorTester
for the specifiedCollector
. The result of theCollector
will be compared to the expected value using the specifiedequivalence
. -
expectCollects
Verifies that the specified expected result is always produced by collecting the specified inputs, regardless of how the elements are divided. -
doExpectCollects
-
assertEquivalent
-