Top Description Fields Methods
org.assertj.core.api

public Interface WithAssertions

extends InstanceOfAssertFactories
Annotations
@CheckReturnValue
Imports
java.io.File, .IOException, .InputStream, .UncheckedIOException, java.math.BigDecimal, .BigInteger, java.net.URI, .URL, java.nio.charset.Charset, java.nio.file.Path, java.text.DateFormat, java.time.Duration, .Instant, .LocalDate, .LocalDateTime, .LocalTime, .OffsetDateTime, .OffsetTime, .Period, .YearMonth, .ZonedDateTime, java.time.temporal.Temporal, .TemporalUnit, java.util.Collection, .Date, .Iterator, .List, .Map, .Optional, .OptionalDouble, .OptionalInt, .OptionalLong, .Spliterator, java.util.concurrent.CompletableFuture, .CompletionStage, .Future, java.util.concurrent.atomic.AtomicBoolean, .AtomicInteger, .AtomicIntegerArray, .AtomicIntegerFieldUpdater, .AtomicLong, .AtomicLongArray, .AtomicLongFieldUpdater, .AtomicMarkableReference, .AtomicReference, .AtomicReferenceArray, .AtomicReferenceFieldUpdater, .AtomicStampedReference, .LongAdder, java.util.function.Consumer, .DoublePredicate, .Function, .IntPredicate, .LongPredicate, .Predicate, java.util.regex.Matcher, java.util.stream.DoubleStream, .IntStream, .LongStream, .Stream, org.assertj.core.api.ThrowableAssert.ThrowingCallable, org.assertj.core.api.filter.FilterOperator, .Filters, .InFilter, .NotFilter, .NotInFilter, org.assertj.core.condition.AllOf, .AnyOf, .DoesNotHave, .Not, org.assertj.core.configuration.Configuration, org.assertj.core.data.Index, .MapEntry, .Offset, .Percentage, .TemporalUnitOffset, org.assertj.core.description.Description, org.assertj.core.groups.Properties, .Tuple, org.assertj.core.presentation.BinaryRepresentation, .HexadecimalRepresentation, .Representation, .StandardRepresentation, .UnicodeRepresentation, org.assertj.core.util.CanIgnoreReturnValue, .CheckReturnValue

A unified entry point to all non-deprecated assertions from both the new Java 8 core API and the pre-Java 8 core API. As a convenience, the methods are defined in an interface so that no static imports are necessary if the test class implements this interface. Based on an idea by David Gageot : http://blog.javabien.net/2014/04/23/what-if-assertj-used-java-8/
Author
Alan Rothkopf

Field Summary

Inherited from org.assertj.core.api.InstanceOfAssertFactories:
ARRAYARRAY_2DATOMIC_BOOLEANATOMIC_INTEGERATOMIC_INTEGER_ARRAYATOMIC_INTEGER_FIELD_UPDATERATOMIC_LONGATOMIC_LONG_ARRAYATOMIC_LONG_FIELD_UPDATERATOMIC_MARKABLE_REFERENCEATOMIC_REFERENCEATOMIC_REFERENCE_ARRAYATOMIC_REFERENCE_FIELD_UPDATERATOMIC_STAMPED_REFERENCEBIG_DECIMALBIG_INTEGERBOOLEANBOOLEAN_2D_ARRAYBOOLEAN_ARRAYBYTEBYTE_2D_ARRAYBYTE_ARRAYCHAR_2D_ARRAYCHAR_ARRAYCHAR_SEQUENCECHARACTERCLASSCOLLECTIONCOMPLETABLE_FUTURECOMPLETION_STAGEDATEDOUBLEDOUBLE_2D_ARRAYDOUBLE_ARRAYDOUBLE_PREDICATEDOUBLE_STREAMDURATIONFILEFLOATFLOAT_2D_ARRAYFLOAT_ARRAYFUTUREINPUT_STREAMINSTANTINT_2D_ARRAYINT_ARRAYINT_PREDICATEINT_STREAMINTEGERITERABLEITERATORLISTLOCAL_DATELOCAL_DATE_TIMELOCAL_TIMELONGLONG_2D_ARRAYLONG_ADDERLONG_ARRAYLONG_PREDICATELONG_STREAMMAPMATCHEROFFSET_DATE_TIMEOFFSET_TIMEOPTIONALOPTIONAL_DOUBLEOPTIONAL_INTOPTIONAL_LONGPATHPERIODPREDICATESETSHORTSHORT_2D_ARRAYSHORT_ARRAYSPLITERATORSTREAMSTRINGSTRING_BUFFERSTRING_BUILDERTEMPORALTHROWABLEURI_TYPEURL_TYPEYEAR_MONTHZONED_DATE_TIME

Method Summary

Modifier and TypeMethod and Description
public default <
the type of object the given condition accept.
T
>
Condition<T>

Returns:

the created AllOf.
allOf
(final Iterable<? extends Condition<? super T>>
the conditions to evaluate.
conditions
)

Creates a new AllOf

public default <
the type of object the given condition accept.
T
>
Condition<T>

Returns:

the created AllOf.
allOf
(final Condition<? super T>...
the conditions to evaluate.
conditions
)

Creates a new AllOf

public default <
the type of object the given consumers accept
T
>
ThrowingConsumer<T>

Returns:

the ThrowingConsumer instance
allOf
(ThrowingConsumer<? super T>...
the consumers to evaluate
consumers
)

Create a new ThrowingConsumer that delegates the evaluation of the given consumers to AbstractAssert#satisfies(ThrowingConsumer[]).

public default <
the type of object the given condition accept.
T
>
Condition<T>

Returns:

the created AnyOf.
anyOf
(final Iterable<? extends Condition<? super T>>
the conditions to evaluate.
conditions
)

Creates a new AnyOf

public default <
the type of object the given condition accept.
T
>
Condition<T>

Returns:

the created AnyOf.
anyOf
(final Condition<? super T>...
the conditions to evaluate.
conditions
)

Only delegate to AnyOf#anyOf(Condition...) so that Assertions offers a full feature entry point to all AssertJ features (but you can use AnyOf if you prefer).

public default <
the type of object the given consumers accept
T
>
ThrowingConsumer<T>

Returns:

the ThrowingConsumer instance
anyOf
(ThrowingConsumer<? super T>...
the consumers to evaluate
consumers
)

Create a new ThrowingConsumer that delegates the evaluation of the given consumers to AbstractAssert#satisfiesAnyOf(ThrowingConsumer[]).

public default <
the type to use for the cast.
T
,
the type of the resulting Assert
ASSERT extends AbstractAssert<?, ?>
>
InstanceOfAssertFactory<T, ASSERT>

Returns:

same instance of assertFactory
as
(InstanceOfAssertFactory<T, ASSERT>
the factory which verifies the type and creates the new Assert
assertFactory
)

