Class CheckerCallable<V>

java.lang.Object
util.AbstractChecker<Callable<V>,CheckerCallable<V>>
specialized_checkers.lambda.CheckerCallable<V>
Type Parameters:
V - the result type returned by the call() method of the Callable
All Implemented Interfaces:
InterfaceChecker<AbstractChecker<Callable<V>,CheckerCallable<V>>,Callable<V>>

public class CheckerCallable<V> extends AbstractChecker<Callable<V>,CheckerCallable<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:
  • Constructor Details

    • CheckerCallable

      protected CheckerCallable(Callable<V> callable, String name)
      Constructs a new CheckerCallable with the specified Callable task and a name.
      Parameters:
      callable - the Callable task to be executed by this checker
      name - the name associated with this checker
  • Method Details

    • check

      public static <V> CheckerCallable<V> check(Callable<V> callable, String name)
      Creates a new CheckerCallable for the given Callable instance with a custom name.
      Type Parameters:
      V - the result type returned by the call() method of the Callable
      Parameters:
      callable - the Callable instance to be checked
      name - the name to identify this checker instance (useful for error messages)
      Returns:
      a new CheckerCallable for the provided Callable
    • check

      public static <V> CheckerCallable<V> check(Callable<V> callable)
      Creates a new CheckerCallable for the given Callable instance with a default name.
      Type Parameters:
      V - the result type returned by the call() method of the Callable
      Parameters:
      callable - the Callable instance to be checked
      Returns:
      a new CheckerCallable for the provided Callable
    • self

      protected CheckerCallable<V> self()
      Returns this checker instance (for fluent API usage).
      Specified by:
      self in class AbstractChecker<Callable<V>,CheckerCallable<V>>
      Returns:
      this CheckerCallable instance
    • callWithoutException

      public CheckerCallable<V> callWithoutException()
      Asserts that calling the call() method of the Callable does not throw any exception.
      Returns:
      this CheckerCallable instance for further validation
    • producesExpected

      public CheckerCallable<V> producesExpected(V expected)
      Asserts that the call() method of the Callable produces the expected result.
      Parameters:
      expected - the expected result to compare with the actual result of call()
      Returns:
      this CheckerCallable instance for further validation
    • producesNonNull

      public CheckerCallable<V> producesNonNull()
      Asserts that the call() method of the Callable produces a non-null result.
      Returns:
      this CheckerCallable instance for further validation