Class AssertConsumeOnly<T>
java.lang.Object
org.soliscode.test.assertions.actions.AssertConsumeOnly<T>
- Type Parameters:
T
- element type
- All Implemented Interfaces:
Consumer<T>
,AssertAction
,AssertConsumer<T>
A consumer that checks that it only consumes objects from a specified set of objects, and not consuming any objects
not in the set. This consumer does not require that all of the objects in the set are consumed. Instead of
instantiating this class directly, the AssertActions
utility class should be used:
Consumer<Integer> consumer = AssertActions.consumeOnly(Set.of(1, 3, 5, 7));
This assertion action must be checked after the method it is passed to has completed, so the AssertAction.assertCheck()
method
will need to be explicitly called:
AssertConsumer<Integer> consumer = AssertActions.consumeOnly(Set.of(1, 3, 5, 7);
collection.forEach(consumer);
consumer.assertCheck();
- Since:
- 1.0
- Author:
- evanbergstrom
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAssertConsumeOnly
(@NotNull Iterable<T> expected) Creates a consumer that checks that it only consumes objects from a specified set of objects.AssertConsumeOnly
(@NotNull Iterable<T> expected, @Nullable String message) Creates a consumer that checks that it only consumes objects from a specified set of objects.AssertConsumeOnly
(@NotNull Iterable<T> expected, @Nullable Supplier<String> messageSupplier) Creates a consumer that checks that it only consumes objects from a specified set of objects. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.soliscode.test.assertions.actions.AssertAction
assertCheck
-
Constructor Details
-
AssertConsumeOnly
-
AssertConsumeOnly
public AssertConsumeOnly(@NotNull @NotNull Iterable<T> expected, @Nullable @Nullable String message) Creates a consumer that checks that it only consumes objects from a specified set of objects. This constructor allows specification of a string to be included in the exception of the assertion fails.- Parameters:
expected
- the set of objects that should be consumed.message
- the text to include in the exception.
-
AssertConsumeOnly
public AssertConsumeOnly(@NotNull @NotNull Iterable<T> expected, @Nullable @Nullable Supplier<String> messageSupplier) Creates a consumer that checks that it only consumes objects from a specified set of objects. This constructor allows specification of a supplier of a message to be included in the exception.- Parameters:
expected
- the set of objects that should be consumed.messageSupplier
- the supplier of the text to include in the exception.
-
-
Method Details
-
accept
-