A syntax sugar to write fluent assertion with methods having an InstanceOfAssertFactory parameter.

public default <
the actual's elements type.
T
>
ObjectArrayAssert<T>

Returns:

the created assertion object.
assertThat
(final T[]
the actual value.
actual
)

Creates a new instance of ObjectArrayAssert.

public default <
the actual's elements type.
T
>
Object2DArrayAssert<T>

Returns:

the created assertion object.
assertThat
(final T[][]
the actual value.
actual
)

Creates a new instance of Object2DArrayAssert.

public default <
the generic type of the user-defined assert.
T extends AssertDelegateTarget
>
T

Returns:

the given assertion.
assertThat
(final T
the assertion to return.
assertion
)

Returns the given assertion.

public default <
the type of keys in the map.
K
,
the type of values in the map.
V
>
MapAssert<K, V>

Returns:

the created assertion object.
assertThat
(final Map<K, V>
the actual value.
actual
)

Creates a new instance of MapAssert.

public default AbstractShortAssert<?>

Returns:

the created assertion object.
assertThat
(final short
the actual value.
actual
)

Creates a new instance of ShortAssert.

public default AbstractLongAssert<?>

Returns:

the created assertion object.
assertThat
(final long
the actual value.
actual
)

Creates a new instance of LongAssert.

public default AbstractLongAssert<?>

Returns:

the created assertion object.
assertThat
(final Long
the actual value.
actual
)

Creates a new instance of LongAssert.

public default AbstractLongArrayAssert<?>

Returns:

the created assertion object.
assertThat
(final long[]
the actual value.
actual
)

Creates a new instance of LongArrayAssert.

public default Long2DArrayAssert

Returns:

the created assertion object.
assertThat
(final long[][]
the actual value.
actual
)

Creates a new instance of Long2DArrayAssert.

public default <
the type of the actual value.
T
>
ObjectAssert<T>

Returns:

the created assertion object.
assertThat
(final T
the actual value.
actual
)

Creates a new instance of ObjectAssert.

public default AbstractStringAssert<?>

Returns:

the created assertion object.
assertThat
(final String
the actual value.
actual
)

Creates a new instance of CharSequenceAssertfrom a String.

public default AbstractDateAssert<?>

Returns:

the created assertion object.
assertThat
(final Date
the actual value.
actual
)

Creates a new instance of DateAssert.

public default <
the type of the actual throwable.
T extends Throwable
>
AbstractThrowableAssert<?, T>

Returns:

the created ThrowableAssert.
assertThat
(final T
the actual value.
actual
)

Creates a new instance of ThrowableAssert.

public default AbstractBigDecimalAssert<?>

Returns:

the created assertion object.
assertThat
(final BigDecimal
the actual value.
actual
)

Creates a new instance of BigDecimalAssert.

public default AbstractBigIntegerAssert<?>

Returns:

the created assertion object.
assertThat
(BigInteger
the actual value.
actual
)

Creates a new instance of BigIntegerAssert.

public default AtomicBooleanAssert

Returns:

the created assertion object.
assertThat
(AtomicBoolean
the actual value.
actual
)

Create assertion for AtomicBoolean.

public default AtomicIntegerAssert

Returns:

the created assertion object.
assertThat
(AtomicInteger
the actual value.
actual
)

Create assertion for AtomicInteger.

public default AtomicIntegerArrayAssert

Returns:

the created assertion object.
assertThat
(AtomicIntegerArray
the actual value.
actual
)

Create int[] assertion for AtomicIntegerArray.

public default <
the type of the object holding the updatable field.
OBJECT
>
AtomicIntegerFieldUpdaterAssert<OBJECT>

Returns:

the created assertion object.
assertThat
(AtomicIntegerFieldUpdater<OBJECT>
the actual value.
actual
)

Create assertion for AtomicIntegerFieldUpdater.

public default LongAdderAssert

Returns:

the created assertion object.
assertThat
(LongAdder
the actual value.
actual
)

Create assertion for LongAdder.

public default AtomicLongAssert

Returns:

the created assertion object.
assertThat
(AtomicLong
the actual value.
actual
)

Create assertion for AtomicLong.

public default AtomicLongArrayAssert

Returns:

the created assertion object.
assertThat
(AtomicLongArray
the actual value.
actual
)

Create assertion for AtomicLongArray.

public default <
the type of the object holding the updatable field.
OBJECT
>
AtomicLongFieldUpdaterAssert<OBJECT>

Returns:

the created assertion object.
assertThat
(AtomicLongFieldUpdater<OBJECT>
the actual value.
actual
)

Create assertion for AtomicLongFieldUpdater.

public default <
the type of the value contained in the AtomicReference.
VALUE
>
AtomicReferenceAssert<VALUE>

Returns:

the created assertion object.
assertThat
(AtomicReference<VALUE>
the actual value.
actual
)

Create assertion for AtomicReference.

public default <
the type of the value contained in the AtomicReferenceArray.
ELEMENT
>
AtomicReferenceArrayAssert<ELEMENT>

Returns:

the created assertion object.
assertThat
(AtomicReferenceArray<ELEMENT>
the actual value.
actual
)

Create assertion for AtomicReferenceArray.

public default <
the type of the field which gets updated by the AtomicReferenceFieldUpdater.
FIELD
,
the type of the object holding the updatable field.
OBJECT
>
AtomicReferenceFieldUpdaterAssert<FIELD, OBJECT>

Returns:

the created assertion object.
assertThat
(AtomicReferenceFieldUpdater<OBJECT, FIELD>
the actual value.
actual
)

Create assertion for AtomicReferenceFieldUpdater.

public default <
the type of the value contained in the AtomicMarkableReference.
VALUE
>
AtomicMarkableReferenceAssert<VALUE>

Returns:

the created assertion object.
assertThat
(AtomicMarkableReference<VALUE>
the actual value.
actual
)

Create assertion for AtomicMarkableReference.

public default <
the type of the value contained in the AtomicStampedReference.
VALUE
>
AtomicStampedReferenceAssert<VALUE>

Returns:

the created assertion object.
assertThat
(AtomicStampedReference<VALUE>
the actual value.
actual
)

Create assertion for AtomicStampedReference.

public default AbstractCharSequenceAssert<?, ? extends CharSequence>

Returns:

the created assertion object.
assertThat
(final CharSequence
the actual value.
actual
)

Creates a new instance of CharSequenceAssert.

public default AbstractCharSequenceAssert<?, ? extends CharSequence>

Returns:

the created assertion object.
assertThat
(final StringBuilder
the actual value.
actual
)

Creates a new instance of CharSequenceAssert from a StringBuilder.

public default AbstractCharSequenceAssert<?, ? extends CharSequence>

Returns:

the created assertion object.
assertThat
(final StringBuffer
the actual value.
actual
)

Creates a new instance of CharSequenceAssert from a StringBuffer.

