Class CheckerBiConsumer<T,U>
java.lang.Object
util.AbstractChecker<BiConsumer<T,U>,CheckerBiConsumer<T,U>>
specialized_checkers.lambda.CheckerBiConsumer<T,U>
- Type Parameters:
T
- the type of the first argument to the BiConsumerU
- the type of the second argument to the BiConsumer
- All Implemented Interfaces:
InterfaceChecker<AbstractChecker<BiConsumer<T,
U>, CheckerBiConsumer<T, U>>, BiConsumer<T, U>>
A specialized checker for
BiConsumer
instances, providing fluent API methods
to assert various behaviors and properties of a BiConsumer, such as exception safety,
input modification, and no-op behavior. Supports optional deep cloning of inputs
before passing them to the BiConsumer under test.
Typical usage:
CheckerBiConsumer<MyType, OtherType> checker = CheckerBiConsumer.check(myBiConsumer)
.activateDeepClone()
.applyWithoutException(input1, input2)
.modifiesInput(input1, input2, condition1, condition2);
- See Also:
-
Field Summary
Fields inherited from class util.AbstractChecker
backObject, exceptionTracker, name, object, saveErrors, stop
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CheckerBiConsumer
(BiConsumer<T, U> consumer, String name) Constructs a newCheckerBiConsumer
with the specifiedBiConsumer
and name. -
Method Summary
Modifier and TypeMethodDescriptionActivates deep cloning of inputs before passing them to the BiConsumer.applyWithoutException
(Collection<? extends Map.Entry<T, U>> input) Checks that the BiConsumer can be applied to all entries in the collection without throwing an exception.applyWithoutException
(T input1, U input2) Checks that the BiConsumer can be applied to the given inputs without throwing an exception.static <T,
U> CheckerBiConsumer <T, U> check
(BiConsumer<T, U> biconsumer) Creates a CheckerBiConsumer for the given BiConsumer with a default name.static <T,
U> CheckerBiConsumer <T, U> check
(BiConsumer<T, U> biconsumer, String name) Creates a CheckerBiConsumer for the given BiConsumer and assigns a custom name.Deactivates deep cloning of inputs before passing them to the BiConsumer.doesNothing
(Collection<? extends Map.Entry<T, U>> input) Checks that the BiConsumer does not modify any of the entries in the collection.doesNothing
(T input1, U input2) Checks that the BiConsumer does not modify the given inputs.modifiesInput
(Collection<? extends Map.Entry<T, U>> input, BiPredicate<T, U> condition) Checks that the BiConsumer modifies all entries in the collection as expected, according to the given bi-predicate.modifiesInput
(Collection<? extends Map.Entry<T, U>> input, Predicate<T> condition1, Predicate<U> condition2) Checks that the BiConsumer modifies all entries in the collection as expected, according to the given predicates.modifiesInput
(T input1, U input2, BiPredicate<T, U> condition) Checks that the BiConsumer modifies the inputs as expected, according to the given bi-predicate.Checks that the BiConsumer modifies the inputs as expected, according to the given predicates.protected CheckerBiConsumer
<T, U> self()
Returns this instance (for fluent API).Methods inherited from class util.AbstractChecker
checkProperty, checkProperty, checkProperty, end, getMethod, getObject, getProperty, hasErrors, hasNotErrors, is, is, isEqual, isNonNull, isNot, isNot, isNull, notSaveErrors, saveErrors, show, showNotThrownException, showThrownException, stop
-
Constructor Details
-
CheckerBiConsumer
Constructs a newCheckerBiConsumer
with the specifiedBiConsumer
and name.- Parameters:
consumer
- theBiConsumer
to be wrapped and checkedname
- the name identifying this checker
-
-
Method Details
-
check
Creates a CheckerBiConsumer for the given BiConsumer and assigns a custom name.- Type Parameters:
T
- the first input type ofBiConsumer
U
- the second input type ofBiConsumer
- Parameters:
biconsumer
- the BiConsumer to checkname
- the name to assign to this checker- Returns:
- a CheckerBiConsumer instance for the given BiConsumer
-
check
Creates a CheckerBiConsumer for the given BiConsumer with a default name.- Type Parameters:
T
- the first input type ofBiConsumer
U
- the second input type ofBiConsumer
- Parameters:
biconsumer
- the BiConsumer to check- Returns:
- a CheckerBiConsumer instance for the given BiConsumer
-
self
Returns this instance (for fluent API).- Specified by:
self
in classAbstractChecker<BiConsumer<T,
U>, CheckerBiConsumer<T, U>> - Returns:
- this CheckerBiConsumer instance
-
activateDeepClone
Activates deep cloning of inputs before passing them to the BiConsumer.- Returns:
- this CheckerBiConsumer instance
-
deactivateDeepClone
Deactivates deep cloning of inputs before passing them to the BiConsumer.- Returns:
- this CheckerBiConsumer instance
-
applyWithoutException
Checks that the BiConsumer can be applied to the given inputs without throwing an exception.- Parameters:
input1
- the first input valueinput2
- the second input value- Returns:
- this CheckerBiConsumer instance
-
applyWithoutException
Checks that the BiConsumer can be applied to all entries in the collection without throwing an exception.- Parameters:
input
- the collection of key-value entries to test- Returns:
- this CheckerBiConsumer instance
-
modifiesInput
public CheckerBiConsumer<T,U> modifiesInput(T input1, U input2, Predicate<T> condition1, Predicate<U> condition2) Checks that the BiConsumer modifies the inputs as expected, according to the given predicates.- Parameters:
input1
- the first input valueinput2
- the second input valuecondition1
- the predicate to test the first input after consumptioncondition2
- the predicate to test the second input after consumption- Returns:
- this CheckerBiConsumer instance
-
modifiesInput
Checks that the BiConsumer modifies the inputs as expected, according to the given bi-predicate.- Parameters:
input1
- the first input valueinput2
- the second input valuecondition
- the bi-predicate to test both inputs after consumption- Returns:
- this CheckerBiConsumer instance
-
modifiesInput
public CheckerBiConsumer<T,U> modifiesInput(Collection<? extends Map.Entry<T, U>> input, Predicate<T> condition1, Predicate<U> condition2) Checks that the BiConsumer modifies all entries in the collection as expected, according to the given predicates.- Parameters:
input
- the collection of key-value entries to testcondition1
- the predicate to test the first input after consumptioncondition2
- the predicate to test the second input after consumption- Returns:
- this CheckerBiConsumer instance
-
modifiesInput
public CheckerBiConsumer<T,U> modifiesInput(Collection<? extends Map.Entry<T, U>> input, BiPredicate<T, U> condition) Checks that the BiConsumer modifies all entries in the collection as expected, according to the given bi-predicate.- Parameters:
input
- the collection of key-value entries to testcondition
- the bi-predicate to test both inputs after consumption- Returns:
- this CheckerBiConsumer instance
-
doesNothing
Checks that the BiConsumer does not modify the given inputs.- Parameters:
input1
- the first input valueinput2
- the second input value- Returns:
- this CheckerBiConsumer instance
-
doesNothing
Checks that the BiConsumer does not modify any of the entries in the collection.- Parameters:
input
- the collection of key-value entries to test- Returns:
- this CheckerBiConsumer instance
-