Package org.assertj.core.api
Class ListAssert<ELEMENT>
java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
org.assertj.core.api.AbstractIterableAssert<SELF,ACTUAL,ELEMENT,ELEMENT_ASSERT>
org.assertj.core.api.AbstractCollectionAssert<SELF,ACTUAL,ELEMENT,ELEMENT_ASSERT>
org.assertj.core.api.AbstractListAssert<SELF,ACTUAL,ELEMENT,ELEMENT_ASSERT>
org.assertj.core.api.FactoryBasedNavigableListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>
org.assertj.core.api.ListAssert<ELEMENT>
- Type Parameters:
ELEMENT
- the type of elements of the "actual" value.
- All Implemented Interfaces:
Assert<ListAssert<ELEMENT>,
,List<? extends ELEMENT>> Descriptable<ListAssert<ELEMENT>>
,EnumerableAssert<ListAssert<ELEMENT>,
,ELEMENT> ExtensionPoints<ListAssert<ELEMENT>,
,List<? extends ELEMENT>> IndexedObjectEnumerableAssert<ListAssert<ELEMENT>,
,ELEMENT> ObjectEnumerableAssert<ListAssert<ELEMENT>,
ELEMENT>
public class ListAssert<ELEMENT>
extends FactoryBasedNavigableListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>
Assertion methods for
List
s.
To create an instance of this class, invoke
.
Assertions.assertThat(List)
- Author:
- Yvonne Wang, Alex Ruiz, Joel Costigliola, Mikhail Mazursky
-
Field Summary
Fields inherited from class org.assertj.core.api.AbstractIterableAssert
iterables
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals
-
Constructor Summary
ConstructorDescriptionListAssert
(List<? extends ELEMENT> actual) ListAssert
(DoubleStream actual) ListAssert
(IntStream actual) ListAssert
(LongStream actual) ListAssert
(Stream<? extends ELEMENT> actual) -
Method Summary
Modifier and TypeMethodDescriptionstatic ListAssert<Double>
assertThatDoubleStream
(DoubleStream actual) static ListAssert<Integer>
assertThatIntStream
(IntStream actual) static <ELEMENT> ListAssert<ELEMENT>
assertThatList
(List<? extends ELEMENT> actual) static ListAssert<Long>
assertThatLongStream
(LongStream actual) static <ELEMENT> ListAssert<ELEMENT>
assertThatStream
(Stream<? extends ELEMENT> actual) Verifies that the actual value is equal to the given one.isExactlyInstanceOf
(Class<?> type) Verifies that the actual value is exactly an instance of the given type.isInstanceOf
(Class<?> type) Verifies that the actual value is an instance of the given type.isInstanceOfAny
(Class<?>... types) Verifies that the actual value is an instance of any of the given types.isNotExactlyInstanceOf
(Class<?> type) Verifies that the actual value is not exactly an instance of given type.isNotInstanceOf
(Class<?> type) Verifies that the actual value is not an instance of the given type.isNotInstanceOfAny
(Class<?>... types) Verifies that the actual value is not an instance of any of the given types.isNotOfAnyClassIn
(Class<?>... types) Verifies that the actual value type is not in given types.isNotSameAs
(Object expected) Verifies that the actual value is not the same as the given one, ie using == comparison.isOfAnyClassIn
(Class<?>... types) Verifies that the actual value type is in given types.Verifies that the actual value is the same as the given one, ie using == comparison.protected ListAssert<ELEMENT>
newAbstractIterableAssert
(Iterable<? extends ELEMENT> iterable) This methods is needed to build a new concrete instance of AbstractIterableAssert after a filtering operation is executed.protected ListAssert<ELEMENT>
startsWithForProxy
(ELEMENT[] sequence) Methods inherited from class org.assertj.core.api.FactoryBasedNavigableListAssert
assertThat, toAssert
Methods inherited from class org.assertj.core.api.AbstractListAssert
as, as, contains, describedAs, describedAs, doesNotContain, doesNotHave, doesNotHaveSameClassAs, has, has, hasSameClassAs, hasToString, is, is, isIn, isIn, isNot, isNotEqualTo, isNotIn, isNotIn, isNotNull, isSorted, isSortedAccordingTo, overridingErrorMessage, satisfies, usingComparator, usingComparator, usingComparisonStrategy, usingDefaultComparator, usingDefaultElementComparator, usingElementComparator, withFailMessage, withThreadDumpOnError
Methods inherited from class org.assertj.core.api.AbstractCollectionAssert
isUnmodifiable
Methods inherited from class org.assertj.core.api.AbstractIterableAssert
allMatch, allMatch, allSatisfy, allSatisfy, anyMatch, anySatisfy, anySatisfy, are, areAtLeast, areAtLeastOne, areAtMost, areExactly, areNot, contains, containsAll, containsAnyElementsOf, containsAnyOf, containsAnyOfForProxy, containsExactly, containsExactlyElementsOf, containsExactlyForProxy, containsExactlyInAnyOrder, containsExactlyInAnyOrderElementsOf, containsExactlyInAnyOrderForProxy, containsForProxy, containsNull, containsOnly, containsOnlyElementsOf, containsOnlyForProxy, containsOnlyNulls, containsOnlyOnce, containsOnlyOnceElementsOf, containsOnlyOnceForProxy, containsSequence, containsSequence, containsSequenceForProxy, containsSubsequence, containsSubsequence, containsSubsequenceForProxy, doesNotContain, doesNotContainAnyElementsOf, doesNotContainForProxy, doesNotContainNull, doesNotContainSequence, doesNotContainSequence, doesNotContainSequenceForProxy, doesNotContainSubsequence, doesNotContainSubsequence, doesNotContainSubsequenceForProxy, doesNotHaveAnyElementsOfTypes, doesNotHaveDuplicates, doNotHave, element, element, elements, endsWith, endsWith, endsWithForProxy, extracting, extracting, extracting, extracting, extracting, extracting, extractingForProxy, extractingResultOf, extractingResultOf, filteredOn, filteredOn, filteredOn, filteredOn, filteredOn, filteredOnAssertions, filteredOnAssertions, filteredOnNull, first, first, flatExtracting, flatExtracting, flatExtracting, flatExtracting, flatExtracting, flatExtracting, flatExtractingForProxy, flatMap, flatMap, flatMap, flatMap, getComparatorsByType, getComparatorsForElementPropertyOrFieldTypes, hasAtLeastOneElementOfType, hasExactlyElementsOfTypes, hasOnlyElementsOfType, hasOnlyElementsOfTypes, hasOnlyOneElementSatisfying, hasSameElementsAs, hasSameSizeAs, hasSameSizeAs, hasSize, hasSizeBetween, hasSizeGreaterThan, hasSizeGreaterThanOrEqualTo, hasSizeLessThan, hasSizeLessThanOrEqualTo, have, haveAtLeast, haveAtLeastOne, haveAtMost, haveExactly, inBinary, inHexadecimal, isEmpty, isNotEmpty, isNullOrEmpty, isSubsetOf, isSubsetOf, isSubsetOfForProxy, last, last, map, map, map, navigationDescription, newAbstractIterableAssertForProxy, noneMatch, noneSatisfy, noneSatisfy, satisfiesExactly, satisfiesExactly, satisfiesExactlyForProxy, satisfiesExactlyInAnyOrder, satisfiesExactlyInAnyOrder, satisfiesExactlyInAnyOrderForProxy, satisfiesOnlyOnce, satisfiesOnlyOnce, satisfiesOnlyOnceForProxy, singleElement, singleElement, size, startsWith, usingComparatorForElementFieldsWithNames, usingComparatorForElementFieldsWithType, usingComparatorForType, usingElementComparatorIgnoringFields, usingElementComparatorOnFields, usingFieldByFieldElementComparator, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, usingRecursiveFieldByFieldElementComparator, usingRecursiveFieldByFieldElementComparator, usingRecursiveFieldByFieldElementComparatorIgnoringFields, usingRecursiveFieldByFieldElementComparatorOnFields, zipSatisfy
Methods inherited from class org.assertj.core.api.AbstractAssert
areEqual, asInstanceOf, asList, assertionError, asString, descriptionText, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, hashCode, hasSameHashCodeAs, isElementOfCustomAssert, isInstanceOfSatisfying, isNull, matches, matches, newListAssertInstance, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, withFailMessage, withRepresentation
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.assertj.core.api.Descriptable
as
Methods inherited from interface org.assertj.core.api.EnumerableAssert
hasSameSizeAs, hasSameSizeAs, hasSize, hasSizeBetween, hasSizeGreaterThan, hasSizeGreaterThanOrEqualTo, hasSizeLessThan, hasSizeLessThanOrEqualTo, isEmpty, isNotEmpty, isNullOrEmpty
Methods inherited from interface org.assertj.core.api.ObjectEnumerableAssert
allMatch, allMatch, allSatisfy, allSatisfy, anyMatch, anySatisfy, anySatisfy, are, areAtLeast, areAtLeastOne, areAtMost, areExactly, areNot, contains, containsAll, containsAnyElementsOf, containsAnyOf, containsExactly, containsExactlyElementsOf, containsExactlyInAnyOrder, containsExactlyInAnyOrderElementsOf, containsNull, containsOnly, containsOnlyElementsOf, containsOnlyNulls, containsOnlyOnce, containsOnlyOnceElementsOf, containsSequence, containsSequence, containsSubsequence, containsSubsequence, doesNotContain, doesNotContainAnyElementsOf, doesNotContainNull, doesNotContainSequence, doesNotContainSequence, doesNotContainSubsequence, doesNotContainSubsequence, doesNotHaveAnyElementsOfTypes, doesNotHaveDuplicates, doNotHave, endsWith, endsWith, hasAtLeastOneElementOfType, hasExactlyElementsOfTypes, hasOnlyElementsOfType, hasOnlyElementsOfTypes, hasOnlyOneElementSatisfying, hasSameElementsAs, have, haveAtLeast, haveAtLeastOne, haveAtMost, haveExactly, isSubsetOf, isSubsetOf, noneMatch, noneSatisfy, noneSatisfy, satisfiesExactly, satisfiesExactly, satisfiesExactlyInAnyOrder, satisfiesExactlyInAnyOrder, satisfiesOnlyOnce, satisfiesOnlyOnce, startsWith
-
Constructor Details
-
ListAssert
-
ListAssert
-
ListAssert
-
ListAssert
-
ListAssert
-
-
Method Details
-
assertThatList
-
assertThatStream
-
assertThatDoubleStream
-
assertThatLongStream
-
assertThatIntStream
-
newAbstractIterableAssert
Description copied from class:AbstractIterableAssert
This methods is needed to build a new concrete instance of AbstractIterableAssert after a filtering operation is executed.If you create your own subclass of AbstractIterableAssert, simply returns an instance of it in this method.
- Overrides:
newAbstractIterableAssert
in classFactoryBasedNavigableListAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
iterable
- the iterable used to build the concrete instance of AbstractIterableAssert- Returns:
- concrete instance of AbstractIterableAssert
-
isEqualTo
Description copied from class:AbstractAssert
Verifies that the actual value is equal to the given one.Example:
// assertions succeed assertThat("abc").isEqualTo("abc"); assertThat(new HashMap<String, Integer>()).isEqualTo(new HashMap<String, Integer>()); // assertions fail assertThat("abc").isEqualTo("123"); assertThat(new ArrayList<String>()).isEqualTo(1);
- Specified by:
isEqualTo
in interfaceAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>> - Overrides:
isEqualTo
in classAbstractListAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
expected
- the given value to compare the actual value to.- Returns:
this
assertion object.
-
isInstanceOf
Description copied from class:AbstractAssert
Verifies that the actual value is an instance of the given type.Example:
// assertions succeed assertThat("abc").isInstanceOf(String.class); assertThat(new HashMap<String, Integer>()).isInstanceOf(HashMap.class); assertThat(new HashMap<String, Integer>()).isInstanceOf(Map.class); // assertions fail assertThat(1).isInstanceOf(String.class); assertThat(new ArrayList<String>()).isInstanceOf(LinkedList.class);
- Specified by:
isInstanceOf
in interfaceAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>> - Overrides:
isInstanceOf
in classAbstractListAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
type
- the type to check the actual value against.- Returns:
- this assertion object.
-
isInstanceOfAny
Description copied from class:AbstractAssert
Verifies that the actual value is an instance of any of the given types.Example:
// assertions succeed assertThat("abc").isInstanceOfAny(String.class, Integer.class); assertThat(new ArrayList<String>()).isInstanceOfAny(LinkedList.class, ArrayList.class); assertThat(new HashMap<String, Integer>()).isInstanceOfAny(TreeMap.class, Map.class); // assertions fail assertThat(1).isInstanceOfAny(Double.class, Float.class); assertThat(new ArrayList<String>()).isInstanceOfAny(LinkedList.class, Vector.class);
- Specified by:
isInstanceOfAny
in interfaceAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>> - Overrides:
isInstanceOfAny
in classAbstractListAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
types
- the types to check the actual value against.- Returns:
- this assertion object.
-
isOfAnyClassIn
Description copied from class:AbstractAssert
Verifies that the actual value type is in given types.Example:
// assertions succeed assertThat(new HashMap<String, Integer>()).isOfAnyClassIn(HashMap.class, TreeMap.class); assertThat(new ArrayList<String>()).isOfAnyClassIn(ArrayList.class, LinkedList.class); // assertions fail assertThat(new HashMap<String, Integer>()).isOfAnyClassIn(TreeMap.class, Map.class); assertThat(new ArrayList<String>()).isOfAnyClassIn(LinkedList.class, List.class);
- Specified by:
isOfAnyClassIn
in interfaceAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>> - Overrides:
isOfAnyClassIn
in classAbstractListAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
types
- the types to check the actual value against.- Returns:
- this assertion object.
-
isExactlyInstanceOf
Description copied from class:AbstractAssert
Verifies that the actual value is exactly an instance of the given type.Example:
// assertions succeed assertThat("abc").isExactlyInstanceOf(String.class); assertThat(new ArrayList<String>()).isExactlyInstanceOf(ArrayList.class); assertThat(new HashMap<String, Integer>()).isExactlyInstanceOf(HashMap.class); // assertions fail assertThat(1).isExactlyInstanceOf(String.class); assertThat(new ArrayList<String>()).isExactlyInstanceOf(List.class); assertThat(new HashMap<String, Integer>()).isExactlyInstanceOf(Map.class);
- Specified by:
isExactlyInstanceOf
in interfaceAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>> - Overrides:
isExactlyInstanceOf
in classAbstractListAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
type
- the type to check the actual value against.- Returns:
- this assertion object.
-
isNotInstanceOf
Description copied from class:AbstractAssert
Verifies that the actual value is not an instance of the given type.Example:
// assertions succeed assertThat(1).isNotInstanceOf(Double.class); assertThat(new ArrayList<String>()).isNotInstanceOf(LinkedList.class); // assertions fail assertThat("abc").isNotInstanceOf(String.class); assertThat(new HashMap<String, Integer>()).isNotInstanceOf(HashMap.class); assertThat(new HashMap<String, Integer>()).isNotInstanceOf(Map.class);
- Specified by:
isNotInstanceOf
in interfaceAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>> - Overrides:
isNotInstanceOf
in classAbstractListAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
type
- the type to check the actual value against.- Returns:
- this assertion object.
-
isNotInstanceOfAny
Description copied from class:AbstractAssert
Verifies that the actual value is not an instance of any of the given types.Example:
// assertions succeed assertThat(1).isNotInstanceOfAny(Double.class, Float.class); assertThat(new ArrayList<String>()).isNotInstanceOfAny(LinkedList.class, Vector.class); // assertions fail assertThat(1).isNotInstanceOfAny(Double.class, Integer.class); assertThat(new ArrayList<String>()).isNotInstanceOfAny(LinkedList.class, ArrayList.class); assertThat(new HashMap<String, Integer>()).isNotInstanceOfAny(TreeMap.class, Map.class);
- Specified by:
isNotInstanceOfAny
in interfaceAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>> - Overrides:
isNotInstanceOfAny
in classAbstractListAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
types
- the types to check the actual value against.- Returns:
- this assertion object.
-
isNotOfAnyClassIn
Description copied from class:AbstractAssert
Verifies that the actual value type is not in given types.Example:
// assertions succeed assertThat(new HashMap<String, Integer>()).isNotOfAnyClassIn(Map.class, TreeMap.class); assertThat(new ArrayList<String>()).isNotOfAnyClassIn(LinkedList.class, List.class); // assertions fail assertThat(new HashMap<String, Integer>()).isNotOfAnyClassIn(HashMap.class, TreeMap.class); assertThat(new ArrayList<String>()).isNotOfAnyClassIn(ArrayList.class, LinkedList.class);
- Specified by:
isNotOfAnyClassIn
in interfaceAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>> - Overrides:
isNotOfAnyClassIn
in classAbstractListAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
types
- the types to check the actual value against.- Returns:
- this assertion object.
-
isNotExactlyInstanceOf
Description copied from class:AbstractAssert
Verifies that the actual value is not exactly an instance of given type.Example:
// assertions succeed assertThat(1).isNotExactlyInstanceOf(String.class); assertThat(new ArrayList<String>()).isNotExactlyInstanceOf(List.class); assertThat(new HashMap<String, Integer>()).isNotExactlyInstanceOf(Map.class); // assertions fail assertThat("abc").isNotExactlyInstanceOf(String.class); assertThat(new ArrayList<String>()).isNotExactlyInstanceOf(ArrayList.class); assertThat(new HashMap<String, Integer>()).isNotExactlyInstanceOf(HashMap.class);
- Specified by:
isNotExactlyInstanceOf
in interfaceAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>> - Overrides:
isNotExactlyInstanceOf
in classAbstractListAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
type
- the type to check the actual value against.- Returns:
- this assertion object.
-
isSameAs
Description copied from class:AbstractAssert
Verifies that the actual value is the same as the given one, ie using == comparison.Example:
// Name is a class with first and last fields, two Names are equals if both first and last are equals. Name tyrion = new Name("Tyrion", "Lannister"); Name alias = tyrion; Name clone = new Name("Tyrion", "Lannister"); // assertions succeed: assertThat(tyrion).isSameAs(alias) .isEqualTo(clone); // assertion fails: assertThat(tyrion).isSameAs(clone);
- Specified by:
isSameAs
in interfaceAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>> - Overrides:
isSameAs
in classAbstractListAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
expected
- the given value to compare the actual value to.- Returns:
this
assertion object.
-
isNotSameAs
Description copied from class:AbstractAssert
Verifies that the actual value is not the same as the given one, ie using == comparison.Example:
// Name is a class with first and last fields, two Names are equals if both first and last are equals. Name tyrion = new Name("Tyrion", "Lannister"); Name alias = tyrion; Name clone = new Name("Tyrion", "Lannister"); // assertions succeed: assertThat(clone).isNotSameAs(tyrion) .isEqualTo(tyrion); // assertion fails: assertThat(alias).isNotSameAs(tyrion);
- Specified by:
isNotSameAs
in interfaceAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>> - Overrides:
isNotSameAs
in classAbstractListAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
expected
- the given value to compare the actual value to.- Returns:
this
assertion object.
-
startsWithForProxy
- Overrides:
startsWithForProxy
in classAbstractIterableAssert<ListAssert<ELEMENT>,
List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>>
-