public default AbstractShortArrayAssert<?>

Returns:

the created assertion object.
assertThat
(final short[]
the actual value.
actual
)

Creates a new instance of ShortArrayAssert.

public default Short2DArrayAssert

Returns:

the created assertion object.
assertThat
(final short[][]
the actual value.
actual
)

Creates a new instance of Short2DArrayAssert.

public default AbstractShortAssert<?>

Returns:

the created assertion object.
assertThat
(final Short
the actual value.
actual
)

Creates a new instance of ShortAssert.

public default ClassAssert

Returns:

the created assertion object.
assertThat
(final Class<?>
the actual value.
actual
)

Creates a new instance of ClassAssert.

public default AbstractCharacterAssert<?>

Returns:

the created assertion object.
assertThat
(final Character
the actual value.
actual
)

Creates a new instance of CharacterAssert.

public default AbstractCharArrayAssert<?>

Returns:

the created assertion object.
assertThat
(final char[]
the actual value.
actual
)

Creates a new instance of CharArrayAssert.

public default Char2DArrayAssert

Returns:

the created assertion object.
assertThat
(final char[][]
the actual value.
actual
)

Creates a new instance of Char2DArrayAssert.

public default AbstractCharacterAssert<?>

Returns:

the created assertion object.
assertThat
(final char
the actual value.
actual
)

Creates a new instance of CharacterAssert.

public default <
the type of actual.
T extends Comparable<? super T>
>
AbstractComparableAssert<?, T>

Returns:

the created assertion object.
assertThat
(final T
the actual value.
actual
)

Creates a new instance of GenericComparableAssert with standard comparison semantics.

public default <
the type of elements.
T
>
IterableAssert<T>

Returns:

the created assertion object.
assertThat
(final Iterable<? extends T>
the actual value.
actual
)

Creates a new instance of IterableAssert.

public default <
The actual type
ACTUAL extends Iterable<? extends ELEMENT>
,
The actual elements type
ELEMENT
,
The actual elements AbstractAssert type
ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>
>
FactoryBasedNavigableIterableAssert<?, ACTUAL, ELEMENT, ELEMENT_ASSERT>

Returns:

the created assertion object.
assertThat
(Iterable<? extends ELEMENT>
the actual value.
actual
,
AssertFactory<ELEMENT, ELEMENT_ASSERT>
the factory used to create the elements assert instance.
assertFactory
)

Deprecated This was added to help creating type-specific assertions for the elements of an Iterable instance.
Creates a new instance of FactoryBasedNavigableIterableAssert allowing to navigate to any Iterable element in order to perform assertions on it.
public default <
the type of elements.
T
>
IteratorAssert<T>

Returns:

the created assertion object.
assertThat
(final Iterator<? extends T>
the actual value.
actual
)

Creates a new instance of IteratorAssert.

public default <
The actual type
ACTUAL extends Iterable<? extends ELEMENT>
,
The actual elements type
ELEMENT
,
The actual elements AbstractAssert type
ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>
>
ClassBasedNavigableIterableAssert<?, ACTUAL, ELEMENT, ELEMENT_ASSERT>

Returns:

the created assertion object.
assertThat
(ACTUAL
the actual value.
actual
,
Class<ELEMENT_ASSERT>
the class used to create the elements assert instance.
assertClass
)

Deprecated This was added to help creating type-specific assertions for the elements of an Iterable instance.
Creates a new instance of ClassBasedNavigableIterableAssert allowing to navigate to any Iterable element in order to perform assertions on it.
public default AbstractBooleanAssert<?>

Returns:

the created assertion object.
assertThat
(final Boolean
the actual value.
actual
)

Creates a new instance of BooleanAssert.

public default AbstractBooleanArrayAssert<?>

Returns:

the created assertion object.
assertThat
(final boolean[]
the actual value.
actual
)

Creates a new instance of BooleanArrayAssert.

public default Boolean2DArrayAssert

Returns:

the created assertion object.
assertThat
(final boolean[][]
the actual value.
actual
)

Creates a new instance of Boolean2DArrayAssert.

public default AbstractByteAssert<?>

Returns:

the created assertion object.
assertThat
(final byte
the actual value.
actual
)

Creates a new instance of ByteAssert.

public default AbstractByteAssert<?>

Returns:

the created assertion object.
assertThat
(final Byte
the actual value.
actual
)

Creates a new instance of ByteAssert.

public default AbstractByteArrayAssert<?>

Returns:

the created assertion object.
assertThat
(final byte[]
the actual value.
actual
)

Creates a new instance of ByteArrayAssert.

public default Byte2DArrayAssert

Returns:

the created assertion object.
assertThat
(final byte[][]
the actual value.
actual
)

Creates a new instance of Byte2DArrayAssert.

public default AbstractBooleanAssert<?>

Returns:

the created assertion object.
assertThat
(final boolean
the actual value.
actual
)

Creates a new instance of BooleanAssert.

public default AbstractFloatAssert<?>

Returns:

the created assertion object.
assertThat
(final float
the actual value.
actual
)

Creates a new instance of FloatAssert.

public default AbstractInputStreamAssert<?, ? extends InputStream>

Returns:

the created assertion object.
assertThat
(final InputStream
the actual value.
actual
)

Creates a new instance of InputStreamAssert.

public default AbstractFileAssert<?>

Returns:

the created assertion object.
assertThat
(final File
the actual value.
actual
)

Creates a new instance of FileAssert.

public default <
the type of the value contained in the java.util.concurrent.Future.
RESULT
>
FutureAssert<RESULT>

Returns:

the created assertion object.
assertThat
(Future<RESULT>
the actual value.
actual
)

Create assertion for java.util.concurrent.Future.

public default AbstractPathAssert<?>

Returns:

the created assertion object
assertThat
(final Path
the path to test
actual
)

Creates a new instance of PathAssert

public default AbstractIntArrayAssert<?>

Returns:

the created assertion object.
assertThat
(final int[]
the actual value.
actual
)

Creates a new instance of IntArrayAssert.

public default Int2DArrayAssert

Returns:

the created assertion object.
assertThat
(final int[][]
the actual value.
actual
)

Creates a new instance of Int2DArrayAssert.

public default AbstractFloatAssert<?>

Returns:

the created assertion object.
assertThat
(final Float
the actual value.
actual
)

Creates a new instance of FloatAssert.

public default Float2DArrayAssert

Returns:

the created assertion object.
assertThat
(final float[][]
the actual value.
actual
)

Creates a new instance of Float2DArrayAssert.

public default AbstractIntegerAssert<?>

Returns:

the created assertion object.
assertThat
(final int
the actual value.
actual
)

Creates a new instance of IntegerAssert.

public default AbstractFloatArrayAssert<?>

Returns:

the created assertion object.
assertThat
(final float[]
the actual value.
actual
)

