public interface WithAssertions
default Offset<Float> offset(Float value)
Assertions.offset(Float)
default Offset<Double> offset(Double value)
Assertions.offset(Double)
default <K,V> MapEntry<K,V> entry(K key, V value)
Assertions.entry(Object, Object)
default void fail(String failureMessage)
Assertions.fail(String)
default void fail(String failureMessage, Throwable realCause)
Assertions.fail(String,Throwable)
default <T> Not<T> not(Condition<? super T> condition)
Assertions.not(Condition)
default <T> Condition<T> allOf(Iterable<? extends Condition<? super T>> conditions)
Assertions.allOf(Iterable)
default <T> Condition<T> allOf(Condition<? super T>... conditions)
Assertions.allOf(Condition[])
default <T> AbstractObjectArrayAssert<?,T> assertThat(T[] actual)
Assertions.assertThat(Object[])
default <T extends AssertDelegateTarget> T assertThat(T assertion)
Assertions.assertThat(AssertDelegateTarget)
default <K,V> MapAssert<K,V> assertThat(Map<K,V> actual)
Assertions.assertThat(Map)
default AbstractShortAssert<?> assertThat(short actual)
Assertions.assertThat(short)
default AbstractLongAssert<?> assertThat(long actual)
Assertions.assertThat(long)
default AbstractLongAssert<?> assertThat(Long actual)
Assertions.assertThat(Long)
default AbstractLongArrayAssert<?> assertThat(long[] actual)
Assertions.assertThat(long[])
default <T> AbstractObjectAssert<?,T> assertThat(T actual)
Assertions.assertThat(Object)
default AbstractCharSequenceAssert<?,String> assertThat(String actual)
Assertions.assertThat(String)
default AbstractDateAssert<?> assertThat(Date actual)
Assertions.assertThat(Date)
default AbstractThrowableAssert<?,? extends Throwable> assertThat(Throwable actual)
Assertions.assertThat(Throwable)
default AbstractBigDecimalAssert<?> assertThat(BigDecimal actual)
Assertions.assertThat(BigDecimal)
default AbstractBigIntegerAssert<?> assertThat(BigInteger actual)
BigIntegerAssert
.actual
- the actual value.default AtomicBooleanAssert assertThat(AtomicBoolean actual)
AtomicBoolean
.actual
- the actual value.default AtomicIntegerAssert assertThat(AtomicInteger actual)
AtomicInteger
.actual
- the actual value.default AtomicIntegerArrayAssert assertThat(AtomicIntegerArray actual)
AtomicIntegerArray
.actual
- the actual value.default <OBJECT> AtomicIntegerFieldUpdaterAssert<OBJECT> assertThat(AtomicIntegerFieldUpdater<OBJECT> actual)
AtomicIntegerFieldUpdater
.OBJECT
- the type of the object holding the updatable field.actual
- the actual value.default AtomicLongAssert assertThat(AtomicLong actual)
AtomicLong
.actual
- the actual value.default AtomicLongArrayAssert assertThat(AtomicLongArray actual)
AtomicLongArray
.actual
- the actual value.default <OBJECT> AtomicLongFieldUpdaterAssert<OBJECT> assertThat(AtomicLongFieldUpdater<OBJECT> actual)
AtomicLongFieldUpdater
.OBJECT
- the type of the object holding the updatable field.actual
- the actual value.default <VALUE> AtomicReferenceAssert<VALUE> assertThat(AtomicReference<VALUE> actual)
AtomicReference
.VALUE
- the type of the value contained in the AtomicReference
.actual
- the actual value.default <ELEMENT> AtomicReferenceArrayAssert<ELEMENT> assertThat(AtomicReferenceArray<ELEMENT> actual)
AtomicReferenceArray
.ELEMENT
- the type of the value contained in the AtomicReferenceArray
.actual
- the actual value.default <FIELD,OBJECT> AtomicReferenceFieldUpdaterAssert<FIELD,OBJECT> assertThat(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.default <VALUE> AtomicMarkableReferenceAssert<VALUE> assertThat(AtomicMarkableReference<VALUE> actual)
AtomicMarkableReference
.VALUE
- the type of the value contained in the AtomicMarkableReference
.actual
- the actual value.default <VALUE> AtomicStampedReferenceAssert<VALUE> assertThat(AtomicStampedReference<VALUE> actual)
AtomicStampedReference
.VALUE
- the type of the value contained in the AtomicStampedReference
.actual
- the actual value.default AbstractCharSequenceAssert<?,? extends CharSequence> assertThat(CharSequence actual)
Assertions.assertThat(CharSequence)
default AbstractShortArrayAssert<?> assertThat(short[] actual)
Assertions.assertThat(short[])
default AbstractShortAssert<?> assertThat(Short actual)
Assertions.assertThat(Short)
default AbstractClassAssert<?> assertThat(Class<?> actual)
Assertions.assertThat(Class)
default AbstractCharacterAssert<?> assertThat(Character actual)
Assertions.assertThat(Character)
default AbstractCharArrayAssert<?> assertThat(char[] actual)
Assertions.assertThat(char[])
default AbstractCharacterAssert<?> assertThat(char actual)
Assertions.assertThat(char)
default <T extends Comparable<? super T>> AbstractComparableAssert<?,T> assertThat(T actual)
Assertions.assertThat(Comparable)
default <T> IterableAssert<T> assertThat(Iterable<? extends T> actual)
Assertions.assertThat(Iterable)
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)
Assertions.assertThat(Iterable, AssertFactory)
default <T> IterableAssert<T> assertThat(Iterator<? extends T> actual)
Assertions.assertThat(Iterator)
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)
Assertions.assertThat(Iterable, Class)
default AbstractBooleanAssert<?> assertThat(Boolean actual)
Assertions.assertThat(Boolean)
default AbstractBooleanArrayAssert<?> assertThat(boolean[] actual)
Assertions.assertThat(boolean)
default AbstractByteAssert<?> assertThat(byte actual)
Assertions.assertThat(byte)
default AbstractByteAssert<?> assertThat(Byte actual)
Assertions.assertThat(Byte)
default AbstractByteArrayAssert<?> assertThat(byte[] actual)
Assertions.assertThat(byte[])
default AbstractBooleanAssert<?> assertThat(boolean actual)
Assertions.assertThat(boolean)
default AbstractFloatAssert<?> assertThat(float actual)
Assertions.assertThat(float)
default AbstractInputStreamAssert<?,? extends InputStream> assertThat(InputStream actual)
Assertions.assertThat(InputStream)
default AbstractFileAssert<?> assertThat(File actual)
Assertions.assertThat(File)
default <RESULT> AbstractFutureAssert<?,? extends Future<? extends RESULT>,RESULT> assertThat(Future<RESULT> actual)
Assertions.assertThat(Future)
default AbstractPathAssert<?> assertThat(Path actual)
Assertions.assertThat(Path)
default AbstractIntArrayAssert<?> assertThat(int[] actual)
Assertions.assertThat(int[])
default AbstractFloatAssert<?> assertThat(Float actual)
Assertions.assertThat(Float)
default AbstractIntegerAssert<?> assertThat(int actual)
Assertions.assertThat(int)
default AbstractFloatArrayAssert<?> assertThat(float[] actual)
Assertions.assertThat(float[])
default AbstractIntegerAssert<?> assertThat(Integer actual)
Assertions.assertThat(Integer)
default AbstractDoubleAssert<?> assertThat(double actual)
Assertions.assertThat(double)
default AbstractDoubleAssert<?> assertThat(Double actual)
Assertions.assertThat(Double)
default <T> ListAssert<? extends T> assertThat(List<? extends T> actual)
Assertions.assertThat(List)
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)
Assertions.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)
Assertions.assertThat(List, AssertFactory)
)}default <ELEMENT,STREAM extends BaseStream<ELEMENT,STREAM>> AbstractListAssert<?,? extends List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>> assertThat(BaseStream<? extends ELEMENT,STREAM> actual)
Assertions.assertThat(List)
default AbstractDoubleArrayAssert<?> assertThat(double[] actual)
Assertions.assertThat(double[])
default Properties<Object> extractProperty(String propertyName)
Assertions.extractProperty(String)
default <T> Properties<T> extractProperty(String propertyName, Class<T> propertyType)
Assertions.extractProperty(String,Class)
default Tuple tuple(Object... values)
Assertions.tuple(Object[])
default Index atIndex(int actual)
Assertions.atIndex(int)
default Offset<Double> within(Double actual)
Assertions.within(Double)
default Offset<BigDecimal> within(BigDecimal actual)
Assertions.within(BigDecimal)
default Offset<Float> within(Float actual)
Assertions.within(Float)
default <T> Condition<T> anyOf(Iterable<? extends Condition<? super T>> conditions)
Assertions.anyOf(Iterable)
default <T> Condition<T> anyOf(Condition<? super T>... conditions)
Assertions.anyOf(Condition[])
default <T> DoesNotHave<T> doesNotHave(Condition<? super T> condition)
Assertions.doesNotHave(Condition)
default String contentOf(File file, String charsetName)
Assertions.contentOf(File,String)
default String contentOf(File actual)
Assertions.contentOf(File)
default String contentOf(File file, Charset charset)
Assertions.contentOf(File,Charset)
default List<String> linesOf(File actual)
Assertions.linesOf(File)
default List<String> linesOf(File file, String charsetName)
Assertions.linesOf(File,String)
default List<String> linesOf(File actual, Charset arg1)
Assertions.linesOf(File,Charset)
default void setRemoveAssertJRelatedElementsFromStackTrace(boolean actual)
Assertions.setRemoveAssertJRelatedElementsFromStackTrace(boolean)
default void failBecauseExceptionWasNotThrown(Class<? extends Throwable> exceptionClass)
default void setAllowExtractingPrivateFields(boolean actual)
Assertions.setAllowExtractingPrivateFields(boolean)
default void registerCustomDateFormat(DateFormat actual)
Assertions.registerCustomDateFormat(DateFormat)
default void registerCustomDateFormat(String actual)
Assertions.registerCustomDateFormat(String)
default void useDefaultDateFormatsOnly()
Assertions.useDefaultDateFormatsOnly()
default AbstractZonedDateTimeAssert<?> assertThat(ZonedDateTime actual)
Assertions.assertThat(ZonedDateTime)
default <RESULT> CompletableFutureAssert<RESULT> assertThat(CompletableFuture<RESULT> future)
Assertions.assertThat(CompletableFuture)
default <VALUE> OptionalAssert<VALUE> assertThat(Optional<VALUE> optional)
Assertions.assertThat(Optional)
default OptionalDoubleAssert assertThat(OptionalDouble optional)
Assertions.assertThat(java.util.OptionalDouble)
default OptionalIntAssert assertThat(OptionalInt optional)
Assertions.assertThat(java.util.OptionalInt)
default OptionalLongAssert assertThat(OptionalLong optional)
Assertions.assertThat(java.util.OptionalLong)
default AbstractLocalDateTimeAssert<?> assertThat(LocalDateTime localDateTime)
Assertions.assertThat(LocalDateTime)
default AbstractLocalDateAssert<?> assertThat(LocalDate localDate)
Assertions.assertThat(LocalDate)
default AbstractLocalTimeAssert<?> assertThat(LocalTime localTime)
Assertions.assertThat(LocalTime)
default AbstractInstantAssert<?> assertThat(Instant actual)
Assertions.assertThat(java.time.Instant)
default AbstractOffsetTimeAssert<?> assertThat(OffsetTime offsetTime)
Assertions.assertThat(OffsetTime)
default AbstractOffsetDateTimeAssert<?> assertThat(OffsetDateTime offsetDateTime)
Assertions.assertThat(OffsetDateTime)
default AbstractThrowableAssert<?,? extends Throwable> assertThatThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable)
Assertions.assertThatThrownBy(ThrowableAssert.ThrowingCallable)
default AbstractThrowableAssert<?,? extends Throwable> assertThatCode(ThrowableAssert.ThrowingCallable shouldRaiseOrNotThrowable)
Throwable
more easily when used with Java 8 lambdas.
Example :
ThrowingCallable callable = () -> {
throw new Exception("boom!");
};
// assertion succeeds
assertThatCode(callable).isInstanceOf(Exception.class)
.hasMessageContaining("boom");
// assertion fails
assertThatCode(callable).doesNotThrowAnyException();
If the provided ThrowableAssert.ThrowingCallable
does not validate against next assertions, an error is immediately raised,
in that case the test description provided with as(String, Object...)
is not honored.
To use a test description, use catchThrowable(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 :(
shouldRaiseOrNotThrowable
- The ThrowableAssert.ThrowingCallable
or lambda with the code that should raise the throwable.null
if none was raised by the callable.default Throwable catchThrowable(ThrowableAssert.ThrowingCallable shouldRaiseThrowable)
Assertions.catchThrowable(ThrowableAssert.ThrowingCallable)
default <T extends Throwable> ThrowableTypeAssert<T> assertThatExceptionOfType(Class<? extends T> exceptionType)
throwingCallable
which allows to chain assertions on the thrown exception.
Example:
assertThatExceptionOfType(IOException.class).isThrownBy(() -> { throw new IOException("boom!"); })
.withMessage("boom!");
This method is more or less the same of assertThatThrownBy(ThrowableAssert.ThrowingCallable)
but in a more natural way.exceptionType
- the actual value.ThrowableTypeAssert
.default <T> PredicateAssert<T> assertThat(Predicate<T> actual)
Assertions.assertThat(Predicate)
default IntPredicateAssert assertThat(IntPredicate actual)
Assertions.assertThat(IntPredicate)
default LongPredicateAssert assertThat(LongPredicate actual)
Assertions.assertThat(LongPredicate)
default DoublePredicateAssert assertThat(DoublePredicate actual)
Assertions.assertThat(DoublePredicate)
default AbstractUrlAssert<?> assertThat(URL actual)
Assertions.assertThat(URL)
default AbstractUriAssert<?> assertThat(URI actual)
Assertions.assertThat(URI)
default <T> T assertThat(AssertProvider<T> component)
Assertions.assertThat(AssertProvider)
default <E> Filters<E> filter(E[] array)
Assertions.filter(Object[])
default <E> Filters<E> filter(Iterable<E> iterableToFilter)
Assertions.filter(Iterable)
Copyright © 2014–2017 AssertJ. All rights reserved.