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.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 forList
s.To create an instance of this class, invoke
.Assertions.assertThat(List)
- Author:
- Yvonne Wang, Alex Ruiz, Joel Costigliola, Mikhail Mazursky
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ListAssert.ListFromStream<ELEMENT,STREAM extends BaseStream<ELEMENT,STREAM>>
-
Field Summary
-
Fields inherited from class org.assertj.core.api.AbstractListAssert
lists
-
Fields inherited from class org.assertj.core.api.AbstractIterableAssert
iterables
-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, customRepresentation, info, myself, objects, printAssertionsDescription, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Constructor Description ListAssert(List<? extends ELEMENT> actual)
ListAssert(DoubleStream actual)
ListAssert(IntStream actual)
ListAssert(LongStream actual)
ListAssert(Stream<? extends ELEMENT> actual)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private AssertionError
actualDoesNotStartWithSequence(AssertionInfo info, Object[] sequence)
private ListAssert.ListFromStream
asListFromStream()
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)
-
Methods inherited from class org.assertj.core.api.FactoryBasedNavigableListAssert
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.AbstractIterableAssert
allMatch, allMatch, allSatisfy, anyMatch, 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, 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, satisfiesExactly, satisfiesExactlyForProxy, satisfiesExactlyInAnyOrder, satisfiesExactlyInAnyOrderForProxy, singleElement, singleElement, size, startsWith, usingComparatorForElementFieldsWithNames, usingComparatorForElementFieldsWithType, usingComparatorForType, usingElementComparatorIgnoringFields, usingElementComparatorOnFields, usingFieldByFieldElementComparator, usingRecursiveComparison, usingRecursiveComparison, usingRecursiveFieldByFieldElementComparator, usingRecursiveFieldByFieldElementComparator, usingRecursiveFieldByFieldElementComparatorIgnoringFields, usingRecursiveFieldByFieldElementComparatorOnFields, withAssertionState, withComparatorsForElementPropertyOrFieldNames, withComparatorsForElementPropertyOrFieldTypes, withIterables, withTypeComparators, zipSatisfy
-
Methods inherited from class org.assertj.core.api.AbstractAssert
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, satisfiesAnyOf, satisfiesAnyOfForProxy, 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, anyMatch, 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, satisfiesExactly, satisfiesExactlyInAnyOrder, startsWith
-
-
-
-
Constructor Detail
-
ListAssert
public ListAssert(IntStream actual)
-
ListAssert
public ListAssert(LongStream actual)
-
ListAssert
public ListAssert(DoubleStream actual)
-
-
Method Detail
-
newAbstractIterableAssert
protected ListAssert<ELEMENT> newAbstractIterableAssert(Iterable<? extends ELEMENT> iterable)
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
public ListAssert<ELEMENT> isEqualTo(Object expected)
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
public ListAssert<ELEMENT> isInstanceOf(Class<?> type)
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
public ListAssert<ELEMENT> isInstanceOfAny(Class<?>... types)
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
public ListAssert<ELEMENT> isOfAnyClassIn(Class<?>... types)
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
public ListAssert<ELEMENT> isExactlyInstanceOf(Class<?> type)
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
public ListAssert<ELEMENT> isNotInstanceOf(Class<?> type)
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
public ListAssert<ELEMENT> isNotInstanceOfAny(Class<?>... types)
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
public ListAssert<ELEMENT> isNotOfAnyClassIn(Class<?>... types)
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
public ListAssert<ELEMENT> isNotExactlyInstanceOf(Class<?> type)
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
public ListAssert<ELEMENT> isSameAs(Object expected)
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
public ListAssert<ELEMENT> isNotSameAs(Object expected)
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
protected ListAssert<ELEMENT> startsWithForProxy(ELEMENT[] sequence)
- Overrides:
startsWithForProxy
in classAbstractIterableAssert<ListAssert<ELEMENT>,List<? extends ELEMENT>,ELEMENT,ObjectAssert<ELEMENT>>
-
actualDoesNotStartWithSequence
private AssertionError actualDoesNotStartWithSequence(AssertionInfo info, Object[] sequence)
-
asListFromStream
private ListAssert.ListFromStream asListFromStream()
-
-