Creates a new instance of FloatArrayAssert.

public default AbstractIntegerAssert<?>

Returns:

the created assertion object.
assertThat
(final Integer
the actual value.
actual
)

Creates a new instance of IntegerAssert.

public default AbstractDoubleAssert<?>

Returns:

the created assertion object.
assertThat
(final double
the actual value.
actual
)

Creates a new instance of DoubleAssert.

public default AbstractDoubleAssert<?>

Returns:

the created assertion object.
assertThat
(final Double
the actual value.
actual
)

Creates a new instance of DoubleAssert.

public default <
the type of elements.
E
>
AbstractCollectionAssert<?, Collection<? extends E>, E, ObjectAssert<E>>

Returns:

the created assertion object.
assertThat
(final Collection<? extends E>
the actual value.
actual
)

Creates a new instance of CollectionAssert.

public default <
the type of elements.
T
>
ListAssert<T>

Returns:

the created assertion object.
assertThat
(final List<? extends T>
the actual value.
actual
)

Creates a new instance of ListAssert.

public default <
The actual elements type
ELEMENT
,
The actual type
ACTUAL extends List<? extends ELEMENT>
,
The actual elements AbstractAssert type
ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>
>
ClassBasedNavigableListAssert<?, ACTUAL, ELEMENT, ELEMENT_ASSERT>

Returns:

the created assertion object.
assertThat
(List<? extends ELEMENT>
the actual value.
actual
,
Class<ELEMENT_ASSERT>
the class used to create the elements assert instance.
assertClass
)

Deprecated This was added to help creating type-specific assertions for the elements of an List instance.
Creates a new instance of ClassBasedNavigableListAssert allowing to navigate to any List element in order to perform assertions on it.
public default <
The actual type
ACTUAL extends List<? extends ELEMENT>
,
The actual elements type
ELEMENT
,
The actual elements AbstractAssert type
ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>
>
FactoryBasedNavigableListAssert<?, ACTUAL, ELEMENT, ELEMENT_ASSERT>

Returns:

the created assertion object.
assertThat
(List<? extends ELEMENT>
the actual value.
actual
,
AssertFactory<ELEMENT, ELEMENT_ASSERT>
the factory used to create the elements assert instance.
assertFactory
)

Deprecated This was added to help creating type-specific assertions for the elements of an List instance.
Creates a new instance of FactoryBasedNavigableListAssert allowing to navigate to any List element in order to perform assertions on it.
public default <
the type of elements.
ELEMENT
>
ListAssert<ELEMENT>

Returns:

the created assertion object.
assertThat
(Stream<? extends ELEMENT>
the actual Stream value.
actual
)

Creates a new instance of ListAssert from the given Stream.

public default ListAssert<Double>

Returns:

the created assertion object.
assertThat
(DoubleStream
the actual DoubleStream value.
actual
)

Creates a new instance of ListAssert from the given DoubleStream.

public default ListAssert<Long>

Returns:

the created assertion object.
assertThat
(LongStream
the actual LongStream value.
actual
)

Creates a new instance of ListAssert from the given LongStream.

public default ListAssert<Integer>

Returns:

the created assertion object.
assertThat
(IntStream
the actual IntStream value.
actual
)

Creates a new instance of ListAssert from the given IntStream.

public default AbstractDoubleArrayAssert<?>

Returns:

the created assertion object.
assertThat
(final double[]
the actual value.
actual
)

Creates a new instance of DoubleArrayAssert.

public default Double2DArrayAssert

Returns:

the created assertion object.
assertThat
(final double[][]
the actual value.
actual
)

Creates a new instance of Double2DArrayAssert.

public default AbstractZonedDateTimeAssert<?>

Returns:

the created assertion object.
assertThat
(final ZonedDateTime
the actual value.
actual
)

Creates a new instance of ZonedDateTimeAssert.

public default <
the type of the value contained in the java.util.concurrent.CompletableFuture.
RESULT
>
CompletableFutureAssert<RESULT>

Returns:

the created assertion object.
assertThat
(final CompletableFuture<RESULT>
the actual value.
future
)

Create assertion for java.util.concurrent.CompletableFuture.

public default <
the type of the value contained in the java.util.concurrent.CompletionStage.
RESULT
>
CompletableFutureAssert<RESULT>

Returns:

the created assertion object.
assertThat
(final CompletionStage<RESULT>
the actual CompletionStage.
completionStage
)

Create assertion for java.util.concurrent.CompletionStage by converting it to a CompletableFuture and returning a CompletableFutureAssert.

public default <
the type of the value contained in the java.util.Optional.
VALUE
>
OptionalAssert<VALUE>

Returns:

the created assertion object.
assertThat
(final Optional<VALUE>
the actual value.
optional
)

Create assertion for java.util.Optional.

public default OptionalDoubleAssert

Returns:

the created assertion object.
assertThat
(final OptionalDouble
the actual value.
optional
)

Create assertion for java.util.OptionalDouble.

public default MatcherAssert

Returns:

the created assertion object.
assertThat
(final Matcher
the actual matcher.
matcher
)

Create assertion for java.util.regex.Matcher

public default OptionalIntAssert

Returns:

the created assertion object.
assertThat
(final OptionalInt
the actual value.
optional
)

Create assertion for java.util.OptionalInt.

public default OptionalLongAssert

Returns:

the created assertion object.
assertThat
(final OptionalLong
the actual value.
optional
)

Create assertion for java.util.OptionalLong.

public default TemporalAssert

Returns:

the created assertion object.
assertThat
(final Temporal
the actual value.
temporal
)

Creates a new instance of TemporalAssert.

public default AbstractLocalDateTimeAssert<?>

Returns:

the created assertion object.
assertThat
(final LocalDateTime
the actual value.
localDateTime
)

Creates a new instance of LocalDateTimeAssert.

public default AbstractLocalDateAssert<?>

Returns:

the created assertion object.
assertThat
(final LocalDate
the actual value.
localDate
)

Creates a new instance of LocalDateAssert.

public default AbstractYearMonthAssert<?>

Returns:

the created assertion object.
assertThat
(final YearMonth
the actual value.
yearMonth
)

Creates a new instance of YearMonthAssert.

public default AbstractLocalTimeAssert<?>

Returns:

the created assertion object.
assertThat
(final LocalTime
the actual value.
localTime
)

Creates a new instance of LocalTimeAssert.

public default AbstractInstantAssert<?>

Returns:

the created assertion object.
assertThat
(final Instant
the actual value.
actual
)

Creates a new instance of InstantAssert.

public default AbstractDurationAssert<?>

Returns:

the created assertion object.
assertThat
(final Duration
the actual value.
actual
)

Creates a new instance of DurationAssert.

public default AbstractPeriodAssert<?>

Returns:

the created assertion object.
assertThat
(final Period
the actual value.
actual
)

