Package org.assertj.core.api
Class ListAssert<ELEMENT>
java.lang.Object
org.assertj.core.api.AbstractAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>>
org.assertj.core.api.AbstractIterableAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>
org.assertj.core.api.AbstractCollectionAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>
org.assertj.core.api.AbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>
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
Lists.
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
iterablesFields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals -
Constructor Summary
ConstructorsConstructorDescriptionListAssert(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, i.e., 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, i.e., using == comparison.protected ListAssert<ELEMENT> newAbstractIterableAssert(Iterable<? extends ELEMENT> iterable) This method 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, toAssertMethods 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, withThreadDumpOnErrorMethods inherited from class org.assertj.core.api.AbstractCollectionAssert
isUnmodifiableMethods inherited from class org.assertj.core.api.AbstractIterableAssert
allMatch, allMatch, allSatisfy, allSatisfy, anyMatch, 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, 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, zipSatisfyMethods inherited from class org.assertj.core.api.AbstractAssert
actual, areEqual, asInstanceOf, asList, assertionError, asString, descriptionText, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, doesNotMatch, doesNotMatch, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, hashCode, hasSameHashCodeAs, hasToString, isElementOfCustomAssert, isInstanceOfSatisfying, isNull, matches, matches, newListAssertInstance, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingEquals, usingEquals, withFailMessage, withRepresentationMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.assertj.core.api.Descriptable
as, describedAsMethods inherited from interface org.assertj.core.api.EnumerableAssert
hasSameSizeAs, hasSameSizeAs, hasSize, hasSizeBetween, hasSizeGreaterThan, hasSizeGreaterThanOrEqualTo, hasSizeLessThan, hasSizeLessThanOrEqualTo, isEmpty, isNotEmpty, isNullOrEmptyMethods inherited from interface org.assertj.core.api.ObjectEnumerableAssert
allMatch, allMatch, allSatisfy, allSatisfy, anyMatch, 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, 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:AbstractIterableAssertThis method 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:
newAbstractIterableAssertin 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:AbstractAssertVerifies 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:
isEqualToin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>> - Overrides:
isEqualToin classAbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
expected- the given value to compare the actual value to.- Returns:
thisassertion object.
-
isInstanceOf
Description copied from class:AbstractAssertVerifies 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:
isInstanceOfin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>> - Overrides:
isInstanceOfin 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:AbstractAssertVerifies 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:
isInstanceOfAnyin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>> - Overrides:
isInstanceOfAnyin 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:AbstractAssertVerifies 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:
isOfAnyClassInin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>> - Overrides:
isOfAnyClassInin 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:AbstractAssertVerifies 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:
isExactlyInstanceOfin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>> - Overrides:
isExactlyInstanceOfin 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:AbstractAssertVerifies 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:
isNotInstanceOfin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>> - Overrides:
isNotInstanceOfin 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:AbstractAssertVerifies 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:
isNotInstanceOfAnyin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>> - Overrides:
isNotInstanceOfAnyin 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:AbstractAssertVerifies 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:
isNotOfAnyClassInin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>> - Overrides:
isNotOfAnyClassInin 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:AbstractAssertVerifies 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:
isNotExactlyInstanceOfin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>> - Overrides:
isNotExactlyInstanceOfin 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:AbstractAssertVerifies that the actual value is the same as the given one, i.e., 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:
isSameAsin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>> - Overrides:
isSameAsin classAbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
expected- the given value to compare the actual value to.- Returns:
thisassertion object.
-
isNotSameAs
Description copied from class:AbstractAssertVerifies that the actual value is not the same as the given one, i.e., 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:
isNotSameAsin interfaceAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>> - Overrides:
isNotSameAsin classAbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>> - Parameters:
expected- the given value to compare the actual value to.- Returns:
thisassertion object.
-
startsWithForProxy
- Overrides:
startsWithForProxyin classAbstractIterableAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>>
-