Interface ExpectedException<T extends Throwable>

Type Parameters:
T - the type of the expected exception
All Superinterfaces:
Expected, ExpectedObject<Class<T>>

public interface ExpectedException<T extends Throwable> extends ExpectedObject<Class<T>>

A type representing the expected exceptional behavior in a test.

  • Field Summary

    Fields inherited from interface org.tudalgo.algoutils.tutor.general.assertions.expected.Expected

    BRACKET_FORMATTER
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T extends Exception>
    ExpectedException<T>
    of(Class<T> clazz, Predicate<Class<T>> classTest, Predicate<T> exceptionTest, Function<String,String> formatter)
    Returns an instance representing an expected exceptional behavior.
    default String
    string(Stringifier stringifier)
    Returns a string representation of the expected behavior using the given stringifier to make the behavior human-readable.
    boolean
    test(Class<T> object)
    Returns if the given type is of the expected type.
    boolean
    test(T exception)
    Returns if the given exception is as expected.

    Methods inherited from interface org.tudalgo.algoutils.tutor.general.assertions.expected.Expected

    behavior, display
  • Method Details

    • of

      static <T extends Exception> ExpectedException<T> of(Class<T> clazz, Predicate<Class<T>> classTest, Predicate<T> exceptionTest, Function<String,String> formatter)

      Returns an instance representing an expected exceptional behavior.

      Type Parameters:
      T - the type of the expected exception
      Parameters:
      clazz - the type representing the expected exception
      classTest - a predicate testing if a given class is of the expected type
      exceptionTest - a predicate testing if a given exception is of the expected type
      formatter - the formatter
      Returns:
      the expected exceptional behavior
    • string

      default String string(Stringifier stringifier)
      Description copied from interface: Expected

      Returns a string representation of the expected behavior using the given stringifier to make the behavior human-readable.

      Specified by:
      string in interface Expected
      Parameters:
      stringifier - the stringifier
      Returns:
      the string
    • test

      boolean test(Class<T> object)
      Returns if the given type is of the expected type.
      Specified by:
      test in interface ExpectedObject<T extends Throwable>
      Parameters:
      object - the type to test
      Returns:
      if the given type is of the expected type
    • test

      boolean test(T exception)
      Returns if the given exception is as expected.
      Parameters:
      exception - the exception to test
      Returns:
      if the given exception is of the expected