Creates a new instance of PeriodAssert.

public default AbstractOffsetTimeAssert<?>

Returns:

the created assertion object.
assertThat
(final OffsetTime
the actual value.
offsetTime
)

Creates a new instance of OffsetTimeAssert.

public default AbstractOffsetDateTimeAssert<?>

Returns:

the created assertion object.
assertThat
(final OffsetDateTime
the actual value.
offsetDateTime
)

Creates a new instance of OffsetTimeAssert.

public default <
the type of the value contained in the Predicate.
T
>
PredicateAssert<T>

Returns:

the created assertion object.
assertThat
(final Predicate<T>
the actual value.
actual
)

Create assertion for Predicate.

public default IntPredicateAssert

Returns:

the created assertion object.
assertThat
(final IntPredicate
the actual value.
actual
)

Create assertion for IntPredicate.

public default LongPredicateAssert

Returns:

the created assertion object.
assertThat
(final LongPredicate
the actual value.
actual
)

Create assertion for LongPredicate.

public default DoublePredicateAssert

Returns:

the created assertion object.
assertThat
(final DoublePredicate
the actual value.
actual
)

Create assertion for DoublePredicate.

public default AbstractUrlAssert<?>

Returns:

the created assertion object.
assertThat
(final URL
the actual value.
actual
)

Creates a new instance of UrlAssert.

public default AbstractUriAssert<?>

Returns:

the created assertion object.
assertThat
(final URI
the actual value.
actual
)

Creates a new instance of UriAssert.

public default <
the type of the elements.
ELEMENT
>
SpliteratorAssert<ELEMENT>

Returns:

the created assertion object.
assertThat
(final Spliterator<ELEMENT>
the actual value.
actual
)

Creates a new instance of SpliteratorAssert.

public default <
the AssertProvider wrapped type.
T
>
T

Returns:

the associated Assert of the given component
assertThat
(final AssertProvider<T>
the component that creates its own assert
component
)

Delegates the creation of the Assert to the AssertProvider#assertThat() of the given component.

public default AbstractThrowableAssert<?, ? extends Throwable>

Returns:

The captured exception or null if none was raised by the callable.
assertThatCode
(ThrowableAssert.ThrowingCallable
The ThrowingCallable or lambda with the code that should raise the throwable.
shouldRaiseOrNotThrowable
)

Allows to capture and then assert on a Throwable more easily when used with Java 8 lambdas.

public default <
the type of elements.
E
>
AbstractCollectionAssert<?, Collection<? extends E>, E, ObjectAssert<E>>

Returns:

the created assertion object.
assertThatCollection
(final Collection<? extends E>
the actual value.
actual
)

Creates a new instance of CollectionAssert.

public default <
the type of actual.
T
>
AbstractUniversalComparableAssert<?, T>

Returns:

the created assertion object.
assertThatComparable
(Comparable<T>
the actual value.
actual
)

Creates a new instance of UniversalComparableAssert with standard comparison semantics.

public default ThrowableTypeAssert<Exception>
public default <
the exception type.
T extends Throwable
>
ThrowableTypeAssert<T>

Returns:

