java.lang.Object
org.tudalgo.algoutils.tutor.general.assertions.Assertions2

public final class Assertions2 extends Object
A collection of assertion methods.
  • Method Details

    • objectAssert

      public static <T> T objectAssert(ExpectedObject<T> expected, T object, Context context, PreCommentSupplier<? super ResultOfObject<T>> preCommentSupplier)
    • objectAssert

      public static <T> T objectAssert(ExpectedObject<T> expected, T object, Context context)
    • objectAssert

      public static <T> T objectAssert(ExpectedObject<T> expected, T object, PreCommentSupplier<? super ResultOfObject<T>> preCommentSupplier)
    • objectAssert

      public static <T> T objectAssert(ExpectedObject<T> expected, ObjectCallable<T> callable, Context context, PreCommentSupplier<? super ResultOfObject<T>> preCommentSupplier)
    • objectAssert

      public static <T> T objectAssert(ExpectedObject<T> expected, ObjectCallable<T> callable, Context context)
    • objectAssert

      public static <T> T objectAssert(ExpectedObject<T> expected, ObjectCallable<T> callable, PreCommentSupplier<? super ResultOfObject<T>> preCommentSupplier)
    • assertCallEquals

      public static <T> T assertCallEquals(T expected, ObjectCallable<T> callable, Context context, PreCommentSupplier<? super ResultOfObject<T>> preCommentSupplier)

      Asserts that the callable returns an object equal to the given expected object.

      Type Parameters:
      T - the type of the object
      Parameters:
      expected - the expected object
      callable - the callable to retrieve the object from
      context - the context of the test
      preCommentSupplier - the supplier of the pre-comment
      Returns:
      the result of the test
    • assertCallFalse

      public static boolean assertCallFalse(ObjectCallable<Boolean> callable, Context context, PreCommentSupplier<? super ResultOfObject<Boolean>> preCommentSupplier)

      Asserts that the callable returns Boolean.FALSE.

      Parameters:
      callable - the callable to retrieve the object from
      context - the context of the test
      preCommentSupplier - the supplier of the pre-comment
      Returns:
      the result of the test
    • assertCallNotEquals

      public static <T> T assertCallNotEquals(T unexpected, ObjectCallable<T> callable, Context context, PreCommentSupplier<? super ResultOfObject<T>> preCommentSupplier)
      Asserts that the callable returns an object not equal to the given object.
      Type Parameters:
      T - the type of the object
      Parameters:
      unexpected - the unexpected object
      callable - the callable to retrieve the object from
      context - the context of the test
      preCommentSupplier - the supplier of the pre-comment
      Returns:
      the result of the test
    • assertCallNotNull

      public static <T> T assertCallNotNull(ObjectCallable<T> callable, Context context, PreCommentSupplier<? super ResultOfObject<T>> preCommentSupplier)
      Asserts that the callable returns an object.
      Type Parameters:
      T - the type of the object
      Parameters:
      callable - the callable to retrieve the object from
      context - the context of the test
      preCommentSupplier - the supplier of the pre-comment
      Returns:
      the result of the test
    • assertCallNotSame

      public static <T> T assertCallNotSame(T unexpected, ObjectCallable<T> callable, Context context, PreCommentSupplier<? super ResultOfObject<T>> preCommentSupplier)
      Asserts that the given callable does not return the given object.
      Type Parameters:
      T - the type of the object
      Parameters:
      unexpected - the unexpected object
      callable - the callable to retrieve the object from
      context - the context of the test
      preCommentSupplier - the supplier of the pre-comment
      Returns:
      the result of the test
    • assertCallNull

      public static <T> T assertCallNull(ObjectCallable<T> callable, Context context, PreCommentSupplier<? super ResultOfObject<T>> preCommentSupplier)

      Asserts that the given callable returns null.

      Parameters:
      callable - the callable to retrieve the object from
      context - the context of the test
      preCommentSupplier - the supplier of the pre-comment
      Returns:
      the result of the test
    • assertCallSame

      public static <T> T assertCallSame(T expected, ObjectCallable<T> callable, Context context, PreCommentSupplier<? super ResultOfObject<T>> preCommentSupplier)
      Asserts that the given callable returns the given object.
      Type Parameters:
      T - the type of the object
      Parameters:
      expected - the expected object
      callable - the callable to retrieve the object from
      context - the context of the test
      preCommentSupplier - the supplier of the pre-comment
      Returns:
      the result of the test
    • assertCallTrue

      public static boolean assertCallTrue(ObjectCallable<Boolean> callable, Context context, PreCommentSupplier<? super ResultOfObject<Boolean>> preCommentSupplier)

      Asserts that the given callable returns Boolean.TRUE.

      Parameters:
      callable - the callable to retrieve the object from
      context - the context of the test
      preCommentSupplier - the supplier of the pre-comment
      Returns:
      the result of the test
    • assertEquals

      public static <T> T assertEquals(T expected, T actual, Context context, PreCommentSupplier<? super ResultOfObject<T>> preCommentSupplier)

      Asserts that the given actual object is equal to the given expected object.

      Type Parameters:
      T - the type of the object
      Parameters:
      expected - the expected object
      actual - the actual object
      context - the context of the test
      Returns:
      the result of the test
    • assertFalse

      public static boolean assertFalse(boolean actual, Context context, PreCommentSupplier<? super ResultOfObject<Boolean>> preCommentSupplier)

      Asserts that the callable returns Boolean.FALSE.

      Parameters:
      actual - the actual value
      context - the context of the test
      preCommentSupplier - the supplier of the pre-comment
      Returns:
      the result of the test
    • assertNotEquals

      public static <T> T assertNotEquals(T unexpected, T actual, Context context, PreCommentSupplier<? super ResultOfObject<T>> preCommentSupplier)

      Asserts that the given actual object is not equal to the given unexpected object.

      Type Parameters:
      T - the type of the object
      Parameters:
      unexpected - the unexpected object
      actual - the actual object
      context - the context of the test
      Returns:
      the result of the test
    • assertNotNull

      public static <T> T assertNotNull(T actual, Context context, PreCommentSupplier<? super ResultOfObject<T>> preCommentSupplier)

      Asserts that the given actual object is not null.

      Type Parameters:
      T - the type of the object
      Parameters:
      actual - the actual object
      context - the context of the test
      preCommentSupplier - the supplier of the pre-comment
      Returns:
      the result of the test
    • assertNotSame

      public static <T> T assertNotSame(T unexpected, T actual, Context context, PreCommentSupplier<? super ResultOfObject<T>> preCommentSupplier)

      Asserts that the given actual object is not the same as the given unexpected object.

      Type Parameters:
      T - the type of the object
      Parameters:
      unexpected - the unexpected object
      actual - the actual object
      context - the context of the test
      Returns:
      the result of the test
    • assertNull

      public static <T> T assertNull(T actual, Context context, PreCommentSupplier<? super ResultOfObject<T>> preCommentSupplier)

      Asserts that the given actual object is null.

      Type Parameters:
      T - the type of the object
      Parameters:
      actual - the actual object
      context - the context of the test
      preCommentSupplier - the supplier of the pre-comment
      Returns:
      the result of the test
    • assertSame

      public static <T> T assertSame(T expected, T actual, Context context, PreCommentSupplier<? super ResultOfObject<T>> preCommentSupplier)

      Asserts that the given actual object is the same as the given expected object.

      Type Parameters:
      T - the type of the object
      Parameters:
      expected - the expected object
      actual - the actual object
      context - the context of the test
      Returns:
      the result of the test
    • assertThrows

      public static <T extends Exception> T assertThrows(Class<T> expected, Callable callable, Context context, PreCommentSupplier<? super ResultOfExceptionalCall<T>> preCommentSupplier)

      Asserts that the given callable throws an exception of the given expected type.

      Parameters:
      expected - the expected type of the exception
      context - the context of the test
      preCommentSupplier - the supplier of the pre-comment
      Returns:
      the result of the test
    • call

      public static void call(Callable callable, Context context, PreCommentSupplier<? super ResultOfCall> preCommentSupplier)
    • callObject

      public static <T> T callObject(ObjectCallable<T> callable, Context context, PreCommentSupplier<? super ResultOfObject<T>> preCommentSupplier)
    • assertTrue

      public static boolean assertTrue(boolean actual, Context context, PreCommentSupplier<? super ResultOfObject<Boolean>> preCommentSupplier)
      Asserts that the given boolean value is true.
      Parameters:
      actual - the boolean value
      context - the context of the test
      preCommentSupplier - the supplier of the pre-comment
      Returns:
      the result of the test
    • contextBuilder

      public static Context.Builder<?> contextBuilder()
      Returns a contexts builder.
      Returns:
      the context builder
    • emptyContext

      public static Context emptyContext()
      Returns an empty contexts.
      Returns:
      the empty context
    • fail

      public static <T> T fail(Context context, PreCommentSupplier<? super ResultOfFail> preCommentSupplier)
      Fails.
      Type Parameters:
      T - the return type (for convenience reasons)
      Parameters:
      context - the context of the fail
      preCommentSupplier - the supplier of the pre-comment
      Returns:
      nothing
    • fail

      public static <T> T fail(Exception cause, Context context, PreCommentSupplier<? super ResultOfFail> preCommentSupplier)
      Fails.
      Type Parameters:
      T - the return type (for convenience reasons)
      Parameters:
      cause - the cause of the fail
      context - the context of the fail
      preCommentSupplier - the supplier of the pre-comment
      Returns:
      nothing
    • fail

      public static <T> T fail(Expected expected, Actual actual, Context context, PreCommentSupplier<? super ResultOfFail> preCommentSupplier)
    • failBuilder

      public static Fail.Builder failBuilder()
      Returns a fail builder.
      Returns:
      the fail builder
    • testOfCallBuilder

      public static TestOfCall.Builder testOfCallBuilder()
    • testOfObjectBuilder

      public static <T> TestOfObject.Builder<T> testOfObjectBuilder()
      Returns a object test builder.
      Returns:
      the object test builder
    • testOfThrowableCallBuilder

      public static <T extends Exception> TestOfExceptionalCall.Builder<T> testOfThrowableCallBuilder()
      Returns a throwable call test builder.
      Returns:
      the throwable call test builder
    • context

      public static Context context(Object... records)