Class CollectorTester<T extends @Nullable Object, A extends @Nullable Object, R extends @Nullable Object>
java.lang.Object
com.google.common.testing.CollectorTester<T,A,R>
@GwtCompatible
@NullMarked
public final class CollectorTester<T extends @Nullable Object, A extends @Nullable Object, R extends @Nullable Object>
extends Object
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
- Author:
- Louis Wasserman
-
Method Summary
Modifier and TypeMethodDescriptionfinal 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 extends @Nullable Object, A extends @Nullable Object, R extends @Nullable Object>
CollectorTester<T, A, R> Creates aCollectorTesterfor the specifiedCollector.static <T extends @Nullable Object, A extends @Nullable Object, R extends @Nullable Object>
CollectorTester<T, A, R> of(Collector<T, A, R> collector, BiPredicate<? super R, ? super R> equivalence) Creates aCollectorTesterfor the specifiedCollector.
-
Method Details
-
of
public static <T extends @Nullable Object, A extends @Nullable Object, R extends @Nullable Object> CollectorTester<T,A, ofR> (Collector<T, A, R> collector) Creates aCollectorTesterfor the specifiedCollector. The result of theCollectorwill be compared to the expected value usingObject.equals(java.lang.Object). -
of
public static <T extends @Nullable Object, A extends @Nullable Object, R extends @Nullable Object> CollectorTester<T,A, ofR> (Collector<T, A, R> collector, BiPredicate<? super R, ? super R> equivalence) Creates aCollectorTesterfor the specifiedCollector. The result of theCollectorwill be compared to the expected value using the specifiedequivalence. -
expectCollects
@SafeVarargs @CanIgnoreReturnValue public final CollectorTester<T,A, expectCollectsR> (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.
-