Class Assumptions

java.lang.Object
org.assertj.core.api.Assumptions
Direct Known Subclasses:
BDDAssumptions

public class Assumptions extends Object
Entry point for assumption methods for different types, which allow to skip test execution on failed assumptions.
Since:
2.9.0 / 3.9.0
  • Constructor Details

    • Assumptions

      public Assumptions()
  • Method Details

    • assumeThat

      public static <T> ObjectAssert<T> assumeThat(T actual)
      Creates a new instance of ObjectAssert assumption.
      Type Parameters:
      T - the type of the actual value.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractStringAssert<?> assumeThat(String actual)
      Creates a new instance of StringAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractBigDecimalAssert<?> assumeThat(BigDecimal actual)
      Creates a new instance of BigDecimalAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractBigIntegerAssert<?> assumeThat(BigInteger actual)
      Creates a new instance of BigIntegerAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractUriAssert<?> assumeThat(URI actual)
      Creates a new instance of UriAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractUrlAssert<?> assumeThat(URL actual)
      Creates a new instance of UrlAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractBooleanAssert<?> assumeThat(boolean actual)
      Creates a new instance of BooleanAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractBooleanAssert<?> assumeThat(Boolean actual)
      Creates a new instance of BooleanAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractBooleanArrayAssert<?> assumeThat(boolean[] actual)
      Creates a new instance of BooleanArrayAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static Boolean2DArrayAssert assumeThat(boolean[][] actual)
      Creates a new instance of Boolean2DArrayAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.17.0
    • assumeThat

      public static AbstractByteAssert<?> assumeThat(byte actual)
      Creates a new instance of ByteAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractByteAssert<?> assumeThat(Byte actual)
      Creates a new instance of ByteAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractByteArrayAssert<?> assumeThat(byte[] actual)
      Creates a new instance of ByteArrayAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static Byte2DArrayAssert assumeThat(byte[][] actual)
      Creates a new instance of Byte2DArrayAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.17.0
    • assumeThat

      public static AbstractCharacterAssert<?> assumeThat(char actual)
      Creates a new instance of CharacterAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractCharacterAssert<?> assumeThat(Character actual)
      Creates a new instance of CharacterAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractCharArrayAssert<?> assumeThat(char[] actual)
      Creates a new instance of CharArrayAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static Char2DArrayAssert assumeThat(char[][] actual)
      Creates a new instance of Char2DArrayAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.17.0
    • assumeThat

      public static AbstractCharSequenceAssert<?,? extends CharSequence> assumeThat(CharSequence actual)
      Creates a new instance of CharSequenceAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThatCharSequence

      public static AbstractCharSequenceAssert<?,? extends CharSequence> assumeThatCharSequence(CharSequence actual)
      Creates a new instance of CharSequenceAssert assumption.

      Use this over assumeThat(CharSequence) in case of ambiguous method resolution when the object under test implements several interfaces Assertj provides assumeThat for.

      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.25.0
    • assumeThat

      public static AbstractCharSequenceAssert<?,? extends CharSequence> assumeThat(StringBuilder actual)
      Creates a new instance of CharSequenceAssert assumption from a StringBuilder.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.11.0
    • assumeThat

      public static AbstractCharSequenceAssert<?,? extends CharSequence> assumeThat(StringBuffer actual)
      Creates a new instance of CharSequenceAssert assumption from a StringBuffer.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.11.0
    • assumeThat

      public static AbstractShortAssert<?> assumeThat(short actual)
      Creates a new instance of ShortAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractShortAssert<?> assumeThat(Short actual)
      Creates a new instance of ShortAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractShortArrayAssert<?> assumeThat(short[] actual)
      Creates a new instance of ShortArrayAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static Short2DArrayAssert assumeThat(short[][] actual)
      Creates a new instance of Short2DArrayAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.17.0
    • assumeThat

      public static AbstractIntegerAssert<?> assumeThat(int actual)
      Creates a new instance of IntegerAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractIntegerAssert<?> assumeThat(Integer actual)
      Creates a new instance of IntegerAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractIntArrayAssert<?> assumeThat(int[] actual)
      Creates a new instance of IntArrayAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static Int2DArrayAssert assumeThat(int[][] actual)
      Creates a new instance of Int2DArrayAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.17.0
    • assumeThat

      public static AbstractLongAssert<?> assumeThat(long actual)
      Creates a new instance of LongAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractLongAssert<?> assumeThat(Long actual)
      Creates a new instance of LongAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractLongArrayAssert<?> assumeThat(long[] actual)
      Creates a new instance of LongArrayAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static Long2DArrayAssert assumeThat(long[][] actual)
      Creates a new instance of Long2DArrayAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.17.0
    • assumeThat

      public static AbstractFloatAssert<?> assumeThat(float actual)
      Creates a new instance of FloatAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractFloatAssert<?> assumeThat(Float actual)
      Creates a new instance of FloatAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractFloatArrayAssert<?> assumeThat(float[] actual)
      Creates a new instance of FloatArrayAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static Float2DArrayAssert assumeThat(float[][] actual)
      Creates a new instance of Float2DArrayAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.17.0
    • assumeThat

      public static AbstractDoubleAssert<?> assumeThat(double actual)
      Creates a new instance of DoubleAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractDoubleAssert<?> assumeThat(Double actual)
      Creates a new instance of DoubleAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractDoubleArrayAssert<?> assumeThat(double[] actual)
      Creates a new instance of DoubleArrayAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static Double2DArrayAssert assumeThat(double[][] actual)
      Creates a new instance of Double2DArrayAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.17.0
    • assumeThat

      public static AtomicBooleanAssert assumeThat(AtomicBoolean actual)
      Create assumption for AtomicBoolean.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AtomicIntegerAssert assumeThat(AtomicInteger actual)
      Create assumption for AtomicInteger.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AtomicIntegerArrayAssert assumeThat(AtomicIntegerArray actual)
      Creates int[] assumption for AtomicIntegerArray.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static <OBJECT> AtomicIntegerFieldUpdaterAssert<OBJECT> assumeThat(AtomicIntegerFieldUpdater<OBJECT> actual)
      Create assumption for AtomicIntegerFieldUpdater.
      Type Parameters:
      OBJECT - the type of the object holding the updatable field.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static LongAdderAssert assumeThat(LongAdder actual)
      Create assumption for LongAdder.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.16.0
    • assumeThat

      public static AtomicLongAssert assumeThat(AtomicLong actual)
      Create assumption for AtomicLong.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AtomicLongArrayAssert assumeThat(AtomicLongArray actual)
      Create assumption for AtomicLongArray.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static <OBJECT> AtomicLongFieldUpdaterAssert<OBJECT> assumeThat(AtomicLongFieldUpdater<OBJECT> actual)
      Create assumption for AtomicLongFieldUpdater.
      Type Parameters:
      OBJECT - the type of the object holding the updatable field.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static <VALUE> AtomicReferenceAssert<VALUE> assumeThat(AtomicReference<VALUE> actual)
      Create assumption for AtomicReference.
      Type Parameters:
      VALUE - the type of the value contained in the AtomicReference.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static <ELEMENT> AtomicReferenceArrayAssert<ELEMENT> assumeThat(AtomicReferenceArray<ELEMENT> actual)
      Create assumption for AtomicReferenceArray.
      Type Parameters:
      ELEMENT - the type of the value contained in the AtomicReferenceArray.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static <FIELD, OBJECT> AtomicReferenceFieldUpdaterAssert<FIELD,OBJECT> assumeThat(AtomicReferenceFieldUpdater<OBJECT,FIELD> actual)
      Create assumption for AtomicReferenceFieldUpdater.
      Type Parameters:
      FIELD - the type of the field which gets updated by the AtomicReferenceFieldUpdater.
      OBJECT - the type of the object holding the updatable field.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static <VALUE> AtomicMarkableReferenceAssert<VALUE> assumeThat(AtomicMarkableReference<VALUE> actual)
      Create assumption for AtomicMarkableReference.
      Type Parameters:
      VALUE - the type of the value contained in the AtomicMarkableReference.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static <VALUE> AtomicStampedReferenceAssert<VALUE> assumeThat(AtomicStampedReference<VALUE> actual)
      Create assumption for AtomicStampedReference.
      Type Parameters:
      VALUE - the type of the value contained in the AtomicStampedReference.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static ClassAssert assumeThat(Class<?> actual)
      Creates a new instance of ClassAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractDateAssert<?> assumeThat(Date actual)
      Creates a new instance of DateAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractFileAssert<?> assumeThat(File actual)
      Creates a new instance of FileAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static AbstractPathAssert<?> assumeThat(Path actual)
      Creates a new instance of PathAssert assumption.
      Parameters:
      actual - the path to test
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThatPath

      public static AbstractPathAssert<?> assumeThatPath(Path actual)
      Creates a new instance of PathAssert assumption.

      Use this over assumeThat(Path) in case of ambiguous method resolution when the object under test implements several interfaces Assertj provides assumeThat for.

      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.23.0
    • assumeThat

      public static AbstractInputStreamAssert<?,? extends InputStream> assumeThat(InputStream actual)
      Creates a new instance of InputStreamAssert assumption.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static <RESULT> AbstractFutureAssert<?,? extends Future<? extends RESULT>,RESULT> assumeThat(Future<RESULT> future)
      Create assertion for FutureAssert assumption.
      Type Parameters:
      RESULT - the type of the value contained in the Future.
      Parameters:
      future - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static <ELEMENT> IterableAssert<ELEMENT> assumeThat(Iterable<? extends ELEMENT> actual)
      Creates a new instance of IterableAssert assumption.
      Type Parameters:
      ELEMENT - the type of elements.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThatIterable

      public static <ELEMENT> IterableAssert<ELEMENT> assumeThatIterable(Iterable<? extends ELEMENT> actual)
      Creates a new instance of IterableAssert assumption.

      Use this over assumeThat(Iterable) in case of ambiguous method resolution when the object under test implements several interfaces Assertj provides assumeThat for.

      Type Parameters:
      ELEMENT - the type of elements.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.23.0
    • assumeThat

      public static <ELEMENT> IteratorAssert<ELEMENT> assumeThat(Iterator<? extends ELEMENT> actual)
      Creates a new instance of IteratorAssert assumption.
      Type Parameters:
      ELEMENT - the type of elements.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThatIterator

      public static <ELEMENT> IteratorAssert<ELEMENT> assumeThatIterator(Iterator<? extends ELEMENT> actual)
      Creates a new instance of IteratorAssert assumption.

      Use this over assumeThat(Iterator) in case of ambiguous method resolution when the object under test implements several interfaces Assertj provides assumeThat for.

      Type Parameters:
      ELEMENT - the type of elements.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.23.0
    • assumeThat

      public static <E> AbstractCollectionAssert<?,Collection<? extends E>,E,ObjectAssert<E>> assumeThat(Collection<? extends E> actual)
      Creates a new instance of CollectionAssert assumption.
      Type Parameters:
      E - the type of elements.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.21.0
    • assumeThatCollection

      public static <E> AbstractCollectionAssert<?,Collection<? extends E>,E,ObjectAssert<E>> assumeThatCollection(Collection<? extends E> actual)
      Creates a new instance of CollectionAssert assumption.

      Use this over assumeThat(Collection) in case of ambiguous method resolution when the object under test implements several interfaces Assertj provides assumeThat for.

      Type Parameters:
      E - the type of elements.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.23.0
    • assumeThat

      public static <ELEMENT> FactoryBasedNavigableListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>> assumeThat(List<? extends ELEMENT> actual)
      Creates a new instance of ListAssert assumption.
      Type Parameters:
      ELEMENT - the type of elements.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThatList

      public static <ELEMENT> FactoryBasedNavigableListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>> assumeThatList(List<? extends ELEMENT> actual)
      Creates a new instance of ListAssert assumption.

      Use this over assumeThat(List) in case of ambiguous method resolution when the object under test implements several interfaces Assertj provides assumeThat for.

      Type Parameters:
      ELEMENT - the type of elements.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.23.0
    • assumeThat

      public static <T> ObjectArrayAssert<T> assumeThat(T[] actual)
      Creates a new instance of ObjectArrayAssert assumption.
      Type Parameters:
      T - the type of elements.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static <T> Object2DArrayAssert<T> assumeThat(T[][] actual)
      Creates a new instance of Object2DArrayAssert assumption.
      Type Parameters:
      T - the type of elements.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.17.0
    • assumeThat

      public static <K, V> MapAssert<K,V> assumeThat(Map<K,V> actual)
      Creates a new instance of MapAssert assumption.
      Type Parameters:
      K - the type of keys in the map.
      V - the type of values in the map.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThat

      public static <T extends Comparable<? super T>> AbstractComparableAssert<?,T> assumeThat(T actual)
      Creates a new instance of GenericComparableAssert assumption.
      Type Parameters:
      T - the type of actual.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThatComparable

      public static <T> AbstractUniversalComparableAssert<?,T> assumeThatComparable(Comparable<T> actual)
      Creates a new instance of UniversalComparableAssert assumption.

      Use this over assumeThat(Comparable) in case of ambiguous method resolution when the object under test implements several interfaces Assertj provides assumeThat for.

      Type Parameters:
      T - the type of actual.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.23.0
    • assumeThat

      public static <T extends Throwable> AbstractThrowableAssert<?,T> assumeThat(T actual)
      Creates a new instance of ThrowableAssert assumption.
      Type Parameters:
      T - the type of the actual throwable.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThatExceptionOfType

      public static <T extends Throwable> ThrowableTypeAssert<T> assumeThatExceptionOfType(Class<? extends T> exceptionType)
      Entry point to check that an exception of type T is thrown by a given throwingCallable which allows to chain assertions on the thrown exception.
      Type Parameters:
      T - the exception type.
      Parameters:
      exceptionType - the exception type class.
      Returns:
      the created ThrowableTypeAssert.
      Since:
      3.23.0
    • assumeThatException

      public static ThrowableTypeAssert<Exception> assumeThatException()
      Returns:
      the created assumption for assertion object.
      Since:
      3.23.0
    • assumeThatRuntimeException

      public static ThrowableTypeAssert<RuntimeException> assumeThatRuntimeException()
      Returns:
      the created assumption for assertion object.
      Since:
      3.23.0
    • assumeThatNullPointerException

      public static ThrowableTypeAssert<NullPointerException> assumeThatNullPointerException()
      Returns:
      the created assumption for assertion object.
      Since:
      3.23.0
    • assumeThatIllegalArgumentException

      public static ThrowableTypeAssert<IllegalArgumentException> assumeThatIllegalArgumentException()
      Returns:
      the created assumption for assertion object.
      Since:
      3.23.0
    • assumeThatIOException

      public static ThrowableTypeAssert<IOException> assumeThatIOException()
      Returns:
      the created assumption for assertion object.
      Since:
      3.23.0
    • assumeThatIndexOutOfBoundsException

      public static ThrowableTypeAssert<IndexOutOfBoundsException> assumeThatIndexOutOfBoundsException()
      Returns:
      the created assumption for assertion object.
      Since:
      3.23.0
    • assumeThatReflectiveOperationException

      public static ThrowableTypeAssert<ReflectiveOperationException> assumeThatReflectiveOperationException()
      Returns:
      the created assumption for assertion object.
      Since:
      3.23.0
    • assumeThatThrownBy

      public static AbstractThrowableAssert<?,? extends Throwable> assumeThatThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable)
      Allows to capture and then assume on a Throwable (easier done with lambdas).

      Example :

        @Test
        public void testException() {
          assumeThatThrownBy(() -> { throw new Exception("boom!") }).isInstanceOf(Exception.class)
                                                                    .hasMessageContaining("boom");
       }
      Parameters:
      shouldRaiseThrowable - The ThrowableAssert.ThrowingCallable or lambda with the code that should raise the throwable.
      Returns:
      the created assumption for assertion object.
      Since:
      2.9.0 / 3.9.0
    • assumeThatCode

      public static AbstractThrowableAssert<?,? extends Throwable> assumeThatCode(ThrowableAssert.ThrowingCallable shouldRaiseOrNotThrowable)
      Allows to capture and then assume on a Throwable (easier done with lambdas).

      The main difference with assumeThatThrownBy(ThrowingCallable) is that this method does not fail if no exception was thrown.

      Example :

       ThrowingCallable callable = () -> {
         throw new Exception("boom!");
       };
      
       // assertion succeeds
       assumeThatCode(callable).isInstanceOf(Exception.class)
                               .hasMessageContaining("boom");
      
       // assertion fails
       assumeThatCode(callable).doesNotThrowAnyException();

      This method was not named assumeThat because the java compiler reported it ambiguous when used directly with a lambda :(

      Parameters:
      shouldRaiseOrNotThrowable - The ThrowableAssert.ThrowingCallable or lambda with the code that should raise the throwable.
      Returns:
      the created ThrowableAssert.
      Since:
      3.9.0
    • assumeThatObject

      public static <T> ObjectAssert<T> assumeThatObject(T actual)
      Creates a new instance of ObjectAssert assumption.

      This overload is useful, when an overloaded method of assertThat(...) takes precedence over the generic assumeThat(Object).

      Example:

      Cast necessary because assumeThat(List) "forgets" actual type:

      assumeThat(new LinkedList<>(asList("abc"))).matches(list -> ((Deque<String>) list).getFirst().equals("abc")); 
      No cast needed, but also no additional list assertions:
      assumeThatObject(new LinkedList<>(asList("abc"))).matches(list -> list.getFirst().equals("abc")); 
      Type Parameters:
      T - the type of the actual value.
      Parameters:
      actual - the actual value.
      Returns:
      the created assertion object.
      Since:
      3.12.0
    • assumeThat

      public static <T> PredicateAssert<T> assumeThat(Predicate<T> actual)
      Creates a new instance of PredicateAssert assumption.
      Type Parameters:
      T - the Predicate type.
      Parameters:
      actual - the Predicate to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThatPredicate

      public static <T> PredicateAssert<T> assumeThatPredicate(Predicate<T> actual)
      Creates a new instance of PredicateAssert assumption.

      Use this over assumeThat(Predicate) in case of ambiguous method resolution when the object under test implements several interfaces Assertj provides assumeThat for.

      Type Parameters:
      T - the type of elements.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.23.0
    • assumeThat

      public static IntPredicateAssert assumeThat(IntPredicate actual)
      Creates a new instance of IntPredicateAssert assumption.
      Parameters:
      actual - the IntPredicate to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static LongPredicateAssert assumeThat(LongPredicate actual)
      Creates a new instance of LongPredicateAssert assumption.
      Parameters:
      actual - the LongPredicate to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static DoublePredicateAssert assumeThat(DoublePredicate actual)
      Creates a new instance of DoublePredicateAssert assumption.
      Parameters:
      actual - the DoublePredicate to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static <RESULT> CompletableFutureAssert<RESULT> assumeThat(CompletableFuture<RESULT> actual)
      Creates a new instance of CompletableFutureAssert assumption.
      Type Parameters:
      RESULT - the CompletableFuture wrapped type.
      Parameters:
      actual - the CompletableFuture to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static <RESULT> CompletableFutureAssert<RESULT> assumeThat(CompletionStage<RESULT> actual)
      Creates a new instance of CompletableFutureAssert assumption for a CompletionStage by converting it to a CompletableFuture and returning a CompletableFutureAssert.

      If the given CompletionStage is null, the CompletableFuture in the returned CompletableFutureAssert will also be null.

      Type Parameters:
      RESULT - the CompletableFuture wrapped type.
      Parameters:
      actual - the CompletableFuture to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static <VALUE> OptionalAssert<VALUE> assumeThat(Optional<VALUE> actual)
      Creates a new instance of OptionalAssert assumption.
      Type Parameters:
      VALUE - the Optional wrapped type.
      Parameters:
      actual - the Optional to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static OptionalDoubleAssert assumeThat(OptionalDouble actual)
      Creates a new instance of OptionalDoubleAssert assumption.
      Parameters:
      actual - the OptionalDouble to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static MatcherAssert assumeThat(Matcher actual)
      Creates a new instance of MatcherAssert assumption.
      Parameters:
      actual - the Matcher to test
      Returns:
      the created assumption for assertion object.
    • assumeThat

      public static OptionalIntAssert assumeThat(OptionalInt actual)
      Creates a new instance of OptionalIntAssert assumption.
      Parameters:
      actual - the OptionalInt to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static OptionalLongAssert assumeThat(OptionalLong actual)
      Creates a new instance of OptionalLongAssert assumption.
      Parameters:
      actual - the OptionalLong to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static AbstractZonedDateTimeAssert<?> assumeThat(ZonedDateTime actual)
      Creates a new instance of ZonedDateTimeAssert assumption.
      Parameters:
      actual - the ZonedDateTime to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static AbstractLocalDateTimeAssert<?> assumeThat(LocalDateTime actual)
      Creates a new instance of LocalDateTimeAssert assumption.
      Parameters:
      actual - the LocalDateTime to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static AbstractOffsetDateTimeAssert<?> assumeThat(OffsetDateTime actual)
      Creates a new instance of OffsetDateTimeAssert assumption.
      Parameters:
      actual - the OffsetDateTime to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static AbstractOffsetTimeAssert<?> assumeThat(OffsetTime actual)
      Creates a new instance of OffsetTimeAssert assumption.
      Parameters:
      actual - the LocalTime to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static AbstractLocalTimeAssert<?> assumeThat(LocalTime actual)
      Creates a new instance of LocalTimeAssert assumption.
      Parameters:
      actual - the LocalTime to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static AbstractLocalDateAssert<?> assumeThat(LocalDate actual)
      Creates a new instance of LocalDateAssert assumption.
      Parameters:
      actual - the LocalDate to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static AbstractInstantAssert<?> assumeThat(Instant actual)
      Creates a new instance of InstantAssert assumption.
      Parameters:
      actual - the Instant to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static AbstractDurationAssert<?> assumeThat(Duration actual)
      Creates a new instance of DurationAssert assumption.
      Parameters:
      actual - the Duration to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.15.0
    • assumeThat

      public static AbstractPeriodAssert<?> assumeThat(Period actual)
      Creates a new instance of PeriodAssert assumption.
      Parameters:
      actual - the Period to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.17.0
    • assumeThat

      public static <ELEMENT> AbstractListAssert<?,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>> assumeThat(Stream<? extends ELEMENT> actual)
      Creates a new instance of ListAssert assumption from the given Stream.
      Type Parameters:
      ELEMENT - the type of elements.
      Parameters:
      actual - the Stream to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThatStream

      public static <ELEMENT> AbstractListAssert<?,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>> assumeThatStream(Stream<? extends ELEMENT> actual)
      Creates a new instance of ListAssert assumption from the given Stream.

      Use this over assumeThat(Stream) in case of ambiguous method resolution when the object under test implements several interfaces Assertj provides assumeThat for.

      Type Parameters:
      ELEMENT - the type of elements.
      Parameters:
      actual - the actual value.
      Returns:
      the created assumption for assertion object.
      Since:
      3.23.0
    • assumeThat

      public static AbstractListAssert<?,List<? extends Double>,Double,ObjectAssert<Double>> assumeThat(DoubleStream actual)
      Creates a new instance of ListAssert assumption from the given DoubleStream.
      Parameters:
      actual - the DoubleStream to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static AbstractListAssert<?,List<? extends Long>,Long,ObjectAssert<Long>> assumeThat(LongStream actual)
      Creates a new instance of ListAssert assumption from the given LongStream.
      Parameters:
      actual - the LongStream to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static AbstractListAssert<?,List<? extends Integer>,Integer,ObjectAssert<Integer>> assumeThat(IntStream actual)
      Creates a new instance of ListAssert assumption from the given IntStream.
      Parameters:
      actual - the LongStream to test
      Returns:
      the created assumption for assertion object.
      Since:
      3.9.0
    • assumeThat

      public static <ELEMENT> AbstractSpliteratorAssert<?,ELEMENT> assumeThat(Spliterator<ELEMENT> actual)
      Creates a new instance of SpliteratorAssert assumption from the given Spliterator.
      Type Parameters:
      ELEMENT - the type of the elements
      Parameters:
      actual - the Spliterator to test
      Returns:
      the created assumption for assertion object.
    • setPreferredAssumptionException

      public static void setPreferredAssumptionException(PreferredAssumptionException preferredAssumptionException)
      Sets which exception is thrown if an assumption is not met.

      This method is useful if you are using a testing framework that supports assumptions and expect a specific exception to be thrown when an assumption is not met.

      You can choose one of:

      Make sure that the exception you choose can be found in the classpath otherwise AssertJ will throw an IllegalStateException.

      For example JUnit4 expects org.junit.AssumptionViolatedException, you can tell AssertJ to use it as shown below:

       // after this call, AssertJ will throw an org.junit.AssumptionViolatedException when an assumption is not met   
       Assertions.setPreferredAssumptionExceptions(PreferredAssumptionException.JUNIT4);
       

      By default, AssertJ uses the AUTO_DETECT mode and tries to throw one of the following exceptions, in this order:

      1. org.testng.SkipException for TestNG (if available in the classpath)
      2. org.junit.AssumptionViolatedException for JUnit 4 (if available in the classpath)
      3. org.opentest4j.TestAbortedException for JUnit 5
      Parameters:
      preferredAssumptionException - the preferred exception to use with Assumptions.
      Since:
      3.21.0
    • generateAssumptionClass

      protected static <ASSERTION> Class<? extends ASSERTION> generateAssumptionClass(Class<ASSERTION> assertionType)