Class Java6BDDAssertions
- java.lang.Object
-
- org.assertj.core.api.Java6BDDAssertions
-
@Deprecated public class Java6BDDAssertions extends Object
Deprecated.For Android compatible assertions use the latest assertj 2.x version which is based on Java 7 only.Android-compatible BDD-style assertions duplicated from
BDDAssertions
.- Since:
- 2.5.0 / 3.5.0
- See Also:
BDDAssertions
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Java6BDDAssertions()
Deprecated.Creates a new
.BDDAssertions
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static BooleanAssert
then(boolean actual)
Deprecated.Creates a new instance of
.BooleanAssert
static BooleanArrayAssert
then(boolean[] actual)
Deprecated.Creates a new instance of
.BooleanArrayAssert
static Boolean2DArrayAssert
then(boolean[][] actual)
Deprecated.Creates a new instance of
.Boolean2DArrayAssert
static ByteAssert
then(byte actual)
Deprecated.Creates a new instance of
.ByteAssert
static ByteArrayAssert
then(byte[] actual)
Deprecated.Creates a new instance of
.ByteArrayAssert
static Byte2DArrayAssert
then(byte[][] actual)
Deprecated.Creates a new instance of
.Byte2DArrayAssert
static CharacterAssert
then(char actual)
Deprecated.Creates a new instance of
.CharacterAssert
static CharArrayAssert
then(char[] actual)
Deprecated.Creates a new instance of
.CharArrayAssert
static Char2DArrayAssert
then(char[][] actual)
Deprecated.Creates a new instance of
.Char2DArrayAssert
static DoubleAssert
then(double actual)
Deprecated.Creates a new instance of
.DoubleAssert
static DoubleArrayAssert
then(double[] actual)
Deprecated.Creates a new instance of
.DoubleArrayAssert
static Double2DArrayAssert
then(double[][] actual)
Deprecated.Creates a new instance of
.Double2DArrayAssert
static FloatAssert
then(float actual)
Deprecated.Creates a new instance of
.FloatAssert
static FloatArrayAssert
then(float[] actual)
Deprecated.Creates a new instance of
.FloatArrayAssert
static Float2DArrayAssert
then(float[][] actual)
Deprecated.Creates a new instance of
.Float2DArrayAssert
static IntegerAssert
then(int actual)
Deprecated.Creates a new instance of
.IntegerAssert
static IntArrayAssert
then(int[] actual)
Deprecated.Creates a new instance of
.IntArrayAssert
static Int2DArrayAssert
then(int[][] actual)
Deprecated.Creates a new instance of
.Int2DArrayAssert
static LongAssert
then(long actual)
Deprecated.Creates a new instance of
.LongAssert
static LongArrayAssert
then(long[] actual)
Deprecated.Creates a new instance of
.LongArrayAssert
static Long2DArrayAssert
then(long[][] actual)
Deprecated.Creates a new instance of
.Long2DArrayAssert
static ShortAssert
then(short actual)
Deprecated.Creates a new instance of
.ShortAssert
static ShortArrayAssert
then(short[] actual)
Deprecated.Creates a new instance of
.ShortArrayAssert
static Short2DArrayAssert
then(short[][] actual)
Deprecated.Creates a new instance of
.Short2DArrayAssert
static <ACTUAL extends Iterable<? extends ELEMENT>,ELEMENT,ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT,ELEMENT>>
ClassBasedNavigableIterableAssert<?,ACTUAL,ELEMENT,ELEMENT_ASSERT>then(ACTUAL actual, Class<ELEMENT_ASSERT> assertClass)
Deprecated.Creates a new instance of
allowing to navigate to anyClassBasedNavigableIterableAssert
Iterable
element in order to perform assertions on it.static FileAssert
then(File actual)
Deprecated.Creates a new instance of
.FileAssert
static InputStreamAssert
then(InputStream actual)
Deprecated.Creates a new instance of
.InputStreamAssert
static BooleanAssert
then(Boolean actual)
Deprecated.Creates a new instance of
.BooleanAssert
static ByteAssert
then(Byte actual)
Deprecated.Creates a new instance of
.ByteAssert
static CharacterAssert
then(Character actual)
Deprecated.Creates a new instance of
.CharacterAssert
static CharSequenceAssert
then(CharSequence actual)
Deprecated.Creates a new instance of
.CharSequenceAssert
static ClassAssert
then(Class<?> actual)
Deprecated.Creates a new instance ofClassAssert
static DoubleAssert
then(Double actual)
Deprecated.Creates a new instance of
.DoubleAssert
static FloatAssert
then(Float actual)
Deprecated.Creates a new instance of
.FloatAssert
static IntegerAssert
then(Integer actual)
Deprecated.Creates a new instance of
.IntegerAssert
static <ACTUAL extends Iterable<? extends ELEMENT>,ELEMENT,ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT,ELEMENT>>
FactoryBasedNavigableIterableAssert<?,ACTUAL,ELEMENT,ELEMENT_ASSERT>then(Iterable<? extends ELEMENT> actual, AssertFactory<ELEMENT,ELEMENT_ASSERT> assertFactory)
Deprecated.Creates a new instance of
allowing to navigate to anyFactoryBasedNavigableIterableAssert
Iterable
element in order to perform assertions on it.static <T> IterableAssert<T>
then(Iterable<? extends T> actual)
Deprecated.Creates a new instance of
.IterableAssert
static LongAssert
then(Long actual)
Deprecated.Creates a new instance of
.LongAssert
static ShortAssert
then(Short actual)
Deprecated.Creates a new instance of
.ShortAssert
static StringAssert
then(String actual)
Deprecated.Creates a new instance of
.StringAssert
static CharSequenceAssert
then(StringBuffer actual)
Deprecated.Creates a new instance of
from aCharSequenceAssert
StringBuffer
.static CharSequenceAssert
then(StringBuilder actual)
Deprecated.Creates a new instance of
from aCharSequenceAssert
StringBuilder
.static ThrowableAssert
then(Throwable actual)
Deprecated.Creates a new instance of
.ThrowableAssert
static BigDecimalAssert
then(BigDecimal actual)
Deprecated.Creates a new instance of
.BigDecimalAssert
static BigIntegerAssert
then(BigInteger actual)
Deprecated.Creates a new instance of
.BigIntegerAssert
static UriAssert
then(URI actual)
Deprecated.Creates a new instance of
.UriAssert
static UrlAssert
then(URL actual)
Deprecated.Creates a new instance of
.UrlAssert
static AtomicBooleanAssert
then(AtomicBoolean actual)
Deprecated.Create assertion forAtomicBoolean
.static AtomicIntegerAssert
then(AtomicInteger actual)
Deprecated.Create assertion forAtomicInteger
.static AtomicIntegerArrayAssert
then(AtomicIntegerArray actual)
Deprecated.Create int[] assertion forAtomicIntegerArray
.static <OBJECT> AtomicIntegerFieldUpdaterAssert<OBJECT>
then(AtomicIntegerFieldUpdater<OBJECT> actual)
Deprecated.Create assertion forAtomicIntegerFieldUpdater
.static AtomicLongAssert
then(AtomicLong actual)
Deprecated.Create assertion forAtomicLong
.static AtomicLongArrayAssert
then(AtomicLongArray actual)
Deprecated.Create assertion forAtomicLongArray
.static <OBJECT> AtomicLongFieldUpdaterAssert<OBJECT>
then(AtomicLongFieldUpdater<OBJECT> actual)
Deprecated.Create assertion forAtomicLongFieldUpdater
.static <VALUE> AtomicMarkableReferenceAssert<VALUE>
then(AtomicMarkableReference<VALUE> actual)
Deprecated.Create assertion forAtomicMarkableReference
.static <VALUE> AtomicReferenceAssert<VALUE>
then(AtomicReference<VALUE> actual)
Deprecated.Create assertion forAtomicReference
.static <ELEMENT> AtomicReferenceArrayAssert<ELEMENT>
then(AtomicReferenceArray<ELEMENT> actual)
Deprecated.Create assertion forAtomicReferenceArray
.static <FIELD,OBJECT>
AtomicReferenceFieldUpdaterAssert<FIELD,OBJECT>then(AtomicReferenceFieldUpdater<OBJECT,FIELD> actual)
Deprecated.Create assertion forAtomicReferenceFieldUpdater
.static <VALUE> AtomicStampedReferenceAssert<VALUE>
then(AtomicStampedReference<VALUE> actual)
Deprecated.Create assertion forAtomicStampedReference
.static <RESULT> FutureAssert<RESULT>
then(Future<RESULT> actual)
Deprecated.Creates a new instance of
.FutureAssert
static DateAssert
then(Date actual)
Deprecated.Creates a new instance of
.DateAssert
static <T> IteratorAssert<T>
then(Iterator<? extends T> actual)
Deprecated.Creates a new instance of
.IteratorAssert
static <ELEMENT,ACTUAL extends List<? extends ELEMENT>,ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT,ELEMENT>>
ClassBasedNavigableListAssert<?,ACTUAL,ELEMENT,ELEMENT_ASSERT>then(List<? extends ELEMENT> actual, Class<ELEMENT_ASSERT> assertClass)
Deprecated.Creates a new instance of
allowing to navigate to anyClassBasedNavigableListAssert
List
element in order to perform assertions on it.static <ACTUAL extends List<? extends ELEMENT>,ELEMENT,ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT,ELEMENT>>
FactoryBasedNavigableListAssert<?,ACTUAL,ELEMENT,ELEMENT_ASSERT>then(List<? extends ELEMENT> actual, AssertFactory<ELEMENT,ELEMENT_ASSERT> assertFactory)
Deprecated.Creates a new instance of
allowing to navigate to anyFactoryBasedNavigableListAssert
List
element in order to perform assertions on it.static <T> ListAssert<T>
then(List<? extends T> actual)
Deprecated.Creates a new instance of
.ListAssert
static <K,V>
MapAssert<K,V>then(Map<K,V> actual)
Deprecated.Creates a new instance of
.MapAssert
static <T> T
then(AssertProvider<T> component)
Deprecated.Delegates the creation of theAssert
to theAssertProvider.assertThat()
of the given component.static <T extends Comparable<? super T>>
GenericComparableAssert<T>then(T actual)
Deprecated.Creates a new instance of
with standard comparison semantics.GenericComparableAssert
static <T> ObjectArrayAssert<T>
then(T[] actual)
Deprecated.Creates a new instance of
.ObjectArrayAssert
static <T> Object2DArrayAssert<T>
then(T[][] actual)
Deprecated.Creates a new instance of
.Object2DArrayAssert
ThrowableAssert
thenCode(ThrowableAssert.ThrowingCallable shouldRaiseOrNotThrowable)
Deprecated.Allows to capture and then assert on aThrowable
more easily when used with Java 8 lambdas.static <T> ObjectAssert<T>
thenObject(T actual)
Deprecated.Creates a new instance of
for any object.ObjectAssert
static ThrowableAssert
thenThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable)
Deprecated.Allows to capture and then assert on aThrowable
more easily when used with Java 8 lambdas.static ThrowableAssert
thenThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable, String description, Object... args)
Deprecated.Allows to capture and then assert on aThrowable
likethenThrownBy(ThrowingCallable)
but this method let you set the assertion description the same way you do withas(String, Object...)
.
-
-
-
Constructor Detail
-
Java6BDDAssertions
protected Java6BDDAssertions()
Deprecated.Creates a new
.BDDAssertions
-
-
Method Detail
-
then
public static AtomicBooleanAssert then(AtomicBoolean actual)
Deprecated.Create assertion forAtomicBoolean
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 2.7.0 / 3.7.0
-
then
public static AtomicIntegerAssert then(AtomicInteger actual)
Deprecated.Create assertion forAtomicInteger
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 2.7.0 / 3.7.0
-
then
public static AtomicIntegerArrayAssert then(AtomicIntegerArray actual)
Deprecated.Create int[] assertion forAtomicIntegerArray
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 2.7.0 / 3.7.0
-
then
public static <OBJECT> AtomicIntegerFieldUpdaterAssert<OBJECT> then(AtomicIntegerFieldUpdater<OBJECT> actual)
Deprecated.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.
- Since:
- 2.7.0 / 3.7.0
-
then
public static AtomicLongAssert then(AtomicLong actual)
Deprecated.Create assertion forAtomicLong
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 2.7.0 / 3.7.0
-
then
public static AtomicLongArrayAssert then(AtomicLongArray actual)
Deprecated.Create assertion forAtomicLongArray
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 2.7.0 / 3.7.0
-
then
public static <OBJECT> AtomicLongFieldUpdaterAssert<OBJECT> then(AtomicLongFieldUpdater<OBJECT> actual)
Deprecated.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.
- Since:
- 2.7.0 / 3.7.0
-
then
public static <VALUE> AtomicReferenceAssert<VALUE> then(AtomicReference<VALUE> actual)
Deprecated.Create assertion forAtomicReference
.- Type Parameters:
VALUE
- the type of the value contained in theAtomicReference
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 2.7.0 / 3.7.0
-
then
public static <ELEMENT> AtomicReferenceArrayAssert<ELEMENT> then(AtomicReferenceArray<ELEMENT> actual)
Deprecated.Create assertion forAtomicReferenceArray
.- Type Parameters:
ELEMENT
- the type of the value contained in theAtomicReferenceArray
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 2.7.0 / 3.7.0
-
then
public static <FIELD,OBJECT> AtomicReferenceFieldUpdaterAssert<FIELD,OBJECT> then(AtomicReferenceFieldUpdater<OBJECT,FIELD> actual)
Deprecated.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.
- Since:
- 2.7.0 / 3.7.0
-
then
public static <VALUE> AtomicMarkableReferenceAssert<VALUE> then(AtomicMarkableReference<VALUE> actual)
Deprecated.Create assertion forAtomicMarkableReference
.- Type Parameters:
VALUE
- the type of the value contained in theAtomicMarkableReference
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 2.7.0 / 3.7.0
-
then
public static <VALUE> AtomicStampedReferenceAssert<VALUE> then(AtomicStampedReference<VALUE> actual)
Deprecated.Create assertion forAtomicStampedReference
.- Type Parameters:
VALUE
- the type of the value contained in theAtomicStampedReference
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 2.7.0 / 3.7.0
-
then
public static BigDecimalAssert then(BigDecimal actual)
Deprecated.Creates a new instance of
.BigDecimalAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static BigIntegerAssert then(BigInteger actual)
Deprecated.Creates a new instance of
.BigIntegerAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 2.7.0 / 3.7.0
-
then
public static BooleanAssert then(boolean actual)
Deprecated.Creates a new instance of
.BooleanAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static BooleanAssert then(Boolean actual)
Deprecated.Creates a new instance of
.BooleanAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static BooleanArrayAssert then(boolean[] actual)
Deprecated.Creates a new instance of
.BooleanArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static Boolean2DArrayAssert then(boolean[][] actual)
Deprecated.Creates a new instance of
.Boolean2DArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
then
public static ByteAssert then(byte actual)
Deprecated.Creates a new instance of
.ByteAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static ByteAssert then(Byte actual)
Deprecated.Creates a new instance of
.ByteAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static ByteArrayAssert then(byte[] actual)
Deprecated.Creates a new instance of
.ByteArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static Byte2DArrayAssert then(byte[][] actual)
Deprecated.Creates a new instance of
.Byte2DArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
then
public static CharacterAssert then(char actual)
Deprecated.Creates a new instance of
.CharacterAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static CharArrayAssert then(char[] actual)
Deprecated.Creates a new instance of
.CharArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static Char2DArrayAssert then(char[][] actual)
Deprecated.Creates a new instance of
.Char2DArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
then
public static CharacterAssert then(Character actual)
Deprecated.Creates a new instance of
.CharacterAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static ClassAssert then(Class<?> actual)
Deprecated.Creates a new instance ofClassAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static <T extends Comparable<? super T>> GenericComparableAssert<T> then(T actual)
Deprecated.Creates a new instance of
with standard comparison semantics.GenericComparableAssert
- Type Parameters:
T
- the actual type- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static <T> IterableAssert<T> then(Iterable<? extends T> actual)
Deprecated.Creates a new instance of
.IterableAssert
- Type Parameters:
T
- the actual elements type- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static <T> IteratorAssert<T> then(Iterator<? extends T> actual)
Deprecated.Creates a new instance of
.IteratorAssert
Breaking change in version 3.12.0: this method does not return anymore an
IterableAssert
but anIteratorAssert
.
In order to access assertions fromIterableAssert
, useAbstractIteratorAssert.toIterable()
.IteratorAssert
instances have limited assertions because it does not consume iterator's elements.Examples:
Iterator<String> bestBasketBallPlayers = getBestBasketBallPlayers(); then(bestBasketBallPlayers).hasNext() // Iterator assertion .toIterable() // switch to Iterable assertions .contains("Jordan", "Magic", "Lebron"); // Iterable assertion
- Type Parameters:
T
- the actual elements type- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static <ACTUAL extends Iterable<? extends ELEMENT>,ELEMENT,ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT,ELEMENT>> FactoryBasedNavigableIterableAssert<?,ACTUAL,ELEMENT,ELEMENT_ASSERT> then(Iterable<? extends ELEMENT> actual, AssertFactory<ELEMENT,ELEMENT_ASSERT> assertFactory)
Deprecated.Creates a new instance of
allowing to navigate to anyFactoryBasedNavigableIterableAssert
Iterable
element in order to perform assertions on it.Navigational methods provided:
The available assertions after navigating to an element depend on the
ELEMENT_ASSERT
parameter of the givenAssertFactory<ELEMENT, ELEMENT_ASSERT>
(AssertJ can't figure it out because of Java type erasure).Example with
String
element assertions:Iterable<String> hobbits = newHashSet("frodo", "sam", "pippin"); // build an AssertFactory for StringAssert (much nicer with Java 8 lambdas) AssertFactory<String, StringAssert> stringAssertFactory = new AssertFactory<String, StringAssert>() { @Override public StringAssert createAssert(String string) { return new StringAssert(string); } }; // assertion succeeds with String assertions chained after first() then(hobbits, stringAssertFactory).first() .startsWith("fro") .endsWith("do");
- Type Parameters:
ACTUAL
- The actual typeELEMENT
- The actual elements typeELEMENT_ASSERT
- The actual elements AbstractAssert type- Parameters:
actual
- the actual value.assertFactory
- the factory used to create the elements assert instance.- Returns:
- the created assertion object.
-
then
public static <ACTUAL extends Iterable<? extends ELEMENT>,ELEMENT,ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT,ELEMENT>> ClassBasedNavigableIterableAssert<?,ACTUAL,ELEMENT,ELEMENT_ASSERT> then(ACTUAL actual, Class<ELEMENT_ASSERT> assertClass)
Deprecated.Creates a new instance of
allowing to navigate to anyClassBasedNavigableIterableAssert
Iterable
element in order to perform assertions on it.Navigational methods provided:
The available assertions after navigating to an element depend on the given
assertClass
(AssertJ can't find the element assert type by itself because of Java type erasure).Example with
String
element assertions:Iterable<String> hobbits = newHashSet("frodo", "sam", "pippin"); // assertion succeeds with String assertions chained after first() then(hobbits, StringAssert.class).first() .startsWith("fro") .endsWith("do");
- Type Parameters:
ACTUAL
- The actual typeELEMENT
- The actual elements typeELEMENT_ASSERT
- The actual elements AbstractAssert type- Parameters:
actual
- the actual value.assertClass
- the class used to create the elements assert instance.- Returns:
- the created assertion object.
-
then
public static <ACTUAL extends List<? extends ELEMENT>,ELEMENT,ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT,ELEMENT>> FactoryBasedNavigableListAssert<?,ACTUAL,ELEMENT,ELEMENT_ASSERT> then(List<? extends ELEMENT> actual, AssertFactory<ELEMENT,ELEMENT_ASSERT> assertFactory)
Deprecated.Creates a new instance of
allowing to navigate to anyFactoryBasedNavigableListAssert
List
element in order to perform assertions on it.Navigational methods provided:
The available assertions after navigating to an element depend on the
ELEMENT_ASSERT
parameter of the givenAssertFactory<ELEMENT, ELEMENT_ASSERT>
(AssertJ can't figure it out because of Java type erasure).Example with
String
element assertions:List<String> hobbits = newArrayList("frodo", "sam", "pippin"); // build an AssertFactory for StringAssert (much nicer with Java 8 lambdas) AssertFactory<String, StringAssert> stringAssertFactory = new AssertFactory<String, StringAssert>() { @Override public StringAssert createAssert(String string) { return new StringAssert(string); } }; // assertion succeeds with String assertions chained after first() then(hobbits, stringAssertFactory).first() .startsWith("fro") .endsWith("do");
- Type Parameters:
ACTUAL
- The actual typeELEMENT
- The actual elements typeELEMENT_ASSERT
- The actual elements AbstractAssert type- Parameters:
actual
- the actual value.assertFactory
- the factory used to create the elements assert instance.- Returns:
- the created assertion object.
-
then
public static <ELEMENT,ACTUAL extends List<? extends ELEMENT>,ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT,ELEMENT>> ClassBasedNavigableListAssert<?,ACTUAL,ELEMENT,ELEMENT_ASSERT> then(List<? extends ELEMENT> actual, Class<ELEMENT_ASSERT> assertClass)
Deprecated.Creates a new instance of
allowing to navigate to anyClassBasedNavigableListAssert
List
element in order to perform assertions on it.Navigational methods provided:
The available assertions after navigating to an element depend on the given
assertClass
(AssertJ can't find the element assert type by itself because of Java type erasure).Example with
String
element assertions:List<String> hobbits = newArrayList("frodo", "sam", "pippin"); // assertion succeeds with String assertions chained after first() then(hobbits, StringAssert.class).first() .startsWith("fro") .endsWith("do");
- Type Parameters:
ACTUAL
- The actual typeELEMENT
- The actual elements typeELEMENT_ASSERT
- The actual elements AbstractAssert type- Parameters:
actual
- the actual value.assertClass
- the class used to create the elements assert instance.- Returns:
- the created assertion object.
-
then
public static DoubleAssert then(double actual)
Deprecated.Creates a new instance of
.DoubleAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static DoubleAssert then(Double actual)
Deprecated.Creates a new instance of
.DoubleAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static DoubleArrayAssert then(double[] actual)
Deprecated.Creates a new instance of
.DoubleArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static Double2DArrayAssert then(double[][] actual)
Deprecated.Creates a new instance of
.Double2DArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
then
public static FileAssert then(File actual)
Deprecated.Creates a new instance of
.FileAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static <RESULT> FutureAssert<RESULT> then(Future<RESULT> actual)
Deprecated.Creates a new instance of
.FutureAssert
- Type Parameters:
RESULT
- the type of the value contained in theFuture
.- Parameters:
actual
- the future to test- Returns:
- the created assertion object
- Since:
- 2.7.0 / 3.7.0
-
then
public static InputStreamAssert then(InputStream actual)
Deprecated.Creates a new instance of
.InputStreamAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static FloatAssert then(float actual)
Deprecated.Creates a new instance of
.FloatAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static FloatAssert then(Float actual)
Deprecated.Creates a new instance of
.FloatAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static FloatArrayAssert then(float[] actual)
Deprecated.Creates a new instance of
.FloatArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static IntegerAssert then(int actual)
Deprecated.Creates a new instance of
.IntegerAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static IntArrayAssert then(int[] actual)
Deprecated.Creates a new instance of
.IntArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static Int2DArrayAssert then(int[][] actual)
Deprecated.Creates a new instance of
.Int2DArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static Float2DArrayAssert then(float[][] actual)
Deprecated.Creates a new instance of
.Float2DArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
then
public static IntegerAssert then(Integer actual)
Deprecated.Creates a new instance of
.IntegerAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static <T> ListAssert<T> then(List<? extends T> actual)
Deprecated.Creates a new instance of
.ListAssert
- Type Parameters:
T
- the actual elements type- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static LongAssert then(long actual)
Deprecated.Creates a new instance of
.LongAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static LongAssert then(Long actual)
Deprecated.Creates a new instance of
.LongAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static LongArrayAssert then(long[] actual)
Deprecated.Creates a new instance of
.LongArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static Long2DArrayAssert then(long[][] actual)
Deprecated.Creates a new instance of
.Long2DArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
then
public static <T> ObjectAssert<T> then(T actual)
Deprecated.Creates a new instance of
.ObjectAssert
- Type Parameters:
T
- the actual type- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static <T> ObjectArrayAssert<T> then(T[] actual)
Deprecated.Creates a new instance of
.ObjectArrayAssert
- Type Parameters:
T
- the actual elements type- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static <T> Object2DArrayAssert<T> then(T[][] actual)
Deprecated.Creates a new instance of
.Object2DArrayAssert
- Type Parameters:
T
- the actual elements type- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
then
public static <K,V> MapAssert<K,V> then(Map<K,V> actual)
Deprecated.Creates a new instance of
.MapAssert
- Type Parameters:
K
- the type of keys in the map.V
- the type of values in the map.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static ShortAssert then(short actual)
Deprecated.Creates a new instance of
.ShortAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static ShortAssert then(Short actual)
Deprecated.Creates a new instance of
.ShortAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static ShortArrayAssert then(short[] actual)
Deprecated.Creates a new instance of
.ShortArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static Short2DArrayAssert then(short[][] actual)
Deprecated.Creates a new instance of
.Short2DArrayAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.17.0
-
then
public static CharSequenceAssert then(CharSequence actual)
Deprecated.Creates a new instance of
.CharSequenceAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static CharSequenceAssert then(StringBuilder actual)
Deprecated.Creates a new instance of
from aCharSequenceAssert
StringBuilder
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.11.0
-
then
public static CharSequenceAssert then(StringBuffer actual)
Deprecated.Creates a new instance of
from aCharSequenceAssert
StringBuffer
.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.11.0
-
then
public static StringAssert then(String actual)
Deprecated.Creates a new instance of
.StringAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static DateAssert then(Date actual)
Deprecated.Creates a new instance of
.DateAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static ThrowableAssert then(Throwable actual)
Deprecated.Creates a new instance of
.ThrowableAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion Throwable.
-
thenThrownBy
public static ThrowableAssert thenThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable)
Deprecated.Allows to capture and then assert on aThrowable
more easily when used with Java 8 lambdas.Java 8 example :
Java 7 example :@Test public void testException() { thenThrownBy(() -> { throw new Exception("boom!") }).isInstanceOf(Exception.class) .hasMessageContaining("boom"); }
If the providedthenThrownBy(new ThrowingCallable() { @Override public Void call() throws Exception { throw new Exception("boom!"); } }).isInstanceOf(Exception.class) .hasMessageContaining("boom");
ThrowableAssert.ThrowingCallable
does not raise an exception, an error is immediately thrown, in that case the test description provided withas(String, Object...)
is not honored.
To use a test description, useAssertions.catchThrowable(ThrowableAssert.ThrowingCallable)
as shown below:
Alternatively you can also use// assertion will fail but "display me" won't appear in the error thenThrownBy(() -> {}).as("display me") .isInstanceOf(Exception.class); // assertion will fail AND "display me" will appear in the error Throwable thrown = catchThrowable(() -> {}); then(thrown).as("display me") .isInstanceOf(Exception.class);
thenCode(ThrowingCallable)
for the test description provided withas(String, Object...)
to always be honored.- Parameters:
shouldRaiseThrowable
- 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.
-
thenThrownBy
public static ThrowableAssert thenThrownBy(ThrowableAssert.ThrowingCallable shouldRaiseThrowable, String description, Object... args)
Deprecated.Allows to capture and then assert on aThrowable
likethenThrownBy(ThrowingCallable)
but this method let you set the assertion description the same way you do withas(String, Object...)
.Example:
If the provided@Test public void testException() { // if this assertion failed (but it doesn't), the error message would start with [Test explosive code] thenThrownBy(() -> { throw new IOException("boom!") }, "Test explosive code") .isInstanceOf(IOException.class) .hasMessageContaining("boom"); }
ThrowingCallable
does not raise an exception, an error is immediately thrown.The test description provided is honored but not the one with
as(String, Object...)
, example:// assertion will fail but "display me" won't appear in the error message thenThrownBy(() -> {}).as("display me") .isInstanceOf(Exception.class); // assertion will fail AND "display me" will appear in the error message thenThrownBy(() -> {}, "display me") .isInstanceOf(Exception.class);
- Parameters:
shouldRaiseThrowable
- TheThrowableAssert.ThrowingCallable
or lambda with the code that should raise the throwable.description
- the new description to set.args
- optional parameter if description is a format String.- Returns:
- the created
ThrowableAssert
. - Since:
- 3.9.0
-
thenCode
public ThrowableAssert thenCode(ThrowableAssert.ThrowingCallable shouldRaiseOrNotThrowable)
Deprecated.Allows to capture and then assert on aThrowable
more easily when used with Java 8 lambdas.Example :
Contrary toThrowingCallable callable = () -> { throw new Exception("boom!"); }; // assertion succeeds thenCode(callable).isInstanceOf(Exception.class) .hasMessageContaining("boom"); // assertion fails thenCode(callable).doesNotThrowAnyException();
thenThrownBy(ThrowingCallable)
the test description provided withas(String, Object...)
is always honored as shown below.ThrowingCallable doNothing = () -> { // do nothing }; // assertion fails and "display me" appears in the assertion error thenCode(doNothing).as("display me") .isInstanceOf(Exception.class);
This method was not named
then
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
-
then
public static UriAssert then(URI actual)
Deprecated.Creates a new instance of
.UriAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static UrlAssert then(URL actual)
Deprecated.Creates a new instance of
.UrlAssert
- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
-
then
public static <T extends AssertDelegateTarget> T then(T assertion)
Deprecated.Returns the given assertion. This method improves code readability by surrounding the given assertion withthen
.Consider for example the following MyButton and MyButtonAssert classes:
As MyButtonAssert implements AssertDelegateTarget, you can usepublic class MyButton extends JButton { private boolean blinking; public boolean isBlinking() { return this.blinking; } public void setBlinking(boolean blink) { this.blinking = blink; } } private static class MyButtonAssert implements AssertDelegateTarget { private MyButton button; MyButtonAssert(MyButton button) { this.button = button; } void isBlinking() { // standard assertion from core Assertions.then then(button.isBlinking()).isTrue(); } void isNotBlinking() { // standard assertion from core Assertions.then then(button.isBlinking()).isFalse(); } }
then(buttonAssert).isBlinking();
instead ofbuttonAssert.isBlinking();
to have easier to read assertions:@Test public void AssertDelegateTarget_example() { MyButton button = new MyButton(); MyButtonAssert buttonAssert = new MyButtonAssert(button); // you can encapsulate MyButtonAssert assertions methods within then then(buttonAssert).isNotBlinking(); // same as : buttonAssert.isNotBlinking(); button.setBlinking(true); then(buttonAssert).isBlinking(); // same as : buttonAssert.isBlinking(); }
- Type Parameters:
T
- the generic type of the user-defined assert.- Parameters:
assertion
- the assertion to return.- Returns:
- the given assertion.
-
then
public static <T> T then(AssertProvider<T> component)
Deprecated.Delegates the creation of theAssert
to theAssertProvider.assertThat()
of the given component.Read the comments on
AssertProvider
for an example of its usage.- Type Parameters:
T
- the AssertProvider wrapped type.- Parameters:
component
- the component that creates its own assert- Returns:
- the associated
Assert
of the given component
-
thenObject
public static <T> ObjectAssert<T> thenObject(T actual)
Deprecated.Creates a new instance of
for any object.ObjectAssert
This overload is useful, when an overloaded method of then(...) takes precedence over the generic
then(Object)
. Example:Cast necessary because
then(List)
"forgets" actual type:
No cast needed, but also no additional list assertions:then(new LinkedList<>(asList("abc"))).matches(list -> ((Deque<String>) list).getFirst().equals("abc"));
thenObject(new LinkedList<>(asList("abc"))).matches(list -> list.getFirst().equals("abc"));
- Type Parameters:
T
- the type of the actual value.- Parameters:
actual
- the actual value.- Returns:
- the created assertion object.
- Since:
- 3.12.0
-
-