Class CheckerCallable<V>
java.lang.Object
com.luchersol.core.util.AbstractChecker<Callable<V>,CheckerCallable<V>>
com.luchersol.core.specialized_checkers.lambda.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 com.luchersol.core.util.AbstractChecker
backObject, exceptionTracker, name, object, saveErrors, stop -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCheckerCallable(Callable<V> callable, String name) Constructs a newCheckerCallablewith the specifiedCallabletask and a name. -
Method Summary
Modifier and TypeMethodDescriptionAsserts that calling thecall()method of theCallabledoes not throw any exception.static <V> CheckerCallable<V> Creates a newCheckerCallablefor the givenCallableinstance with a default name.static <V> CheckerCallable<V> Creates a newCheckerCallablefor the givenCallableinstance with a custom name.producesExpected(V expected) Asserts that thecall()method of theCallableproduces the expected result.Asserts that thecall()method of theCallableproduces a non-null result.protected CheckerCallable<V> self()Returns this checker instance (for fluent API usage).Methods inherited from class com.luchersol.core.util.AbstractChecker
checkProperty, checkProperty, checkProperty, checkProperty, end, getMethod, getObject, getProperty, hasErrors, hasNotErrors, is, is, is, isEqual, isNonNull, isNot, isNot, isNull, notSaveErrors, saveErrors, setBackObject, setExceptionTracker, setName, setObject, setSaveErrors, setStop, show, showPassedChecks, showThrownException, stop, toChecker, updateChecker
-
Constructor Details
-
CheckerCallable
-
-
Method Details
-
check
Creates a newCheckerCallablefor the givenCallableinstance with a custom name.- Type Parameters:
V- the result type returned by thecall()method of theCallable- Parameters:
callable- theCallableinstance to be checkedname- the name to identify this checker instance (useful for error messages)- Returns:
- a new
CheckerCallablefor the providedCallable
-
check
Creates a newCheckerCallablefor the givenCallableinstance with a default name.- Type Parameters:
V- the result type returned by thecall()method of theCallable- Parameters:
callable- theCallableinstance to be checked- Returns:
- a new
CheckerCallablefor the providedCallable
-
self
Returns this checker instance (for fluent API usage).- Specified by:
selfin classAbstractChecker<Callable<V>,CheckerCallable<V>> - Returns:
- this
CheckerCallableinstance
-
callWithoutException
Asserts that calling thecall()method of theCallabledoes not throw any exception.- Returns:
- this
CheckerCallableinstance for further validation
-
producesExpected
Asserts that thecall()method of theCallableproduces the expected result.- Parameters:
expected- the expected result to compare with the actual result ofcall()- Returns:
- this
CheckerCallableinstance for further validation
-
producesNonNull
Asserts that thecall()method of theCallableproduces a non-null result.- Returns:
- this
CheckerCallableinstance for further validation
-