Package org.assertj.core.api
Interface WithAssertions
public interface WithAssertions
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/
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T> Condition
<T> Delegate call toAssertions.allOf(Iterable)
default <T> Condition
<T> Delegate call toAssertions.allOf(Condition[])
default <T> Condition
<T> Delegate call toAssertions.anyOf(Iterable)
default <T> Condition
<T> Delegate call toAssertions.anyOf(Condition[])
default AbstractBooleanAssert
<?> assertThat
(boolean actual) Delegate call toAssertions.assertThat(boolean)
default AbstractBooleanArrayAssert
<?> assertThat
(boolean[] actual) Delegate call toAssertions.assertThat(boolean)
default AbstractByteAssert
<?> assertThat
(byte actual) Delegate call toAssertions.assertThat(byte)
default AbstractByteArrayAssert
<?> assertThat
(byte[] actual) Delegate call toAssertions.assertThat(byte[])
default AbstractCharacterAssert
<?> assertThat
(char actual) Delegate call toAssertions.assertThat(char)
default AbstractCharArrayAssert
<?> assertThat
(char[] actual) Delegate call toAssertions.assertThat(char[])
default AbstractDoubleAssert
<?> assertThat
(double actual) Delegate call toAssertions.assertThat(double)
default AbstractDoubleArrayAssert
<?> assertThat
(double[] actual) Delegate call toAssertions.assertThat(double[])
default AbstractFloatAssert
<?> assertThat
(float actual) Delegate call toAssertions.assertThat(float)
default AbstractFloatArrayAssert
<?> assertThat
(float[] actual) Delegate call toAssertions.assertThat(float[])
default AbstractIntegerAssert
<?> assertThat
(int actual) Delegate call toAssertions.assertThat(int)
default AbstractIntArrayAssert
<?> assertThat
(int[] actual) Delegate call toAssertions.assertThat(int[])
default AbstractLongAssert
<?> assertThat
(long actual) Delegate call toAssertions.assertThat(long)
default AbstractLongArrayAssert
<?> assertThat
(long[] actual) Delegate call toAssertions.assertThat(long[])
default AbstractShortAssert
<?> assertThat
(short actual) Delegate call toAssertions.assertThat(short)
default AbstractShortArrayAssert
<?> assertThat
(short[] actual) Delegate call toAssertions.assertThat(short[])
default <ACTUAL extends Iterable<? extends ELEMENT>,
ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>>
ClassBasedNavigableIterableAssert<?, ACTUAL, ELEMENT, ELEMENT_ASSERT> assertThat
(ACTUAL actual, Class<ELEMENT_ASSERT> assertClass) Delegate call toAssertions.assertThat(Iterable, Class)
default AbstractFileAssert
<?> assertThat
(File actual) Delegate call toAssertions.assertThat(File)
default AbstractInputStreamAssert
<?, ? extends InputStream> assertThat
(InputStream actual) Delegate call toAssertions.assertThat(InputStream)
default AbstractBooleanAssert
<?> assertThat
(Boolean actual) Delegate call toAssertions.assertThat(Boolean)
default AbstractByteAssert
<?> assertThat
(Byte actual) Delegate call toAssertions.assertThat(Byte)
default AbstractCharacterAssert
<?> assertThat
(Character actual) Delegate call toAssertions.assertThat(Character)
default AbstractCharSequenceAssert
<?, ? extends CharSequence> assertThat
(CharSequence actual) Delegate call toAssertions.assertThat(CharSequence)
default AbstractClassAssert
<?> assertThat
(Class<?> actual) Delegate call toAssertions.assertThat(Class)
default AbstractDoubleAssert
<?> assertThat
(Double actual) Delegate call toAssertions.assertThat(Double)
default AbstractFloatAssert
<?> assertThat
(Float actual) Delegate call toAssertions.assertThat(Float)
default AbstractIntegerAssert
<?> assertThat
(Integer actual) Delegate call toAssertions.assertThat(Integer)
default <ACTUAL extends Iterable<? extends ELEMENT>,
ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>>
FactoryBasedNavigableIterableAssert<?, ACTUAL, ELEMENT, ELEMENT_ASSERT> assertThat
(Iterable<? extends ELEMENT> actual, AssertFactory<ELEMENT, ELEMENT_ASSERT> assertFactory) Delegate call toAssertions.assertThat(Iterable, AssertFactory)
default <T> IterableAssert
<T> assertThat
(Iterable<? extends T> actual) Delegate call toAssertions.assertThat(Iterable)
default AbstractLongAssert
<?> assertThat
(Long actual) Delegate call toAssertions.assertThat(Long)
default AbstractShortAssert
<?> assertThat
(Short actual) Delegate call toAssertions.assertThat(Short)
default AbstractCharSequenceAssert
<?, String> assertThat
(String actual) Delegate call toAssertions.assertThat(String)
default AbstractThrowableAssert
<?, ? extends Throwable> assertThat
(Throwable actual) Delegate call toAssertions.assertThat(Throwable)
default AbstractBigDecimalAssert
<?> assertThat
(BigDecimal actual) Delegate call toAssertions.assertThat(BigDecimal)
default AbstractBigIntegerAssert
<?> assertThat
(BigInteger actual) Creates a new instance of
.BigIntegerAssert
default AbstractUriAssert
<?> assertThat
(URI actual) Delegate call toAssertions.assertThat(URI)
default AbstractUrlAssert
<?> assertThat
(URL actual) Delegate call toAssertions.assertThat(URL)
default AbstractPathAssert
<?> assertThat
(Path actual) Delegate call toAssertions.assertThat(Path)
default AbstractInstantAssert
<?> assertThat
(Instant actual) Delegate call toAssertions.assertThat(java.time.Instant)
default AbstractLocalDateAssert
<?> assertThat
(LocalDate localDate) Delegate call toAssertions.assertThat(LocalDate)
default AbstractLocalDateTimeAssert
<?> assertThat
(LocalDateTime localDateTime) Delegate call toAssertions.assertThat(LocalDateTime)
default AbstractLocalTimeAssert
<?> assertThat
(LocalTime localTime) Delegate call toAssertions.assertThat(LocalTime)
default AbstractOffsetDateTimeAssert
<?> assertThat
(OffsetDateTime offsetDateTime) Delegate call toAssertions.assertThat(OffsetDateTime)
default AbstractOffsetTimeAssert
<?> assertThat
(OffsetTime offsetTime) Delegate call toAssertions.assertThat(OffsetTime)
default AbstractZonedDateTimeAssert
<?> assertThat
(ZonedDateTime actual) Delegate call toAssertions.assertThat(ZonedDateTime)
default AtomicBooleanAssert
assertThat
(AtomicBoolean actual) Create assertion forAtomicBoolean
.default AtomicIntegerAssert
assertThat
(AtomicInteger actual) Create assertion forAtomicInteger
.default AtomicIntegerArrayAssert
assertThat
(AtomicIntegerArray actual) Create int[] assertion forAtomicIntegerArray
.default <OBJECT> AtomicIntegerFieldUpdaterAssert
<OBJECT> assertThat
(AtomicIntegerFieldUpdater<OBJECT> actual) Create assertion forAtomicIntegerFieldUpdater
.default AtomicLongAssert
assertThat
(AtomicLong actual) Create assertion forAtomicLong
.default AtomicLongArrayAssert
assertThat
(AtomicLongArray actual) Create assertion forAtomicLongArray
.default <OBJECT> AtomicLongFieldUpdaterAssert
<OBJECT> assertThat
(AtomicLongFieldUpdater<OBJECT> actual) Create assertion forAtomicLongFieldUpdater
.default <VALUE> AtomicMarkableReferenceAssert
<VALUE> assertThat
(AtomicMarkableReference<VALUE> actual) Create assertion forAtomicMarkableReference
.default <VALUE> AtomicReferenceAssert
<VALUE> assertThat
(AtomicReference<VALUE> actual) Create assertion forAtomicReference
.default <ELEMENT> AtomicReferenceArrayAssert
<ELEMENT> assertThat
(AtomicReferenceArray<ELEMENT> actual) Create assertion forAtomicReferenceArray
.default <FIELD,
OBJECT>
AtomicReferenceFieldUpdaterAssert<FIELD, OBJECT> assertThat
(AtomicReferenceFieldUpdater<OBJECT, FIELD> actual) Create assertion forAtomicReferenceFieldUpdater
.default <VALUE> AtomicStampedReferenceAssert
<VALUE> assertThat
(AtomicStampedReference<VALUE> actual) Create assertion forAtomicStampedReference
.default <RESULT> CompletableFutureAssert
<RESULT> assertThat
(CompletableFuture<RESULT> future) Delegate call toAssertions.assertThat(CompletableFuture)
default <RESULT> AbstractFutureAssert
<?, ? extends Future<? extends RESULT>, RESULT> assertThat
(Future<RESULT> actual) Delegate call toAssertions.assertThat(Future)
default AbstractDateAssert
<?> assertThat
(Date actual) Delegate call toAssertions.assertThat(Date)
default DoublePredicateAssert
assertThat
(DoublePredicate actual) Delegate call toAssertions.assertThat(DoublePredicate)
default IntPredicateAssert
assertThat
(IntPredicate actual) Delegate call toAssertions.assertThat(IntPredicate)
default LongPredicateAssert
assertThat
(LongPredicate actual) Delegate call toAssertions.assertThat(LongPredicate)
default <T> PredicateAssert
<T> assertThat
(Predicate<T> actual) Delegate call toAssertions.assertThat(Predicate)
default <T> IterableAssert
<T> assertThat
(Iterator<? extends T> actual) Delegate call toAssertions.assertThat(Iterator)
default <ELEMENT,
ACTUAL extends List<? extends ELEMENT>, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>>
ClassBasedNavigableListAssert<?, ACTUAL, ELEMENT, ELEMENT_ASSERT> assertThat
(List<? extends ELEMENT> actual, Class<ELEMENT_ASSERT> assertClass) Delegate call toAssertions.assertThat(List, Class)
)}default <ACTUAL extends List<? extends ELEMENT>,
ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>>
FactoryBasedNavigableListAssert<?, ACTUAL, ELEMENT, ELEMENT_ASSERT> assertThat
(List<? extends ELEMENT> actual, AssertFactory<ELEMENT, ELEMENT_ASSERT> assertFactory) Delegate call toAssertions.assertThat(List, AssertFactory)
)}default <T> ListAssert
<? extends T> assertThat
(List<? extends T> actual) Delegate call toAssertions.assertThat(List)
default <K,
V> MapAssert <K, V> assertThat
(Map<K, V> actual) Delegate call toAssertions.assertThat(Map)
default <VALUE> OptionalAssert
<VALUE> assertThat
(Optional<VALUE> optional) Delegate call toAssertions.assertThat(Optional)
default OptionalDoubleAssert
assertThat
(OptionalDouble optional) Delegate call toAssertions.assertThat(java.util.OptionalDouble)
default OptionalIntAssert
assertThat
(OptionalInt optional) Delegate call toAssertions.assertThat(java.util.OptionalInt)
default OptionalLongAssert
assertThat
(OptionalLong optional) Delegate call toAssertions.assertThat(java.util.OptionalLong)
default <ELEMENT,
STREAM extends BaseStream<ELEMENT, STREAM>>
AbstractListAssert<?, ? extends List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> assertThat
(BaseStream<? extends ELEMENT, STREAM> actual) Delegate call toAssertions.assertThat(List)
default <T> T
assertThat
(AssertProvider<T> component) Delegate call toAssertions.assertThat(AssertProvider)
default <T extends AssertDelegateTarget>
TassertThat
(T assertion) Delegate call toAssertions.assertThat(AssertDelegateTarget)
default <T> AbstractObjectArrayAssert
<?, T> assertThat
(T[] actual) Delegate call toAssertions.assertThat(Object[])
default AbstractThrowableAssert
<?, ? extends Throwable> assertThatCode
(ThrowableAssert.ThrowingCallable shouldRaiseOrNotThrowable) Allows to capture and then assert on aThrowable
more easily when used with Java 8 lambdas.default <T extends Throwable>
ThrowableTypeAssert<T> assertThatExceptionOfType
(Class<? extends T> exceptionType) Entry point to check that an exception of type T is thrown by a giventhrowingCallable
which allows to chain assertions on the thrown exception.default AbstractThrowableAssert
<?, ? extends Throwable> assertThatThrownBy
(ThrowableAssert.ThrowingCallable shouldRaiseThrowable) Delegate call toAssertions.assertThatThrownBy(ThrowableAssert.ThrowingCallable)
default Index
atIndex
(int actual) Delegate call toAssertions.atIndex(int)
default Throwable
catchThrowable
(ThrowableAssert.ThrowingCallable shouldRaiseThrowable) Delegate call toAssertions.catchThrowable(ThrowableAssert.ThrowingCallable)
default String
Delegate call toAssertions.contentOf(File)
default String
Delegate call toAssertions.contentOf(File,String)
default String
Delegate call toAssertions.contentOf(File,Charset)
default <T> DoesNotHave
<T> doesNotHave
(Condition<? super T> condition) Delegate call toAssertions.doesNotHave(Condition)
default <K,
V> MapEntry <K, V> entry
(K key, V value) Delegate call toAssertions.entry(Object, Object)
default Properties
<Object> extractProperty
(String propertyName) Delegate call toAssertions.extractProperty(String)
default <T> Properties
<T> extractProperty
(String propertyName, Class<T> propertyType) Delegate call toAssertions.extractProperty(String,Class)
default void
Delegate call toAssertions.fail(String)
default void
Delegate call toAssertions.fail(String,Throwable)
default void
failBecauseExceptionWasNotThrown
(Class<? extends Throwable> exceptionClass) default <E> Filters
<E> filter
(E[] array) Delegate call toAssertions.filter(Object[])
default <E> Filters
<E> Delegate call toAssertions.filter(Iterable)
Delegate call toAssertions.linesOf(File)
Delegate call toAssertions.linesOf(File,String)
Delegate call toAssertions.linesOf(File,Charset)
default <T> Not
<T> Delegate call toAssertions.not(Condition)
Delegate call toAssertions.offset(Double)
Delegate call toAssertions.offset(Float)
default void
registerCustomDateFormat
(String actual) Delegate call toAssertions.registerCustomDateFormat(String)
default void
registerCustomDateFormat
(DateFormat actual) Delegate call toAssertions.registerCustomDateFormat(DateFormat)
default void
setAllowExtractingPrivateFields
(boolean actual) Delegate call toAssertions.setAllowExtractingPrivateFields(boolean)
default void
setRemoveAssertJRelatedElementsFromStackTrace
(boolean actual) Delegate call toAssertions.setRemoveAssertJRelatedElementsFromStackTrace(boolean)
default Tuple
Delegate call toAssertions.tuple(Object[])
default void
Delegate call toAssertions.useDefaultDateFormatsOnly()
Delegate call toAssertions.within(Double)
Delegate call toAssertions.within(Float)
default Offset
<BigDecimal> within
(BigDecimal actual) Delegate call toAssertions.within(BigDecimal)
-
Method Details
-
offset
Delegate call toAssertions.offset(Float)
-
offset
Delegate call toAssertions.offset(Double)
-
entry
Delegate call toAssertions.entry(Object, Object)
-
fail
Delegate call toAssertions.fail(String)
-
fail
Delegate call toAssertions.fail(String,Throwable)
-
not
Delegate call toAssertions.not(Condition)
-
allOf
Delegate call toAssertions.allOf(Iterable)
-
allOf
Delegate call toAssertions.allOf(Condition[])
-
assertThat
Delegate call toAssertions.assertThat(Object[])
-
assertThat
Delegate call toAssertions.assertThat(AssertDelegateTarget)
-
assertThat
Delegate call toAssertions.assertThat(Map)
-
assertThat
Delegate call toAssertions.assertThat(short)
-
assertThat
Delegate call toAssertions.assertThat(long)
-
assertThat
Delegate call toAssertions.assertThat(Long)
-
assertThat
Delegate call toAssertions.assertThat(long[])
-
assertThat
Delegate call toAssertions.assertThat(Object)
-
assertThat
Delegate call toAssertions.assertThat(String)
-
assertThat
Delegate call toAssertions.assertThat(Date)
-
assertThat
Delegate call toAssertions.assertThat(Throwable)
-
assertThat
Delegate call toAssertions.assertThat(BigDecimal)
-
assertThat
Creates a new instance of
.BigIntegerAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 2.7.0 / 3.7.0
-
assertThat
Create assertion forAtomicBoolean
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
Create assertion forAtomicInteger
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
Create int[] assertion forAtomicIntegerArray
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <OBJECT> AtomicIntegerFieldUpdaterAssert<OBJECT> assertThat(AtomicIntegerFieldUpdater<OBJECT> actual) Create assertion forAtomicIntegerFieldUpdater
.- Type Parameters:
OBJECT
- the type of the object holding the updatable field.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
Create assertion forAtomicLong
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
Create assertion forAtomicLongArray
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <OBJECT> AtomicLongFieldUpdaterAssert<OBJECT> assertThat(AtomicLongFieldUpdater<OBJECT> actual) Create assertion forAtomicLongFieldUpdater
.- Type Parameters:
OBJECT
- the type of the object holding the updatable field.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
Create assertion forAtomicReference
.- Type Parameters:
VALUE
- the type of the value contained in theAtomicReference
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <ELEMENT> AtomicReferenceArrayAssert<ELEMENT> assertThat(AtomicReferenceArray<ELEMENT> actual) Create assertion forAtomicReferenceArray
.- Type Parameters:
ELEMENT
- the type of the value contained in theAtomicReferenceArray
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <FIELD,OBJECT> AtomicReferenceFieldUpdaterAssert<FIELD,OBJECT> assertThat(AtomicReferenceFieldUpdater<OBJECT, FIELD> actual) Create assertion forAtomicReferenceFieldUpdater
.- Type Parameters:
FIELD
- the type of the field which gets updated by theAtomicReferenceFieldUpdater
.OBJECT
- the type of the object holding the updatable field.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <VALUE> AtomicMarkableReferenceAssert<VALUE> assertThat(AtomicMarkableReference<VALUE> actual) Create assertion forAtomicMarkableReference
.- Type Parameters:
VALUE
- the type of the value contained in theAtomicMarkableReference
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
default <VALUE> AtomicStampedReferenceAssert<VALUE> assertThat(AtomicStampedReference<VALUE> actual) Create assertion forAtomicStampedReference
.- Type Parameters:
VALUE
- the type of the value contained in theAtomicStampedReference
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
assertThat
Delegate call toAssertions.assertThat(CharSequence)
-
assertThat
Delegate call toAssertions.assertThat(short[])
-
assertThat
Delegate call toAssertions.assertThat(Short)
-
assertThat
Delegate call toAssertions.assertThat(Class)
-
assertThat
Delegate call toAssertions.assertThat(Character)
-
assertThat
Delegate call toAssertions.assertThat(char[])
-
assertThat
Delegate call toAssertions.assertThat(char)
-
assertThat
Delegate call toAssertions.assertThat(Comparable)
-
assertThat
Delegate call toAssertions.assertThat(Iterable)
-
assertThat
default <ACTUAL extends Iterable<? extends ELEMENT>,ELEMENT, FactoryBasedNavigableIterableAssert<?,ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> ACTUAL, assertThatELEMENT, ELEMENT_ASSERT> (Iterable<? extends ELEMENT> actual, AssertFactory<ELEMENT, ELEMENT_ASSERT> assertFactory) Delegate call toAssertions.assertThat(Iterable, AssertFactory)
-
assertThat
Delegate call toAssertions.assertThat(Iterator)
-
assertThat
default <ACTUAL extends Iterable<? extends ELEMENT>,ELEMENT, ClassBasedNavigableIterableAssert<?,ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> ACTUAL, assertThatELEMENT, ELEMENT_ASSERT> (ACTUAL actual, Class<ELEMENT_ASSERT> assertClass) Delegate call toAssertions.assertThat(Iterable, Class)
-
assertThat
Delegate call toAssertions.assertThat(Boolean)
-
assertThat
Delegate call toAssertions.assertThat(boolean)
-
assertThat
Delegate call toAssertions.assertThat(byte)
-
assertThat
Delegate call toAssertions.assertThat(Byte)
-
assertThat
Delegate call toAssertions.assertThat(byte[])
-
assertThat
Delegate call toAssertions.assertThat(boolean)
-
assertThat
Delegate call toAssertions.assertThat(float)
-
assertThat
Delegate call toAssertions.assertThat(InputStream)
-
assertThat
Delegate call toAssertions.assertThat(File)
-
assertThat
default <RESULT> AbstractFutureAssert<?,? extends Future<? extends RESULT>, assertThatRESULT> (Future<RESULT> actual) Delegate call toAssertions.assertThat(Future)
- Since:
- 3.7.0
-
assertThat
Delegate call toAssertions.assertThat(Path)
-
assertThat
Delegate call toAssertions.assertThat(int[])
-
assertThat
Delegate call toAssertions.assertThat(Float)
-
assertThat
Delegate call toAssertions.assertThat(int)
-
assertThat
Delegate call toAssertions.assertThat(float[])
-
assertThat
Delegate call toAssertions.assertThat(Integer)
-
assertThat
Delegate call toAssertions.assertThat(double)
-
assertThat
Delegate call toAssertions.assertThat(Double)
-
assertThat
Delegate call toAssertions.assertThat(List)
-
assertThat
default <ELEMENT,ACTUAL extends List<? extends ELEMENT>, ClassBasedNavigableListAssert<?,ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> ACTUAL, assertThatELEMENT, ELEMENT_ASSERT> (List<? extends ELEMENT> actual, Class<ELEMENT_ASSERT> assertClass) Delegate call toAssertions.assertThat(List, Class)
)} -
assertThat
default <ACTUAL extends List<? extends ELEMENT>,ELEMENT, FactoryBasedNavigableListAssert<?,ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>> ACTUAL, assertThatELEMENT, ELEMENT_ASSERT> (List<? extends ELEMENT> actual, AssertFactory<ELEMENT, ELEMENT_ASSERT> assertFactory) Delegate call toAssertions.assertThat(List, AssertFactory)
)} -
assertThat
default <ELEMENT,STREAM extends BaseStream<ELEMENT, AbstractListAssert<?,STREAM>> ? extends List<? extends ELEMENT>, assertThatELEMENT, ObjectAssert<ELEMENT>> (BaseStream<? extends ELEMENT, STREAM> actual) Delegate call toAssertions.assertThat(List)
-
assertThat
Delegate call toAssertions.assertThat(double[])
-
extractProperty
Delegate call toAssertions.extractProperty(String)
-
extractProperty
Delegate call toAssertions.extractProperty(String,Class)
-
tuple
Delegate call toAssertions.tuple(Object[])
-
atIndex
Delegate call toAssertions.atIndex(int)
-
within
Delegate call toAssertions.within(Double)
-
within
Delegate call toAssertions.within(BigDecimal)
-
within
Delegate call toAssertions.within(Float)
-
anyOf
Delegate call toAssertions.anyOf(Iterable)
-
anyOf
Delegate call toAssertions.anyOf(Condition[])
-
doesNotHave
Delegate call toAssertions.doesNotHave(Condition)
-
contentOf
Delegate call toAssertions.contentOf(File,String)
-
contentOf
Delegate call toAssertions.contentOf(File)
-
contentOf
Delegate call toAssertions.contentOf(File,Charset)
-
linesOf
Delegate call toAssertions.linesOf(File)
-
linesOf
Delegate call toAssertions.linesOf(File,String)
-
linesOf
Delegate call toAssertions.linesOf(File,Charset)
-
setRemoveAssertJRelatedElementsFromStackTrace
default void setRemoveAssertJRelatedElementsFromStackTrace(boolean actual) Delegate call toAssertions.setRemoveAssertJRelatedElementsFromStackTrace(boolean)
-
failBecauseExceptionWasNotThrown
-
setAllowExtractingPrivateFields
default void setAllowExtractingPrivateFields(boolean actual) Delegate call toAssertions.setAllowExtractingPrivateFields(boolean)
-
registerCustomDateFormat
Delegate call toAssertions.registerCustomDateFormat(DateFormat)
-
registerCustomDateFormat
Delegate call toAssertions.registerCustomDateFormat(String)
-
useDefaultDateFormatsOnly
default void useDefaultDateFormatsOnly()Delegate call toAssertions.useDefaultDateFormatsOnly()
-
assertThat
Delegate call toAssertions.assertThat(ZonedDateTime)
-
assertThat
Delegate call toAssertions.assertThat(CompletableFuture)
-
assertThat
Delegate call toAssertions.assertThat(Optional)
-
assertThat
Delegate call toAssertions.assertThat(java.util.OptionalDouble)
-
assertThat
Delegate call toAssertions.assertThat(java.util.OptionalInt)
-
assertThat
Delegate call toAssertions.assertThat(java.util.OptionalLong)
-
assertThat
Delegate call toAssertions.assertThat(LocalDateTime)
-
assertThat
Delegate call toAssertions.assertThat(LocalDate)
-
assertThat
Delegate call toAssertions.assertThat(LocalTime)
-
assertThat
Delegate call toAssertions.assertThat(java.time.Instant)
- Since:
- 3.7.0
-
assertThat
Delegate call toAssertions.assertThat(OffsetTime)
-
assertThat
Delegate call toAssertions.assertThat(OffsetDateTime)
-
assertThatThrownBy
default AbstractThrowableAssert<?,? extends Throwable> assertThatThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable) Delegate call toAssertions.assertThatThrownBy(ThrowableAssert.ThrowingCallable)
-
assertThatCode
default AbstractThrowableAssert<?,? extends Throwable> assertThatCode(ThrowableAssert.ThrowingCallable shouldRaiseOrNotThrowable) Allows to capture and then assert on aThrowable
more easily when used with Java 8 lambdas.Example :
If the providedThrowingCallable callable = () -> { throw new Exception("boom!"); }; // assertion succeeds assertThatCode(callable).isInstanceOf(Exception.class) .hasMessageContaining("boom"); // assertion fails assertThatCode(callable).doesNotThrowAnyException();
ThrowableAssert.ThrowingCallable
does not validate against next assertions, an error is immediately raised, in that case the test description provided withas(String, Object...)
is not honored. To use a test description, usecatchThrowable(ThrowableAssert.ThrowingCallable)
as shown below.ThrowingCallable doNothing = () -> { // do nothing }; // assertion fails and "display me" appears in the assertion error assertThatCode(doNothing).as("display me") .isInstanceOf(Exception.class); // assertion will fail AND "display me" will appear in the error Throwable thrown = catchThrowable(doNothing); assertThatCode(thrown).as("display me") .isInstanceOf(Exception.class);
This method was not named
assertThat
because the java compiler reported it ambiguous when used directly with a lambda :(- Parameters:
shouldRaiseOrNotThrowable
- TheThrowableAssert.ThrowingCallable
or lambda with the code that should raise the throwable.- Returns:
- The captured exception or
null
if none was raised by the callable. - Since:
- 3.7.0
-
catchThrowable
Delegate call toAssertions.catchThrowable(ThrowableAssert.ThrowingCallable)
-
assertThatExceptionOfType
default <T extends Throwable> ThrowableTypeAssert<T> assertThatExceptionOfType(Class<? extends T> exceptionType) Entry point to check that an exception of type T is thrown by a giventhrowingCallable
which allows to chain assertions on the thrown exception.Example:
This method is more or less the same ofassertThatExceptionOfType(IOException.class).isThrownBy(() -> { throw new IOException("boom!"); }) .withMessage("boom!");
assertThatThrownBy(ThrowableAssert.ThrowingCallable)
but in a more natural way.- Parameters:
exceptionType
- the actual value.- Returns:
- the created
ThrowableTypeAssert
.
-
assertThat
Delegate call toAssertions.assertThat(Predicate)
-
assertThat
Delegate call toAssertions.assertThat(IntPredicate)
-
assertThat
Delegate call toAssertions.assertThat(LongPredicate)
-
assertThat
Delegate call toAssertions.assertThat(DoublePredicate)
-
assertThat
Delegate call toAssertions.assertThat(URL)
-
assertThat
Delegate call toAssertions.assertThat(URI)
-
assertThat
Delegate call toAssertions.assertThat(AssertProvider)
-
filter
Delegate call toAssertions.filter(Object[])
-
filter
Delegate call toAssertions.filter(Iterable)
-