public class Assumptions extends Object
| Constructor and Description |
|---|
Assumptions() |
| Modifier and Type | Method and Description |
|---|---|
static AtomicBooleanAssert |
assumeThat(AtomicBoolean actual)
Create assumption for
AtomicBoolean. |
static AtomicIntegerAssert |
assumeThat(AtomicInteger actual)
Create assumption for
AtomicInteger. |
static AtomicIntegerArrayAssert |
assumeThat(AtomicIntegerArray actual)
Creates int[] assumption for
AtomicIntegerArray. |
static <OBJECT> AtomicIntegerFieldUpdaterAssert<OBJECT> |
assumeThat(AtomicIntegerFieldUpdater<OBJECT> actual)
Create assumption for
AtomicIntegerFieldUpdater. |
static AtomicLongAssert |
assumeThat(AtomicLong actual)
Create assumption for
AtomicLong. |
static AtomicLongArrayAssert |
assumeThat(AtomicLongArray actual)
Create assumption for
AtomicLongArray. |
static <OBJECT> AtomicLongFieldUpdaterAssert<OBJECT> |
assumeThat(AtomicLongFieldUpdater<OBJECT> actual)
Create assumption for
AtomicLongFieldUpdater. |
static <VALUE> AtomicMarkableReferenceAssert<VALUE> |
assumeThat(AtomicMarkableReference<VALUE> actual)
Create assumption for
AtomicMarkableReference. |
static <VALUE> AtomicReferenceAssert<VALUE> |
assumeThat(AtomicReference<VALUE> actual)
Create assumption for
AtomicReference. |
static <ELEMENT> AtomicReferenceArrayAssert<ELEMENT> |
assumeThat(AtomicReferenceArray<ELEMENT> actual)
Create assumption for
AtomicReferenceArray. |
static <FIELD,OBJECT> |
assumeThat(AtomicReferenceFieldUpdater<OBJECT,FIELD> actual)
Create assumption for
AtomicReferenceFieldUpdater. |
static <VALUE> AtomicStampedReferenceAssert<VALUE> |
assumeThat(AtomicStampedReference<VALUE> actual)
Create assumption for
AtomicStampedReference. |
static AbstractBigDecimalAssert<?> |
assumeThat(BigDecimal actual)
Creates a new instance of
assumption. |
static AbstractBigIntegerAssert<?> |
assumeThat(BigInteger actual)
Creates a new instance of
assumption. |
static AbstractBooleanAssert<?> |
assumeThat(boolean actual)
Creates a new instance of
assumption. |
static AbstractBooleanAssert<?> |
assumeThat(Boolean actual)
Creates a new instance of
assumption. |
static AbstractBooleanArrayAssert<?> |
assumeThat(boolean[] actual)
Creates a new instance of
assumption. |
static Boolean2DArrayAssert |
assumeThat(boolean[][] actual)
Creates a new instance of
assumption. |
static AbstractByteAssert<?> |
assumeThat(byte actual)
Creates a new instance of
assumption. |
static AbstractByteAssert<?> |
assumeThat(Byte actual)
Creates a new instance of
assumption. |
static AbstractByteArrayAssert<?> |
assumeThat(byte[] actual)
Creates a new instance of
assumption. |
static Byte2DArrayAssert |
assumeThat(byte[][] actual)
Creates a new instance of
assumption. |
static AbstractCharacterAssert<?> |
assumeThat(char actual)
Creates a new instance of
assumption. |
static AbstractCharArrayAssert<?> |
assumeThat(char[] actual)
Creates a new instance of
assumption. |
static Char2DArrayAssert |
assumeThat(char[][] actual)
Creates a new instance of
assumption. |
static AbstractCharacterAssert<?> |
assumeThat(Character actual)
Creates a new instance of
assumption. |
static AbstractCharSequenceAssert<?,? extends CharSequence> |
assumeThat(CharSequence actual)
Creates a new instance of
assumption. |
static ClassAssert |
assumeThat(Class<?> actual)
Creates a new instance of
assumption. |
static <E> AbstractCollectionAssert<?,Collection<? extends E>,E,ObjectAssert<E>> |
assumeThat(Collection<? extends E> actual)
Creates a new instance of
assumption. |
static <RESULT> CompletableFutureAssert<RESULT> |
assumeThat(CompletableFuture<RESULT> actual)
Creates a new instance of
CompletableFutureAssert assumption. |
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. |
static AbstractDateAssert<?> |
assumeThat(Date actual)
Creates a new instance of
assumption. |
static AbstractDoubleAssert<?> |
assumeThat(double actual)
Creates a new instance of
assumption. |
static AbstractDoubleAssert<?> |
assumeThat(Double actual)
Creates a new instance of
assumption. |
static AbstractDoubleArrayAssert<?> |
assumeThat(double[] actual)
Creates a new instance of
assumption. |
static Double2DArrayAssert |
assumeThat(double[][] actual)
Creates a new instance of
assumption. |
static DoublePredicateAssert |
assumeThat(DoublePredicate actual)
Creates a new instance of
DoublePredicateAssert assumption. |
static AbstractListAssert<?,List<? extends Double>,Double,ObjectAssert<Double>> |
assumeThat(DoubleStream actual)
Creates a new instance of
assumption from the given DoubleStream. |
static AbstractDurationAssert<?> |
assumeThat(Duration actual)
Creates a new instance of
DurationAssert assumption. |
static AbstractFileAssert<?> |
assumeThat(File actual)
Creates a new instance of
assumption. |
static AbstractFloatAssert<?> |
assumeThat(float actual)
Creates a new instance of
assumption. |
static AbstractFloatAssert<?> |
assumeThat(Float actual)
Creates a new instance of
assumption. |
static AbstractFloatArrayAssert<?> |
assumeThat(float[] actual)
Creates a new instance of
assumption. |
static Float2DArrayAssert |
assumeThat(float[][] actual)
Creates a new instance of
assumption. |
static <RESULT> AbstractFutureAssert<?,? extends Future<? extends RESULT>,RESULT> |
assumeThat(Future<RESULT> future)
Create assertion for
FutureAssert assumption. |
static AbstractInputStreamAssert<?,? extends InputStream> |
assumeThat(InputStream actual)
Creates a new instance of
assumption. |
static AbstractInstantAssert<?> |
assumeThat(Instant actual)
Creates a new instance of
InstantAssert assumption. |
static AbstractIntegerAssert<?> |
assumeThat(int actual)
Creates a new instance of
assumption. |
static AbstractIntArrayAssert<?> |
assumeThat(int[] actual)
Creates a new instance of
assumption. |
static Int2DArrayAssert |
assumeThat(int[][] actual)
Creates a new instance of
assumption. |
static AbstractIntegerAssert<?> |
assumeThat(Integer actual)
Creates a new instance of
assumption. |
static IntPredicateAssert |
assumeThat(IntPredicate actual)
Creates a new instance of
IntPredicateAssert assumption. |
static AbstractListAssert<?,List<? extends Integer>,Integer,ObjectAssert<Integer>> |
assumeThat(IntStream actual)
Creates a new instance of
assumption from the given IntStream. |
static <ELEMENT> IterableAssert<ELEMENT> |
assumeThat(Iterable<? extends ELEMENT> actual)
Creates a new instance of
assumption. |
static <ELEMENT> IteratorAssert<ELEMENT> |
assumeThat(Iterator<? extends ELEMENT> actual)
Creates a new instance of
assumption. |
static <ELEMENT> FactoryBasedNavigableListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>> |
assumeThat(List<? extends ELEMENT> actual)
Creates a new instance of
assumption. |
static AbstractLocalDateAssert<?> |
assumeThat(LocalDate actual)
Creates a new instance of
LocalDateAssert assumption. |
static AbstractLocalDateTimeAssert<?> |
assumeThat(LocalDateTime actual)
Creates a new instance of
LocalDateTimeAssert assumption. |
static AbstractLocalTimeAssert<?> |
assumeThat(LocalTime actual)
Creates a new instance of
LocalTimeAssert assumption. |
static AbstractLongAssert<?> |
assumeThat(long actual)
Creates a new instance of
assumption. |
static AbstractLongAssert<?> |
assumeThat(Long actual)
Creates a new instance of
assumption. |
static AbstractLongArrayAssert<?> |
assumeThat(long[] actual)
Creates a new instance of
assumption. |
static Long2DArrayAssert |
assumeThat(long[][] actual)
Creates a new instance of
assumption. |
static LongAdderAssert |
assumeThat(LongAdder actual)
Create assumption for
LongAdder. |
static LongPredicateAssert |
assumeThat(LongPredicate actual)
Creates a new instance of
LongPredicateAssert assumption. |
static AbstractListAssert<?,List<? extends Long>,Long,ObjectAssert<Long>> |
assumeThat(LongStream actual)
Creates a new instance of
assumption from the given LongStream. |
static <K,V> MapAssert<K,V> |
assumeThat(Map<K,V> actual)
Creates a new instance of
assumption. |
static MatcherAssert |
assumeThat(Matcher actual)
Creates a new instance of
MatcherAssert assumption. |
static AbstractOffsetDateTimeAssert<?> |
assumeThat(OffsetDateTime actual)
Creates a new instance of
OffsetDateTimeAssert assumption. |
static AbstractOffsetTimeAssert<?> |
assumeThat(OffsetTime actual)
Creates a new instance of
OffsetTimeAssert assumption. |
static <VALUE> OptionalAssert<VALUE> |
assumeThat(Optional<VALUE> actual)
Creates a new instance of
OptionalAssert assumption. |
static OptionalDoubleAssert |
assumeThat(OptionalDouble actual)
Creates a new instance of
OptionalDoubleAssert assumption. |
static OptionalIntAssert |
assumeThat(OptionalInt actual)
Creates a new instance of
OptionalIntAssert assumption. |
static OptionalLongAssert |
assumeThat(OptionalLong actual)
Creates a new instance of
OptionalLongAssert assumption. |
static AbstractPathAssert<?> |
assumeThat(Path actual)
Creates a new instance of
PathAssert assumption. |
static AbstractPeriodAssert<?> |
assumeThat(Period actual)
Creates a new instance of
PeriodAssert assumption. |
static <T> PredicateAssert<T> |
assumeThat(Predicate<T> actual)
Creates a new instance of
PredicateAssert assumption. |
static AbstractShortAssert<?> |
assumeThat(short actual)
Creates a new instance of
assumption. |
static AbstractShortAssert<?> |
assumeThat(Short actual)
Creates a new instance of
assumption. |
static AbstractShortArrayAssert<?> |
assumeThat(short[] actual)
Creates a new instance of
assumption. |
static Short2DArrayAssert |
assumeThat(short[][] actual)
Creates a new instance of
assumption. |
static <ELEMENT> AbstractSpliteratorAssert<?,ELEMENT> |
assumeThat(Spliterator<ELEMENT> actual)
Creates a new instance of
assumption from the given Spliterator. |
static <ELEMENT> AbstractListAssert<?,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>> |
assumeThat(Stream<? extends ELEMENT> actual)
Creates a new instance of
assumption from the given Stream. |
static AbstractStringAssert<?> |
assumeThat(String actual)
Creates a new instance of
assumption. |
static AbstractCharSequenceAssert<?,? extends CharSequence> |
assumeThat(StringBuffer actual)
Creates a new instance of
assumption from a StringBuffer. |
static AbstractCharSequenceAssert<?,? extends CharSequence> |
assumeThat(StringBuilder actual)
Creates a new instance of
assumption from a StringBuilder. |
static <T> ObjectAssert<T> |
assumeThat(T actual)
Creates a new instance of
assumption. |
static <T extends Comparable<? super T>> |
assumeThat(T actual)
Creates a new instance of
assumption. |
static <T extends Throwable> |
assumeThat(T actual)
Creates a new instance of
assumption. |
static <T> ObjectArrayAssert<T> |
assumeThat(T[] actual)
Creates a new instance of
assumption. |
static <T> Object2DArrayAssert<T> |
assumeThat(T[][] actual)
Creates a new instance of
assumption. |
static AbstractUriAssert<?> |
assumeThat(URI actual)
Creates a new instance of
assumption. |
static AbstractUrlAssert<?> |
assumeThat(URL actual)
Creates a new instance of
assumption. |
static AbstractZonedDateTimeAssert<?> |
assumeThat(ZonedDateTime actual)
Creates a new instance of
ZonedDateTimeAssert assumption. |
static AbstractThrowableAssert<?,? extends Throwable> |
assumeThatCode(ThrowableAssert.ThrowingCallable shouldRaiseOrNotThrowable)
Allows to capture and then assume on a
Throwable (easier done with lambdas). |
static <E> AbstractCollectionAssert<?,Collection<? extends E>,E,ObjectAssert<E>> |
assumeThatCollection(Collection<? extends E> actual)
Creates a new instance of
assumption. |
static <T> AbstractUniversalComparableAssert<?,T> |
assumeThatComparable(Comparable<T> actual)
Creates a new instance of
assumption. |
static ThrowableTypeAssert<Exception> |
assumeThatException()
Alias for
assumeThatExceptionOfType(Class) for Exception. |
static <T extends Throwable> |
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. |
static ThrowableTypeAssert<IllegalArgumentException> |
assumeThatIllegalArgumentException()
Alias for
assumeThatExceptionOfType(Class) for IllegalArgumentException. |
static ThrowableTypeAssert<IndexOutOfBoundsException> |
assumeThatIndexOutOfBoundsException()
Alias for
assumeThatExceptionOfType(Class) for IndexOutOfBoundsException. |
static ThrowableTypeAssert<IOException> |
assumeThatIOException()
Alias for
assumeThatExceptionOfType(Class) for IOException. |
static <ELEMENT> IterableAssert<ELEMENT> |
assumeThatIterable(Iterable<? extends ELEMENT> actual)
Creates a new instance of
assumption. |
static <ELEMENT> IteratorAssert<ELEMENT> |
assumeThatIterator(Iterator<? extends ELEMENT> actual)
Creates a new instance of
assumption. |
static <ELEMENT> FactoryBasedNavigableListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>> |
assumeThatList(List<? extends ELEMENT> actual)
Creates a new instance of
assumption. |
static ThrowableTypeAssert<NullPointerException> |
assumeThatNullPointerException()
Alias for
assumeThatExceptionOfType(Class) for NullPointerException. |
static <T> ObjectAssert<T> |
assumeThatObject(T actual)
Creates a new instance of
assumption. |
static AbstractPathAssert<?> |
assumeThatPath(Path actual)
Creates a new instance of
assumption. |
static <T> PredicateAssert<T> |
assumeThatPredicate(Predicate<T> actual)
Creates a new instance of
assumption. |
static ThrowableTypeAssert<ReflectiveOperationException> |
assumeThatReflectiveOperationException()
Alias for
assumeThatExceptionOfType(Class) for ReflectiveOperationException. |
static ThrowableTypeAssert<RuntimeException> |
assumeThatRuntimeException()
Alias for
assumeThatExceptionOfType(Class) for RuntimeException. |
static <ELEMENT> AbstractListAssert<?,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>> |
assumeThatStream(Stream<? extends ELEMENT> actual)
Creates a new instance of
assumption from the given Stream. |
static AbstractThrowableAssert<?,? extends Throwable> |
assumeThatThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable)
Allows to capture and then assume on a
Throwable (easier done with lambdas). |
protected static <ASSERTION> |
generateAssumptionClass(Class<ASSERTION> assertionType) |
static void |
setPreferredAssumptionException(PreferredAssumptionException preferredAssumptionException)
Sets which exception is thrown if an assumption is not met.
|
public static <T> ObjectAssert<T> assumeThat(T actual)
ObjectAssert assumption.T - the type of the actual value.actual - the actual value.public static AbstractStringAssert<?> assumeThat(String actual)
StringAssert assumption.actual - the actual value.public static AbstractBigDecimalAssert<?> assumeThat(BigDecimal actual)
BigDecimalAssert assumption.actual - the actual value.public static AbstractBigIntegerAssert<?> assumeThat(BigInteger actual)
BigIntegerAssert assumption.actual - the actual value.public static AbstractUriAssert<?> assumeThat(URI actual)
UriAssert assumption.actual - the actual value.public static AbstractUrlAssert<?> assumeThat(URL actual)
UrlAssert assumption.actual - the actual value.public static AbstractBooleanAssert<?> assumeThat(boolean actual)
BooleanAssert assumption.actual - the actual value.public static AbstractBooleanAssert<?> assumeThat(Boolean actual)
BooleanAssert assumption.actual - the actual value.public static AbstractBooleanArrayAssert<?> assumeThat(boolean[] actual)
BooleanArrayAssert assumption.actual - the actual value.public static Boolean2DArrayAssert assumeThat(boolean[][] actual)
Boolean2DArrayAssert assumption.actual - the actual value.public static AbstractByteAssert<?> assumeThat(byte actual)
ByteAssert assumption.actual - the actual value.public static AbstractByteAssert<?> assumeThat(Byte actual)
ByteAssert assumption.actual - the actual value.public static AbstractByteArrayAssert<?> assumeThat(byte[] actual)
ByteArrayAssert assumption.actual - the actual value.public static Byte2DArrayAssert assumeThat(byte[][] actual)
Byte2DArrayAssert assumption.actual - the actual value.public static AbstractCharacterAssert<?> assumeThat(char actual)
CharacterAssert assumption.actual - the actual value.public static AbstractCharacterAssert<?> assumeThat(Character actual)
CharacterAssert assumption.actual - the actual value.public static AbstractCharArrayAssert<?> assumeThat(char[] actual)
CharArrayAssert assumption.actual - the actual value.public static Char2DArrayAssert assumeThat(char[][] actual)
Char2DArrayAssert assumption.actual - the actual value.public static AbstractCharSequenceAssert<?,? extends CharSequence> assumeThat(CharSequence actual)
CharSequenceAssert assumption.actual - the actual value.public static AbstractCharSequenceAssert<?,? extends CharSequence> assumeThat(StringBuilder actual)
CharSequenceAssert assumption from a StringBuilder.actual - the actual value.public static AbstractCharSequenceAssert<?,? extends CharSequence> assumeThat(StringBuffer actual)
CharSequenceAssert assumption from a StringBuffer.actual - the actual value.public static AbstractShortAssert<?> assumeThat(short actual)
ShortAssert assumption.actual - the actual value.public static AbstractShortAssert<?> assumeThat(Short actual)
ShortAssert assumption.actual - the actual value.public static AbstractShortArrayAssert<?> assumeThat(short[] actual)
ShortArrayAssert assumption.actual - the actual value.public static Short2DArrayAssert assumeThat(short[][] actual)
Short2DArrayAssert assumption.actual - the actual value.public static AbstractIntegerAssert<?> assumeThat(int actual)
IntegerAssert assumption.actual - the actual value.public static AbstractIntegerAssert<?> assumeThat(Integer actual)
IntegerAssert assumption.actual - the actual value.public static AbstractIntArrayAssert<?> assumeThat(int[] actual)
IntArrayAssert assumption.actual - the actual value.public static Int2DArrayAssert assumeThat(int[][] actual)
Int2DArrayAssert assumption.actual - the actual value.public static AbstractLongAssert<?> assumeThat(long actual)
LongAssert assumption.actual - the actual value.public static AbstractLongAssert<?> assumeThat(Long actual)
LongAssert assumption.actual - the actual value.public static AbstractLongArrayAssert<?> assumeThat(long[] actual)
LongArrayAssert assumption.actual - the actual value.public static Long2DArrayAssert assumeThat(long[][] actual)
Long2DArrayAssert assumption.actual - the actual value.public static AbstractFloatAssert<?> assumeThat(float actual)
FloatAssert assumption.actual - the actual value.public static AbstractFloatAssert<?> assumeThat(Float actual)
FloatAssert assumption.actual - the actual value.public static AbstractFloatArrayAssert<?> assumeThat(float[] actual)
FloatArrayAssert assumption.actual - the actual value.public static Float2DArrayAssert assumeThat(float[][] actual)
Float2DArrayAssert assumption.actual - the actual value.public static AbstractDoubleAssert<?> assumeThat(double actual)
DoubleAssert assumption.actual - the actual value.public static AbstractDoubleAssert<?> assumeThat(Double actual)
DoubleAssert assumption.actual - the actual value.public static AbstractDoubleArrayAssert<?> assumeThat(double[] actual)
DoubleArrayAssert assumption.actual - the actual value.public static Double2DArrayAssert assumeThat(double[][] actual)
Double2DArrayAssert assumption.actual - the actual value.public static AtomicBooleanAssert assumeThat(AtomicBoolean actual)
AtomicBoolean.actual - the actual value.public static AtomicIntegerAssert assumeThat(AtomicInteger actual)
AtomicInteger.actual - the actual value.public static AtomicIntegerArrayAssert assumeThat(AtomicIntegerArray actual)
AtomicIntegerArray.actual - the actual value.public static <OBJECT> AtomicIntegerFieldUpdaterAssert<OBJECT> assumeThat(AtomicIntegerFieldUpdater<OBJECT> actual)
AtomicIntegerFieldUpdater.OBJECT - the type of the object holding the updatable field.actual - the actual value.public static LongAdderAssert assumeThat(LongAdder actual)
LongAdder.actual - the actual value.public static AtomicLongAssert assumeThat(AtomicLong actual)
AtomicLong.actual - the actual value.public static AtomicLongArrayAssert assumeThat(AtomicLongArray actual)
AtomicLongArray.actual - the actual value.public static <OBJECT> AtomicLongFieldUpdaterAssert<OBJECT> assumeThat(AtomicLongFieldUpdater<OBJECT> actual)
AtomicLongFieldUpdater.OBJECT - the type of the object holding the updatable field.actual - the actual value.public static <VALUE> AtomicReferenceAssert<VALUE> assumeThat(AtomicReference<VALUE> actual)
AtomicReference.VALUE - the type of the value contained in the AtomicReference.actual - the actual value.public static <ELEMENT> AtomicReferenceArrayAssert<ELEMENT> assumeThat(AtomicReferenceArray<ELEMENT> actual)
AtomicReferenceArray.ELEMENT - the type of the value contained in the AtomicReferenceArray.actual - the actual value.public static <FIELD,OBJECT> AtomicReferenceFieldUpdaterAssert<FIELD,OBJECT> assumeThat(AtomicReferenceFieldUpdater<OBJECT,FIELD> actual)
AtomicReferenceFieldUpdater.FIELD - the type of the field which gets updated by the AtomicReferenceFieldUpdater.OBJECT - the type of the object holding the updatable field.actual - the actual value.public static <VALUE> AtomicMarkableReferenceAssert<VALUE> assumeThat(AtomicMarkableReference<VALUE> actual)
AtomicMarkableReference.VALUE - the type of the value contained in the AtomicMarkableReference.actual - the actual value.public static <VALUE> AtomicStampedReferenceAssert<VALUE> assumeThat(AtomicStampedReference<VALUE> actual)
AtomicStampedReference.VALUE - the type of the value contained in the AtomicStampedReference.actual - the actual value.public static ClassAssert assumeThat(Class<?> actual)
ClassAssert assumption.actual - the actual value.public static AbstractDateAssert<?> assumeThat(Date actual)
DateAssert assumption.actual - the actual value.public static AbstractFileAssert<?> assumeThat(File actual)
FileAssert assumption.actual - the actual value.public static AbstractPathAssert<?> assumeThat(Path actual)
PathAssert assumption.actual - the path to testpublic static AbstractPathAssert<?> assumeThatPath(Path actual)
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.
actual - the actual value.public static AbstractInputStreamAssert<?,? extends InputStream> assumeThat(InputStream actual)
InputStreamAssert assumption.actual - the actual value.public static <RESULT> AbstractFutureAssert<?,? extends Future<? extends RESULT>,RESULT> assumeThat(Future<RESULT> future)
FutureAssert assumption.RESULT - the type of the value contained in the Future.future - the actual value.public static <ELEMENT> IterableAssert<ELEMENT> assumeThat(Iterable<? extends ELEMENT> actual)
IterableAssert assumption.ELEMENT - the type of elements.actual - the actual value.public static <ELEMENT> IterableAssert<ELEMENT> assumeThatIterable(Iterable<? extends ELEMENT> actual)
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.
ELEMENT - the type of elements.actual - the actual value.public static <ELEMENT> IteratorAssert<ELEMENT> assumeThat(Iterator<? extends ELEMENT> actual)
IteratorAssert assumption.ELEMENT - the type of elements.actual - the actual value.public static <ELEMENT> IteratorAssert<ELEMENT> assumeThatIterator(Iterator<? extends ELEMENT> actual)
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.
ELEMENT - the type of elements.actual - the actual value.public static <E> AbstractCollectionAssert<?,Collection<? extends E>,E,ObjectAssert<E>> assumeThat(Collection<? extends E> actual)
CollectionAssert assumption.E - the type of elements.actual - the actual value.public static <E> AbstractCollectionAssert<?,Collection<? extends E>,E,ObjectAssert<E>> assumeThatCollection(Collection<? extends E> actual)
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.
E - the type of elements.actual - the actual value.public static <ELEMENT> FactoryBasedNavigableListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>> assumeThat(List<? extends ELEMENT> actual)
ListAssert assumption.ELEMENT - the type of elements.actual - the actual value.public static <ELEMENT> FactoryBasedNavigableListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>> assumeThatList(List<? extends ELEMENT> actual)
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.
ELEMENT - the type of elements.actual - the actual value.public static <T> ObjectArrayAssert<T> assumeThat(T[] actual)
ObjectArrayAssert assumption.T - the type of elements.actual - the actual value.public static <T> Object2DArrayAssert<T> assumeThat(T[][] actual)
Object2DArrayAssert assumption.T - the type of elements.actual - the actual value.public static <K,V> MapAssert<K,V> assumeThat(Map<K,V> actual)
MapAssert assumption.K - the type of keys in the map.V - the type of values in the map.actual - the actual value.public static <T extends Comparable<? super T>> AbstractComparableAssert<?,T> assumeThat(T actual)
GenericComparableAssert assumption.T - the type of actual.actual - the actual value.public static <T> AbstractUniversalComparableAssert<?,T> assumeThatComparable(Comparable<T> actual)
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.
T - the type of actual.actual - the actual value.public static <T extends Throwable> AbstractThrowableAssert<?,T> assumeThat(T actual)
ThrowableAssert assumption.T - the type of the actual throwable.actual - the actual value.public static <T extends Throwable> ThrowableTypeAssert<T> assumeThatExceptionOfType(Class<? extends T> exceptionType)
throwingCallable
which allows to chain assertions on the thrown exception.T - the exception type.exceptionType - the exception type class.ThrowableTypeAssert.public static ThrowableTypeAssert<Exception> assumeThatException()
assumeThatExceptionOfType(Class) for Exception.public static ThrowableTypeAssert<RuntimeException> assumeThatRuntimeException()
assumeThatExceptionOfType(Class) for RuntimeException.public static ThrowableTypeAssert<NullPointerException> assumeThatNullPointerException()
assumeThatExceptionOfType(Class) for NullPointerException.public static ThrowableTypeAssert<IllegalArgumentException> assumeThatIllegalArgumentException()
assumeThatExceptionOfType(Class) for IllegalArgumentException.public static ThrowableTypeAssert<IOException> assumeThatIOException()
assumeThatExceptionOfType(Class) for IOException.public static ThrowableTypeAssert<IndexOutOfBoundsException> assumeThatIndexOutOfBoundsException()
assumeThatExceptionOfType(Class) for IndexOutOfBoundsException.public static ThrowableTypeAssert<ReflectiveOperationException> assumeThatReflectiveOperationException()
assumeThatExceptionOfType(Class) for ReflectiveOperationException.public static AbstractThrowableAssert<?,? extends Throwable> assumeThatThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable)
Throwable (easier done with lambdas).
Example :
@Test
public void testException() {
assumeThatThrownBy(() -> { throw new Exception("boom!") }).isInstanceOf(Exception.class)
.hasMessageContaining("boom");
}shouldRaiseThrowable - The ThrowableAssert.ThrowingCallable or lambda with the code that should raise the throwable.public static AbstractThrowableAssert<?,? extends Throwable> assumeThatCode(ThrowableAssert.ThrowingCallable shouldRaiseOrNotThrowable)
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 :(
shouldRaiseOrNotThrowable - The ThrowableAssert.ThrowingCallable or lambda with the code that should raise the throwable.ThrowableAssert.public static <T> ObjectAssert<T> assumeThatObject(T actual)
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")); T - the type of the actual value.actual - the actual value.public static <T> PredicateAssert<T> assumeThat(Predicate<T> actual)
PredicateAssert assumption.T - the Predicate type.actual - the Predicate to testpublic static <T> PredicateAssert<T> assumeThatPredicate(Predicate<T> actual)
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.
T - the type of elements.actual - the actual value.public static IntPredicateAssert assumeThat(IntPredicate actual)
IntPredicateAssert assumption.actual - the IntPredicate to testpublic static LongPredicateAssert assumeThat(LongPredicate actual)
LongPredicateAssert assumption.actual - the LongPredicate to testpublic static DoublePredicateAssert assumeThat(DoublePredicate actual)
DoublePredicateAssert assumption.actual - the DoublePredicate to testpublic static <RESULT> CompletableFutureAssert<RESULT> assumeThat(CompletableFuture<RESULT> actual)
CompletableFutureAssert assumption.RESULT - the CompletableFuture wrapped type.actual - the CompletableFuture to testpublic static <RESULT> CompletableFutureAssert<RESULT> assumeThat(CompletionStage<RESULT> actual)
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.
RESULT - the CompletableFuture wrapped type.actual - the CompletableFuture to testpublic static <VALUE> OptionalAssert<VALUE> assumeThat(Optional<VALUE> actual)
OptionalAssert assumption.VALUE - the Optional wrapped type.actual - the Optional to testpublic static OptionalDoubleAssert assumeThat(OptionalDouble actual)
OptionalDoubleAssert assumption.actual - the OptionalDouble to testpublic static MatcherAssert assumeThat(Matcher actual)
MatcherAssert assumption.actual - the Matcher to testpublic static OptionalIntAssert assumeThat(OptionalInt actual)
OptionalIntAssert assumption.actual - the OptionalInt to testpublic static OptionalLongAssert assumeThat(OptionalLong actual)
OptionalLongAssert assumption.actual - the OptionalLong to testpublic static AbstractZonedDateTimeAssert<?> assumeThat(ZonedDateTime actual)
ZonedDateTimeAssert assumption.actual - the ZonedDateTime to testpublic static AbstractLocalDateTimeAssert<?> assumeThat(LocalDateTime actual)
LocalDateTimeAssert assumption.actual - the LocalDateTime to testpublic static AbstractOffsetDateTimeAssert<?> assumeThat(OffsetDateTime actual)
OffsetDateTimeAssert assumption.actual - the OffsetDateTime to testpublic static AbstractOffsetTimeAssert<?> assumeThat(OffsetTime actual)
OffsetTimeAssert assumption.actual - the LocalTime to testpublic static AbstractLocalTimeAssert<?> assumeThat(LocalTime actual)
LocalTimeAssert assumption.actual - the LocalTime to testpublic static AbstractLocalDateAssert<?> assumeThat(LocalDate actual)
LocalDateAssert assumption.actual - the LocalDate to testpublic static AbstractInstantAssert<?> assumeThat(Instant actual)
InstantAssert assumption.actual - the Instant to testpublic static AbstractDurationAssert<?> assumeThat(Duration actual)
DurationAssert assumption.actual - the Duration to testpublic static AbstractPeriodAssert<?> assumeThat(Period actual)
PeriodAssert assumption.actual - the Period to testpublic static <ELEMENT> AbstractListAssert<?,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>> assumeThat(Stream<? extends ELEMENT> actual)
ListAssert assumption from the given Stream.ELEMENT - the type of elements.actual - the Stream to testpublic static <ELEMENT> AbstractListAssert<?,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>> assumeThatStream(Stream<? extends ELEMENT> actual)
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.
ELEMENT - the type of elements.actual - the actual value.public static AbstractListAssert<?,List<? extends Double>,Double,ObjectAssert<Double>> assumeThat(DoubleStream actual)
ListAssert assumption from the given DoubleStream.actual - the DoubleStream to testpublic static AbstractListAssert<?,List<? extends Long>,Long,ObjectAssert<Long>> assumeThat(LongStream actual)
ListAssert assumption from the given LongStream.actual - the LongStream to testpublic static AbstractListAssert<?,List<? extends Integer>,Integer,ObjectAssert<Integer>> assumeThat(IntStream actual)
ListAssert assumption from the given IntStream.actual - the LongStream to testpublic static <ELEMENT> AbstractSpliteratorAssert<?,ELEMENT> assumeThat(Spliterator<ELEMENT> actual)
SpliteratorAssert assumption from the given Spliterator.ELEMENT - the type of the elementsactual - the Spliterator to testpublic static void setPreferredAssumptionException(PreferredAssumptionException preferredAssumptionException)
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:
PreferredAssumptionException.TEST_NG to throw a org.testng.SkipException if you are using TestNGPreferredAssumptionException.JUNIT4 to throw a org.junit.AssumptionViolatedException if you are using JUnit 4PreferredAssumptionException.JUNIT5 a org.opentest4j.TestAbortedException if you are using JUnit 5PreferredAssumptionException.AUTO_DETECT to get the default behavior where AssertJ tries different exception (explained later on)
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:
org.testng.SkipException for TestNG (if available in the classpath)org.junit.AssumptionViolatedException for JUnit 4 (if available in the classpath)org.opentest4j.TestAbortedException for JUnit 5preferredAssumptionException - the preferred exception to use with Assumptions.Copyright © 2025. All rights reserved.