the created ThrowableTypeAssert.
assertThatExceptionOfType
(final Class<? extends T>
the exception type class.
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.

public default ThrowableTypeAssert<IllegalArgumentException>
public default ThrowableTypeAssert<IllegalStateException>
public default ThrowableTypeAssert<IndexOutOfBoundsException>
public default ThrowableTypeAssert<IOException>
public default <
the type of elements.
ELEMENT
>
IterableAssert<ELEMENT>

Returns:

the created assertion object.
assertThatIterable
(Iterable<? extends ELEMENT>
the actual value.
actual
)

Creates a new instance of IterableAssert.

public default <
the type of elements.
ELEMENT
>
IteratorAssert<ELEMENT>

Returns:

the created assertion object.
assertThatIterator
(Iterator<? extends ELEMENT>
the actual value.
actual
)

Creates a new instance of IteratorAssert.

public default <
the type of elements.
ELEMENT
>
ListAssert<ELEMENT>

Returns:

the created assertion object.
assertThatList
(List<? extends ELEMENT>
the actual value.
actual
)

Creates a new instance of ListAssert.

public default NotThrownAssert

Returns:

the created NotThrownAssert.
assertThatNoException
()

Entry point to check that no exception of any type is thrown by a given throwingCallable.

public default ThrowableTypeAssert<NullPointerException>
public default <
the type of the actual value.
T
>
ObjectAssert<T>

Returns:

the created assertion object.
assertThatObject
(T
the actual value.
actual
)

Creates a new instance of ObjectAssert for any object.

public default AbstractPathAssert<?>

Returns:

the created assertion object
assertThatPath
(Path
the path to test
actual
)

Creates a new instance of PathAssert

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

public default <
the type of the value contained in the Predicate.
T
>
PredicateAssert<T>

Returns:

the created assertion object.
assertThatPredicate
(Predicate<T>
the actual value.
actual
)

Create assertion for Predicate.

public default ThrowableTypeAssert<ReflectiveOperationException>
public default ThrowableTypeAssert<RuntimeException>
public default <
the type of elements.
ELEMENT
>
ListAssert<ELEMENT>

Returns:

the created assertion object.
assertThatStream
(Stream<? extends ELEMENT>
the actual value.
actual
)

Creates a new instance of ListAssert from the given Stream.

public default AbstractThrowableAssert<?, ? extends Throwable>

Returns:

the created ThrowableAssert.
assertThatThrownBy
(final ThrowableAssert.ThrowingCallable
The ThrowingCallable or lambda with the code that should raise the throwable.
shouldRaiseThrowable
)

Allows to capture and then assert on a Throwable (easier done with lambdas).

public default AbstractThrowableAssert<?, ? extends Throwable>

Returns:

the created ThrowableAssert.
assertThatThrownBy
(ThrowableAssert.ThrowingCallable
The ThrowingCallable or lambda with the code that should raise the throwable.
shouldRaiseThrowable
,
String
the new description to set.
description
,
Object...
optional parameter if description is a format String.
args
)

Allows to capture and then assert on a Throwable like assertThatThrownBy(ThrowingCallable) but this method let you set the assertion description the same way you do with as(String, Object...).

public default <
the type of the actual value.
T
>
ObjectAssert<T>

Returns:

the created assertion object.
assertWith
(T
the actual value.
actual
,
Consumer<T>...
to assert on the actual object - must not be null.
requirements
)

Uses the given instance as the instance under test for all the assertions expressed as the passed Consumer.

public default Index

Returns:

the created Index.
atIndex
(final int
the value of the index.
index
)

Only delegate to Index#atIndex(int) so that Assertions offers a full feature entry point to all AssertJ features (but you can use Index if you prefer).

public default Offset<Double>

Returns:

the created Offset.
byLessThan
(Double
the value of the offset.
value
)

Alias for offset(Double) to use with isCloseTo assertions.

public default Offset<Float>

Returns:

the created Offset.
byLessThan
(Float
the value of the offset.
value
)

Alias for offset(Float) to use with isCloseTo assertions.

public default Offset<BigDecimal>

Returns:

the created Offset.
byLessThan
(BigDecimal
the value of the offset.
value
)

Assertions entry point for BigDecimal Offset to use with isCloseTo assertions.

public default Offset<BigInteger>

Returns:

the created Offset.
byLessThan
(BigInteger
the value of the offset.
value
)

Assertions entry point for BigInteger Offset to use with isCloseTo assertions.

public default Offset<Byte>

Returns:

the created Offset.
byLessThan
(Byte
the value of the offset.
value
)

Assertions entry point for Byte Offset to use with isCloseTo assertions.

public default Offset<Integer>

Returns:

the created Offset.
byLessThan
(Integer
the value of the offset.
value
)

Assertions entry point for Integer Offset to use with isCloseTo assertions.

public default Offset<Short>

Returns:

the created Offset.
byLessThan
(Short
the value of the offset.
value
)

Assertions entry point for Short Offset to use with isCloseTo assertions.

public default Offset<Long>

Returns:

the created Offset.
byLessThan
(Long
the value of the offset.
value
)

Assertions entry point for Long Offset to use with isCloseTo assertions.

public default TemporalUnitOffset

Returns:

the created Offset.
byLessThan
(long
the value of the offset.
value
,
TemporalUnit
the TemporalUnit of the offset.
unit
)

Assertions entry point for TemporalUnitOffset with strict less than condition to use with isCloseTo temporal assertions.

public default Exception

Returns:

The captured exception or null if none was raised by the callable.
catchException
(ThrowableAssert.ThrowingCallable
The lambda with the code that should raise the exception.
throwingCallable
)

Allows catching an instance of Exception.

public default IllegalArgumentException

Returns:

The captured exception or null if none was raised by the callable.
catchIllegalArgumentException
(ThrowableAssert.ThrowingCallable
The lambda with the code that should raise the exception.
throwingCallable
)

Allows catching an instance of IllegalArgumentException.

public default IllegalStateException

Returns:

The captured exception or null if none was raised by the callable.
catchIllegalStateException
(ThrowableAssert.ThrowingCallable
The lambda with the code that should raise the exception.
throwingCallable
)

Allows catching an instance of IllegalStateException.

public default IndexOutOfBoundsException

Returns:

The captured exception or null if none was raised by the callable.
catchIndexOutOfBoundsException
(ThrowableAssert.ThrowingCallable
The lambda with the code that should raise the exception.
throwingCallable
)

Allows catching an instance of IndexOutOfBoundsException.

public default IOException

Returns:

The captured exception or null if none was raised by the callable.
catchIOException
(ThrowableAssert.ThrowingCallable
The lambda with the code that should raise the exception.
throwingCallable
)

Allows catching an instance of IOException.

public default NullPointerException

Returns:

The captured exception or null if none was raised by the callable.
catchNullPointerException
(ThrowableAssert.ThrowingCallable
The lambda with the code that should raise the exception.
throwingCallable
)

Allows catching an instance of NullPointerException.

public default ReflectiveOperationException

Returns:

The captured exception or null if none was raised by the callable.
catchReflectiveOperationException
(ThrowableAssert.ThrowingCallable
The lambda with the code that should raise the exception.
throwingCallable
)

Allows catching an instance of ReflectiveOperationException.

public default RuntimeException

Returns:

The captured exception or null if none was raised by the callable.
catchRuntimeException
(ThrowableAssert.ThrowingCallable
The lambda with the code that should raise the exception.
throwingCallable
)

Allows catching an instance of RuntimeException.

public default Throwable

Returns:

The captured exception or null if none was raised by the callable.
catchThrowable
(final ThrowableAssert.ThrowingCallable
The lambda with the code that should raise the exception.
shouldRaiseThrowable
)

Allows to catch an Throwable more easily when used with Java 8 lambdas.

public default <
the Throwable type.
THROWABLE extends Throwable
>
THROWABLE

Returns:

The captured exception or null if none was raised by the callable.
catchThrowableOfType
(ThrowableAssert.ThrowingCallable
The lambda with the code that should raise the exception.
shouldRaiseThrowable
,
Class<THROWABLE>
The type of exception that the code is expected to raise.
type
)

Allows catching a Throwable of a specific type.
public default <
the Throwable type.
THROWABLE extends Throwable
>
THROWABLE

Returns:

The captured exception or null if none was raised by the callable.
catchThrowableOfType
(Class<THROWABLE>
The type of exception that the code is expected to raise.
type
,
ThrowableAssert.ThrowingCallable
The lambda with the code that should raise the exception.
shouldRaiseThrowable
)

Allows catching a Throwable of a specific type.

public default String

Returns:

the content of the file.
contentOf
(final File
the file.
file
,
final String
the name of the character set to use.
charsetName
)

Loads the text content of a file, so that it can be passed to assertThat(String).

public default String

Returns:

the content of the file.
contentOf
(final File
the file.
file
)

Loads the text content of a file with the default character set, so that it can be passed to assertThat(String).

public default String

Returns:

the content of the file.
contentOf
(final File
the file.
file
,
final Charset
the character set to use.
charset
)

Loads the text content of a file, so that it can be passed to assertThat(String).

public default String

Returns:

the content of the URL.
contentOf
(URL
the URL.
url
,
Charset
the character set to use.
charset
)

Loads the text content of a URL, so that it can be passed to assertThat(String).

public default String

Returns:

the content of the URL.
contentOf
(URL
the URL.
url
,
String
the name of the character set to use.
charsetName
)

Loads the text content of a URL, so that it can be passed to assertThat(String).

public default String

Returns:

the content of the file.
contentOf
(URL
the URL.
url
)

Loads the text content of a URL with the default character set, so that it can be passed to assertThat(String).

public default <
the type of object the given condition accept.
T
>
DoesNotHave<T>

Returns:

The DoesNotHave condition created.
doesNotHave
(final Condition<? super T>
the condition to inverse.
condition
)

Creates a new DoesNotHave.

public default <
the type of keys in the map.
K
,
the type of values in the map.
V
>
MapEntry<K, V>

Returns:

the created MapEntry.
entry
(final K
the key of the entry to create.
key
,
final V
the value of the entry to create.
value
)

Only delegate to MapEntry#entry(Object, Object) so that Assertions offers a full feature entry point to all AssertJ features (but you can use MapEntry if you prefer).

public default Properties<Object>

Returns:

the created Properties.
extractProperty
(final String
the name of the property to be read from the elements of a Iterable. It may be a nested property (e.g. "address.street.number").
propertyName
)

Only delegate to Properties#extractProperty(String) so that Assertions offers a full feature entry point to all AssertJ features (but you can use Properties if you prefer).

public default <
the type of value to extract.
T
>
Properties<T>

Returns:

the created Properties.
extractProperty
(final String
the name of the property to be read from the elements of a Iterable. It may be a nested property (e.g. "address.street.number").
propertyName
,
final Class<T>
the type of property to extract
propertyType
)

Only delegate to Properties#extractProperty(String) so that Assertions offers a full feature entry point to all AssertJ features (but you can use Properties if you prefer).

public default <
dummy return value type
T
>
T

Returns:

nothing, it's just to be used in doSomething(optional.orElseGet(() -> fail("boom")));.
fail
(final String
error message.
failureMessage
)

Throws an AssertionError with the given message.

public default <
dummy return value type
T
>
T

Returns:

nothing, it's just to be used in doSomething(optional.orElseGet(() -> fail()));.
fail
()

Throws an AssertionError with an empty message to be used in code like:

 doSomething(optional.orElseGet(() -> fail()));
public default <
dummy return value type
T
>
T

Returns:

nothing, it's just to be used in doSomething(optional.orElseGet(() -> fail("b%s", "oom")));.
fail
(String
error message.
failureMessage
,
Object...
Arguments referenced by the format specifiers in the format string.
args
)

Throws an AssertionError with the given message built as String#format(String, Object...).

public default <
dummy return value type
T
>
T

Returns:

nothing, it's just to be used in doSomething(optional.orElseGet(() -> fail("boom", cause)));.
fail
(final String
the description of the failed assertion. It can be null.
failureMessage
,
final Throwable
cause of the error.
realCause
)

Throws an AssertionError with the given message and with the Throwable that caused the failure.

public default <
dummy return value type
T
>
T

Returns:

nothing, it's just to be used in doSomething(optional.orElseGet(() -> fail(cause)));.
fail
(final Throwable
cause of the error.
realCause
)

Throws an AssertionError with the Throwable that caused the failure.

public default <
dummy return value type
T
>
T

Returns:

nothing, it's just to be used in doSomething(optional.orElseGet(() -> failBecauseExceptionWasNotThrown(IOException.class)));.
failBecauseExceptionWasNotThrown
(final Class<? extends Throwable>
the Throwable class that was expected to be thrown.
throwableClass
)

Throws an AssertionError with a message explaining that a Throwable of given class was expected to be thrown but had not been.

public default <
the array elements type.
E
>
Filters<E>

Returns:

the created Filters.
filter
(final E[]
the array to filter.
array
)

Only delegate to Filters#filter(Object[]) so that Assertions offers a full feature entry point to all AssertJ features (but you can use Filters if you prefer).

public default <
the Iterable elements type.
E
>
Filters<E>

Returns:

the created Filters.
filter
(final Iterable<E>
the Iterable to filter.
iterableToFilter
)

Only delegate to Filters#filter(Object[]) so that Assertions offers a full feature entry point to all AssertJ features (but you can use Filters if you prefer).

public default <
Type of test subject
F
,
Type of the property under the assertion
T
>
Function<F, T>

Returns:

same instance of extractor
from
(Function<F, T>
A function to extract test subject's property
extractor
)

A syntax sugar to write fluent assertion using ObjectAssert#returns(Object, Function) and ObjectAssert#doesNotReturn(Object, Function).

public default InFilter

Returns:

the created "in" filter
in
(Object...
values to match (one match is sufficient)
values
)

Create a FilterOperator to use in filteredOn(String, FilterOperation) to express a filter keeping all Iterable elements whose property/field value matches one of the given values.

public default List<String>

Returns:

the content of the file.
linesOf
(final File
the file.
file
)

Loads the text content of a file into a list of strings with the default charset, each string corresponding to a line.

public default List<String>

Returns:

the content of the file.
linesOf
(final File
the file.
file
,
final String
the name of the character set to use.
charsetName
)

Loads the text content of a file into a list of strings, each string corresponding to a line.

public default List<String>

Returns:

the content of the file.
linesOf
(final File
the file.
file
,
final Charset
the character set to use.
charset
)

Loads the text content of a file into a list of strings, each string corresponding to a line.

public default List<String>

Returns:

the content of the file at the given path.
linesOf
(final Path
the path.
path
)

Loads the text content of a file at a given path into a list of strings with the default charset, each string corresponding to a line.

public default List<String>

Returns:

the content of the file at the given path.
linesOf
(final Path
the file.
path
,
final String
the name of the character set to use.
charsetName
)

Loads the text content of a file at a given path into a list of strings, each string corresponding to a line.

public default List<String>

Returns:

the content of the file at the given path.
linesOf
(final Path
the path.
path
,
final Charset
the character set to use.
charset
)

Loads the text content of a file at a given path into a list of strings, each string corresponding to a line.

public default List<String>

Returns:

the content of the file.
linesOf
(URL
the URL.
url
)

Loads the text content of a URL into a list of strings with the default charset, each string corresponding to a line.

public default List<String>

Returns:

the content of the file.
linesOf
(URL
the URL.
url
,
Charset
the character set to use.
charset
)

Loads the text content of a URL into a list of strings, each string corresponding to a line.

public default List<String>

Returns:

the content of the file.
linesOf
(URL
the URL.
url
,
String
the name of the character set to use.
charsetName
)

Loads the text content of a URL into a list of strings, each string corresponding to a line.

public default <
the type of object the given condition accept.
T
>
Not<T>

Returns:

The Not condition created.
not
(final Condition<? super T>
the condition to inverse.
condition
)

Creates a new Not.

public default NotFilter

Returns:

the created "not" filter
not
(Object
the value not to match
valueNotToMatch
)

Create a FilterOperator to use in filteredOn(String, FilterOperation) to express a filter keeping all Iterable elements whose property/field value matches does not match the given value.

public default NotInFilter

Returns:

the created "not in" filter
notIn
(Object...
values not to match (none of the values must match)
valuesNotToMatch
)

Create a FilterOperator to use in filteredOn(String, FilterOperation) to express a filter keeping all Iterable elements whose property/field value matches does not match any of the given values.

public default Offset<Float>

Returns:

the created Offset.
offset
(final Float
the allowed offset
value
)

Assertions entry point for float Offset.

public default Offset<Double>

Returns:

the created Offset.
offset
(final Double
the allowed offset
value
)

Assertions entry point for double Offset.

public default void
registerCustomDateFormat(final DateFormat
the new Date format used for String based Date assertions.
userCustomDateFormat
)

Add the given date format to the ones used to parse date String in String based Date assertions like org.assertj.core.api.AbstractDateAssert#isEqualTo(String).

public default void
registerCustomDateFormat(final String
the new Date format pattern used for String based Date assertions.
userCustomDateFormatPattern
)

Add the given date format to the ones used to parse date String in String based Date assertions like org.assertj.core.api.AbstractDateAssert#isEqualTo(String).

public default <
the type of format.
T
>
void
registerFormatterForType(Class<T>
the class of the type to format
type
,
Function<T, String>
the formatter Function
formatter
)

Assertions error messages uses a Representation to format the different types involved, using this method you can control the formatting of a given type by providing a specific formatter.

public default void
setAllowComparingPrivateFields(boolean
allow private fields comparison. Default true.
allowComparingPrivateFields
)

Globally sets whether the use of private fields is allowed for comparison.

public default void
setAllowExtractingPrivateFields(final boolean
allow private fields extraction. Default true.
allowExtractingPrivateFields
)

Globally sets whether IterableAssert#extracting(String) and ObjectArrayAssert#extracting(String) should be allowed to extract private fields, if not and they try it fails with exception.

public static void
setDescriptionConsumer(Consumer<Description>
the Description consumer
descriptionConsumer
)

All assertions description will be consumed by the given Consumer<Description> allowing for example to record them in a file.

public default void
setExtractBareNamePropertyMethods(boolean
whether bare-named property methods are found
barenamePropertyMethods
)

Globally sets whether the extractor considers bare-named property methods like String name().

public default void
setLenientDateParsing(boolean
whether lenient parsing mode should be enabled or not
value
)

Instead of using default strict date/time parsing, it is possible to use lenient parsing mode for default date formats parser to interpret inputs that do not precisely match supported date formats (lenient parsing).

public default void
setMaxElementsForPrinting(int
the maximum elements that would be printed for iterables, arrays and maps.
maxElementsForPrinting
)

Sets the maximum number of elements to display in error messages for iterables, arrays and map .

public default void
setMaxLengthForSingleLineDescription(int
the maximum length for an iterable/array to be displayed on one line
maxLengthForSingleLineDescription
)

In error messages, sets the threshold when iterable/array formatting will on one line (if their String description is less than this parameter) or it will be formatted with one element per line.

public default void
setMaxStackTraceElementsDisplayed(int
the maximum number of lines for a stacktrace to be displayed on one throw.
maxStackTraceElementsDisplayed
)

Sets how many stacktrace elements are included in Throwable representation (by default this set to 3).

public static void
setPrintAssertionsDescription(boolean
whether to print assertions description.
printAssertionsDescription
)

Enable/disable printing assertions description to the console (disabled by default).

public default void
setRemoveAssertJRelatedElementsFromStackTrace(final boolean
flag.
removeAssertJRelatedElementsFromStackTrace
)

Sets whether we remove elements related to AssertJ from assertion error stack trace.

public default <
dummy return value type
T
>
T

Returns:

nothing, it's just to be used in doSomething(optional.orElseGet(() -> shouldHaveThrown(IOException.class)));.
shouldHaveThrown
(Class<? extends Throwable>
the Throwable class that was expected to be thrown.
throwableClass
)

Throws an AssertionError with a message explaining that a Throwable of given class was expected to be thrown but had not been.

public default Tuple

Returns:

the built Tuple
tuple
(final Object...
the values stored in the Tuple
values
)

Utility method to build nicely a Tuple when working with IterableAssert#extracting(String...) or ObjectArrayAssert#extracting(String...)

public default void
useDefaultDateFormatsOnly()

Remove all registered custom date formats => use only the defaults date formats to parse string as date.

public default void
useDefaultRepresentation()

Fallback to use StandardRepresentation to revert the effect of calling useRepresentation(Representation).

public default void
useRepresentation(Representation
the Representation to use
customRepresentation
)

Register a Representation that will be used in all following assertions.

public default Offset<Double>

Returns:

the created Offset.
within
(final Double
the value of the offset.
value
)

Alias for offset(Double) to use with isCloseTo assertions.

public default Offset<BigDecimal>

Returns:

the created Offset.
within
(final BigDecimal
the value of the offset.
value
)

Assertions entry point for BigDecimal Offset to use with isCloseTo assertions.

public default Offset<Float>

Returns:

the created Offset.
within
(final Float
the value of the offset.
value
)

Alias for offset(Float) to use with isCloseTo assertions.

public default Offset<BigInteger>

Returns:

the created Offset.
within
(BigInteger
the value of the offset.
value
)

Assertions entry point for BigInteger Offset to use with isCloseTo assertions.

public default Offset<Byte>

Returns:

the created Offset.
within
(Byte
the value of the offset.
value
)

Assertions entry point for Byte Offset to use with isCloseTo assertions.

public default Offset<Integer>

Returns:

the created Offset.
within
(Integer
the value of the offset.
value
)

Assertions entry point for Integer Offset to use with isCloseTo assertions.

public default Offset<Short>

Returns:

the created Offset.
within
(Short
the value of the offset.
value
)

Assertions entry point for Short Offset to use with isCloseTo assertions.

public default Offset<Long>

Returns:

the created Offset.
within
(Long
the value of the offset.
value
)

Assertions entry point for Long Offset to use with isCloseTo assertions.

public default TemporalUnitOffset

Returns:

the created Offset.
within
(long
the allowed offset
value
,
TemporalUnit
the TemporalUnit of the offset
unit
)

Assertions entry point for TemporalUnitOffset with less than or equal condition to use with isCloseTo temporal assertions.

public default Percentage

Returns:

the created Percentage.
withinPercentage
(Double
the required precision percentage
value
)

Assertions entry point for Double org.assertj.core.data.Percentage to use with isCloseTo assertions for percentages.

public default Percentage

Returns:

the created Percentage.
withinPercentage
(Integer
the required precision percentage
value
)

Assertions entry point for Integer org.assertj.core.data.Percentage to use with isCloseTo assertions for percentages.

public default Percentage

Returns:

the created Percentage.
withinPercentage
(Long
the required precision percentage
value
)

Assertions entry point for Long org.assertj.core.data.Percentage to use with isCloseTo assertions for percentages.

public default Duration

Returns:

the given value.
withMarginOf
(Duration
the allowed difference Duration.
allowedDifference
)

Syntactic sugar method to use with AbstractDurationAssert#isCloseTo(Duration, Duration) assertion.

public default Offset<Double>

Returns:

the created Offset.
withPrecision
(Double
the allowed offset
value
)

Assertions entry point for double Offset.

public default Offset<Float>

Returns:

the created Offset.
withPrecision
(Float
the allowed offset
value
)

Assertions entry point for float Offset.

Inherited from org.assertj.core.api.InstanceOfAssertFactories:
arrayarray2DatomicIntegerFieldUpdateratomicLongFieldUpdateratomicMarkableReferenceatomicReferenceatomicReferenceArrayatomicReferenceFieldUpdateratomicStampedReferencecollectioncomparablecompletableFuturecompletionStagefutureiterableiteratorlistmapoptionalpredicatesetspliteratorstreamthrowabletype