Top Description Constructors Methods
org.assertj.core.api

public Class CollectionAssert<ELEMENT>

extends AbstractCollectionAssert<CollectionAssert<ELEMENT>, Collection<? extends ELEMENT>, ELEMENT, ObjectAssert<ELEMENT>>
Class Inheritance
Type Parameters
<ELEMENT>
the type of elements of the "actual" value.
Static Imports
org.assertj.core.util.Lists.newArrayList

Assertion methods for Collections.

To create an instance of this class, invoke Assertions#assertThat(Collection).

Since
3.21.0

Constructor Summary

AccessConstructor and Description
public
CollectionAssert(Collection<? extends ELEMENT> actual)

Method Summary

Modifier and TypeMethod and Description
public static <E> AbstractCollectionAssert<?, Collection<? extends E>, E, ObjectAssert<E>>
assertThatCollection(Collection<? extends E> actual)

protected CollectionAssert<ELEMENT>
newAbstractIterableAssert(Iterable<? extends ELEMENT>
the iterable used to build the concrete instance of AbstractIterableAssert
iterable
)

Implements abstract org.assertj.core.api.AbstractIterableAssert.newAbstractIterableAssert.

This methods is needed to build a new concrete instance of AbstractIterableAssert after a filtering operation is executed.
protected ObjectAssert<ELEMENT>
toAssert(ELEMENT
the element value
value
,
String
describes the element, ex: "check first element" for first(), used in assertion description.
description
)

Implements abstract org.assertj.core.api.AbstractIterableAssert.toAssert.

This method is used in navigating assertions like first(), last() and element(int) to build the assertion for the given element navigated to.
Inherited from org.assertj.core.api.AbstractCollectionAssert:
isUnmodifiable

Constructor Detail

CollectionAssertback to summary
public CollectionAssert(Collection<? extends ELEMENT> actual)

Method Detail

assertThatCollectionback to summary
public static <E> AbstractCollectionAssert<?, Collection<? extends E>, E, ObjectAssert<E>> assertThatCollection(Collection<? extends E> actual)
newAbstractIterableAssertback to summary
protected CollectionAssert<ELEMENT> newAbstractIterableAssert(Iterable<? extends ELEMENT> iterable)

Implements abstract org.assertj.core.api.AbstractIterableAssert.newAbstractIterableAssert.

Doc from org.assertj.core.api.AbstractIterableAssert.newAbstractIterableAssert.

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.

Parameters
iterable:Iterable<? extends ELEMENT>

the iterable used to build the concrete instance of AbstractIterableAssert

Returns:CollectionAssert<ELEMENT>

concrete instance of AbstractIterableAssert

Annotations
@Override
toAssertback to summary
protected ObjectAssert<ELEMENT> toAssert(ELEMENT value, String description)

Implements abstract org.assertj.core.api.AbstractIterableAssert.toAssert.

Doc from org.assertj.core.api.AbstractIterableAssert.toAssert.

This method is used in navigating assertions like first(), last() and element(int) to build the assertion for the given element navigated to.

Typical implementation is returning an ObjectAssert but it is possible to return a more specialized assertions should you know what type of elements the iterables contain.

Parameters
value:ELEMENT

the element value

description:String

describes the element, ex: "check first element" for first(), used in assertion description.

Returns:ObjectAssert<ELEMENT>

the assertion for the given element

Annotations
@Override