Class CheckerCallable<V>
- Type Parameters:
V
- the result type returned by thecall()
method of theCallable
- All Implemented Interfaces:
InterfaceChecker<AbstractChecker<Callable<V>,
CheckerCallable<V>>, Callable<V>>
A specialized checker for
Callable
instances, providing fluent assertions
for validating the behavior and results of Callable
tasks.
This class extends AbstractChecker
to offer convenient methods for
asserting that a Callable
does not throw exceptions, produces expected
results, or returns non-null values.
Example usage:
CheckerCallable<Integer> checker = CheckerCallable.check(() -> 42)
.callWithoutException()
.producesExpected(42)
.producesNonNull();
- See Also:
-
Field Summary
Fields inherited from class util.AbstractChecker
backObject, exceptionTracker, name, object, saveErrors, stop
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CheckerCallable
(Callable<V> callable, String name) Constructs a newCheckerCallable
with the specifiedCallable
task and a name. -
Method Summary
Modifier and TypeMethodDescriptionAsserts that calling thecall()
method of theCallable
does not throw any exception.static <V> CheckerCallable
<V> Creates a newCheckerCallable
for the givenCallable
instance with a default name.static <V> CheckerCallable
<V> Creates a newCheckerCallable
for the givenCallable
instance with a custom name.producesExpected
(V expected) Asserts that thecall()
method of theCallable
produces the expected result.Asserts that thecall()
method of theCallable
produces a non-null result.protected CheckerCallable
<V> self()
Returns this checker instance (for fluent API usage).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
-
CheckerCallable
-
-
Method Details
-
check
Creates a newCheckerCallable
for the givenCallable
instance with a custom name.- Type Parameters:
V
- the result type returned by thecall()
method of theCallable
- Parameters:
callable
- theCallable
instance to be checkedname
- the name to identify this checker instance (useful for error messages)- Returns:
- a new
CheckerCallable
for the providedCallable
-
check
Creates a newCheckerCallable
for the givenCallable
instance with a default name.- Type Parameters:
V
- the result type returned by thecall()
method of theCallable
- Parameters:
callable
- theCallable
instance to be checked- Returns:
- a new
CheckerCallable
for the providedCallable
-
self
Returns this checker instance (for fluent API usage).- Specified by:
self
in classAbstractChecker<Callable<V>,
CheckerCallable<V>> - Returns:
- this
CheckerCallable
instance
-
callWithoutException
Asserts that calling thecall()
method of theCallable
does not throw any exception.- Returns:
- this
CheckerCallable
instance for further validation
-
producesExpected
Asserts that thecall()
method of theCallable
produces the expected result.- Parameters:
expected
- the expected result to compare with the actual result ofcall()
- Returns:
- this
CheckerCallable
instance for further validation
-
producesNonNull
Asserts that thecall()
method of theCallable
produces a non-null result.- Returns:
- this
CheckerCallable
instance for further validation
-