ELEMENT - the type of elements of the "actual" value.public class ListAssert<ELEMENT> extends FactoryBasedNavigableListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>
Lists.
To create an instance of this class, invoke .
Assertions.assertThat(List)
iterablesactual, info, myself, objects, throwUnsupportedExceptionOnEquals| Constructor and Description |
|---|
ListAssert(DoubleStream actual) |
ListAssert(IntStream actual) |
ListAssert(List<? extends ELEMENT> actual) |
ListAssert(LongStream actual) |
ListAssert(Stream<? extends ELEMENT> actual) |
| Modifier and Type | Method and Description |
|---|---|
static 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) |
ListAssert<ELEMENT> |
isEqualTo(Object expected)
Verifies that the actual value is equal to the given one.
|
ListAssert<ELEMENT> |
isExactlyInstanceOf(Class<?> type)
Verifies that the actual value is exactly an instance of the given type.
|
ListAssert<ELEMENT> |
isInstanceOf(Class<?> type)
Verifies that the actual value is an instance of the given type.
|
ListAssert<ELEMENT> |
isInstanceOfAny(Class<?>... types)
Verifies that the actual value is an instance of any of the given types.
|
ListAssert<ELEMENT> |
isNotExactlyInstanceOf(Class<?> type)
Verifies that the actual value is not exactly an instance of given type.
|
ListAssert<ELEMENT> |
isNotInstanceOf(Class<?> type)
Verifies that the actual value is not an instance of the given type.
|
ListAssert<ELEMENT> |
isNotInstanceOfAny(Class<?>... types)
Verifies that the actual value is not an instance of any of the given types.
|
ListAssert<ELEMENT> |
isNotOfAnyClassIn(Class<?>... types)
Verifies that the actual value type is not in given types.
|
ListAssert<ELEMENT> |
isNotSameAs(Object expected)
Verifies that the actual value is not the same as the given one, ie using == comparison.
|
ListAssert<ELEMENT> |
isOfAnyClassIn(Class<?>... types)
Verifies that the actual value type is in given types.
|
ListAssert<ELEMENT> |
isSameAs(Object expected)
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) |
assertThat, toAssertas, 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, withThreadDumpOnErrorisUnmodifiableallMatch, 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, singleElement, singleElement, size, startsWith, usingComparatorForElementFieldsWithNames, usingComparatorForElementFieldsWithType, usingComparatorForType, usingElementComparatorIgnoringFields, usingElementComparatorOnFields, usingFieldByFieldElementComparator, usingRecursiveComparison, usingRecursiveComparison, usingRecursiveFieldByFieldElementComparator, usingRecursiveFieldByFieldElementComparator, usingRecursiveFieldByFieldElementComparatorIgnoringFields, usingRecursiveFieldByFieldElementComparatorOnFields, zipSatisfyareEqual, 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, withRepresentationclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitallMatch, 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, startsWithhasSameSizeAs, hasSameSizeAs, hasSize, hasSizeBetween, hasSizeGreaterThan, hasSizeGreaterThanOrEqualTo, hasSizeLessThan, hasSizeLessThanOrEqualTo, isEmpty, isNotEmpty, isNullOrEmptyaspublic ListAssert(IntStream actual)
public ListAssert(LongStream actual)
public ListAssert(DoubleStream actual)
public static <ELEMENT> ListAssert<ELEMENT> assertThatList(List<? extends ELEMENT> actual)
public static <ELEMENT> ListAssert<ELEMENT> assertThatStream(Stream<? extends ELEMENT> actual)
public static ListAssert<Double> assertThatDoubleStream(DoubleStream actual)
public static ListAssert<Long> assertThatLongStream(LongStream actual)
public static ListAssert<Integer> assertThatIntStream(IntStream actual)
protected ListAssert<ELEMENT> newAbstractIterableAssert(Iterable<? extends ELEMENT> iterable)
AbstractIterableAssertIf you create your own subclass of AbstractIterableAssert, simply returns an instance of it in this method.
newAbstractIterableAssert in class FactoryBasedNavigableListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>iterable - the iterable used to build the concrete instance of AbstractIterableAssertpublic ListAssert<ELEMENT> isEqualTo(Object expected)
AbstractAssertExample:
// 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);isEqualTo in interface Assert<ListAssert<ELEMENT>,List<? extends ELEMENT>>isEqualTo in class AbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>expected - the given value to compare the actual value to.this assertion object.public ListAssert<ELEMENT> isInstanceOf(Class<?> type)
AbstractAssertExample:
// 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);isInstanceOf in interface Assert<ListAssert<ELEMENT>,List<? extends ELEMENT>>isInstanceOf in class AbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>type - the type to check the actual value against.public ListAssert<ELEMENT> isInstanceOfAny(Class<?>... types)
AbstractAssertExample:
// 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);isInstanceOfAny in interface Assert<ListAssert<ELEMENT>,List<? extends ELEMENT>>isInstanceOfAny in class AbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>types - the types to check the actual value against.public ListAssert<ELEMENT> isOfAnyClassIn(Class<?>... types)
AbstractAssertExample:
// 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);isOfAnyClassIn in interface Assert<ListAssert<ELEMENT>,List<? extends ELEMENT>>isOfAnyClassIn in class AbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>types - the types to check the actual value against.public ListAssert<ELEMENT> isExactlyInstanceOf(Class<?> type)
AbstractAssertExample:
// 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);isExactlyInstanceOf in interface Assert<ListAssert<ELEMENT>,List<? extends ELEMENT>>isExactlyInstanceOf in class AbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>type - the type to check the actual value against.public ListAssert<ELEMENT> isNotInstanceOf(Class<?> type)
AbstractAssertExample:
// 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);isNotInstanceOf in interface Assert<ListAssert<ELEMENT>,List<? extends ELEMENT>>isNotInstanceOf in class AbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>type - the type to check the actual value against.public ListAssert<ELEMENT> isNotInstanceOfAny(Class<?>... types)
AbstractAssertExample:
// 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);isNotInstanceOfAny in interface Assert<ListAssert<ELEMENT>,List<? extends ELEMENT>>isNotInstanceOfAny in class AbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>types - the types to check the actual value against.public ListAssert<ELEMENT> isNotOfAnyClassIn(Class<?>... types)
AbstractAssertExample:
// 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);isNotOfAnyClassIn in interface Assert<ListAssert<ELEMENT>,List<? extends ELEMENT>>isNotOfAnyClassIn in class AbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>types - the types to check the actual value against.public ListAssert<ELEMENT> isNotExactlyInstanceOf(Class<?> type)
AbstractAssertExample:
// 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);isNotExactlyInstanceOf in interface Assert<ListAssert<ELEMENT>,List<? extends ELEMENT>>isNotExactlyInstanceOf in class AbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>type - the type to check the actual value against.public ListAssert<ELEMENT> isSameAs(Object expected)
AbstractAssertExample:
// 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);isSameAs in interface Assert<ListAssert<ELEMENT>,List<? extends ELEMENT>>isSameAs in class AbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>expected - the given value to compare the actual value to.this assertion object.public ListAssert<ELEMENT> isNotSameAs(Object expected)
AbstractAssertExample:
// 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);isNotSameAs in interface Assert<ListAssert<ELEMENT>,List<? extends ELEMENT>>isNotSameAs in class AbstractListAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>expected - the given value to compare the actual value to.this assertion object.protected ListAssert<ELEMENT> startsWithForProxy(ELEMENT[] sequence)
startsWithForProxy in class AbstractIterableAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>Copyright © 2025. All rights reserved.