Top Description Fields Constructors Methods
org.assertj.core.api

public abstract Class AbstractCollectionAssert<SELF extends AbstractCollectionAssert<SELF, ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends Collection<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>>

extends AbstractIterableAssert<SELF extends AbstractCollectionAssert<SELF, ACTUAL, ELEMENT, ELEMENT_ASSERT>, ACTUAL extends Collection<? extends ELEMENT>, ELEMENT, ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT, ELEMENT>>
Class Inheritance
Known Direct Subclasses
org.assertj.core.api.CollectionAssert, org.assertj.core.api.AbstractListAssert
Type Parameters
<SELF>
the "self" type of this assertion class. Please read "Emulating 'self types' using Java Generics to simplify fluent API implementation" for more details.
<ACTUAL>
the type of the "actual" value.
<ELEMENT>
the type of elements of the "actual" value.
<ELEMENT_ASSERT>
used for navigational assertions to return the right assert type.
Static Imports
java.util.function.UnaryOperator.identity, org.assertj.core.error.ShouldBeUnmodifiable.shouldBeUnmodifiable

Base class for all implementations of assertions for Collections.
Since
3.21.0

Field Summary

Inherited from org.assertj.core.api.AbstractIterableAssert:
iterables

Constructor Summary

AccessConstructor and Description
protected
AbstractCollectionAssert(ACTUAL actual, Class<?> selfType)

Method Summary

Modifier and TypeMethod and Description
private void
private <E extends ELEMENT> Collection<E>
private void
public SELF

Returns:

this assertion object.
isUnmodifiable
()

Verifies that the actual collection is unmodifiable, i.e., throws an UnsupportedOperationException with any attempt to modify the collection.

Inherited from org.assertj.core.api.AbstractIterableAssert:
allMatchallMatchallSatisfyallSatisfyanyMatchanySatisfyanySatisfyareareAtLeastareAtLeastOneareAtMostareExactlyareNotasascontainscontainsAllcontainsAnyElementsOfcontainsAnyOfcontainsAnyOfForProxycontainsExactlycontainsExactlyElementsOfcontainsExactlyForProxycontainsExactlyInAnyOrdercontainsExactlyInAnyOrderElementsOfcontainsExactlyInAnyOrderForProxycontainsForProxycontainsNullcontainsOnlycontainsOnlyElementsOfcontainsOnlyForProxycontainsOnlyNullscontainsOnlyOncecontainsOnlyOnceElementsOfcontainsOnlyOnceForProxycontainsSequencecontainsSequencecontainsSequenceForProxycontainsSubsequencecontainsSubsequencecontainsSubsequenceForProxydescribedAsdescribedAsdoesNotContaindoesNotContainAnyElementsOfdoesNotContainForProxydoesNotContainNulldoesNotContainSequencedoesNotContainSequencedoesNotContainSequenceForProxydoesNotContainSubsequencedoesNotContainSubsequencedoesNotContainSubsequenceForProxydoesNotHavedoesNotHaveAnyElementsOfTypesdoesNotHaveDuplicatesdoesNotHaveSameClassAsdoNotHaveelementelementelementsendsWithendsWithendsWithForProxyextractingextractingextractingextractingextractingextractingextractingForProxyextractingResultOfextractingResultOffilteredOnfilteredOnfilteredOnfilteredOnfilteredOnfilteredOnAssertionsfilteredOnAssertionsfilteredOnNullfirstfirstflatExtractingflatExtractingflatExtractingflatExtractingflatExtractingflatExtractingflatExtractingForProxyflatMapflatMapflatMapflatMapgetComparatorsByTypegetComparatorsForElementPropertyOrFieldTypeshashasAtLeastOneElementOfTypehasExactlyElementsOfTypeshasOnlyElementsOfTypehasOnlyElementsOfTypeshasOnlyOneElementSatisfyinghasSameClassAshasSameElementsAshasSameSizeAshasSameSizeAshasSizehasSizeBetweenhasSizeGreaterThanhasSizeGreaterThanOrEqualTohasSizeLessThanhasSizeLessThanOrEqualTohasToStringhavehaveAtLeasthaveAtLeastOnehaveAtMosthaveExactlyinBinaryinHexadecimalisisEmptyisEqualToisExactlyInstanceOfisInisInisInstanceOfisInstanceOfAnyisNotisNotEmptyisNotEqualToisNotExactlyInstanceOfisNotInisNotInisNotInstanceOfisNotInstanceOfAnyisNotNullisNotOfAnyClassInisNotSameAsisNullOrEmptyisOfAnyClassInisSameAsisSubsetOfisSubsetOfisSubsetOfForProxylastlastmapmapmapnavigationDescriptionnewAbstractIterableAssertnewAbstractIterableAssertForProxynoneMatchnoneSatisfynoneSatisfyoverridingErrorMessagesatisfiesExactlysatisfiesExactlysatisfiesExactlyForProxysatisfiesExactlyInAnyOrdersatisfiesExactlyInAnyOrdersatisfiesExactlyInAnyOrderForProxysatisfiesOnlyOncesatisfiesOnlyOncesatisfiesOnlyOnceForProxysingleElementsingleElementsizestartsWithstartsWithForProxytoAssertusingComparatorusingComparatorusingComparatorForElementFieldsWithNamesusingComparatorForElementFieldsWithTypeusingComparatorForTypeusingComparisonStrategyusingDefaultComparatorusingDefaultElementComparatorusingElementComparatorusingElementComparatorIgnoringFieldsusingElementComparatorOnFieldsusingFieldByFieldElementComparatorusingRecursiveAssertionusingRecursiveAssertionusingRecursiveComparisonusingRecursiveComparisonusingRecursiveFieldByFieldElementComparatorusingRecursiveFieldByFieldElementComparatorusingRecursiveFieldByFieldElementComparatorIgnoringFieldsusingRecursiveFieldByFieldElementComparatorOnFieldswithAssertionStatewithComparatorsForElementPropertyOrFieldNameswithComparatorsForElementPropertyOrFieldTypeswithFailMessagewithIterableswithThreadDumpOnErrorwithTypeComparatorszipSatisfy

Constructor Detail

AbstractCollectionAssertback to summary
protected AbstractCollectionAssert(ACTUAL actual, Class<?> selfType)

Method Detail

assertIsUnmodifiableback to summary
private void assertIsUnmodifiable()
Annotations
@SuppressWarnings:unchecked
emptyCollectionback to summary
private <E extends ELEMENT> Collection<E> emptyCollection()
expectUnsupportedOperationExceptionback to summary
private void expectUnsupportedOperationException(Runnable runnable, String method)
isUnmodifiableback to summary
public SELF isUnmodifiable()

Verifies that the actual collection is unmodifiable, i.e., throws an UnsupportedOperationException with any attempt to modify the collection.

Example:

 // assertions will pass
assertThat(Collections.unmodifiableCollection(new ArrayList<>())).isUnmodifiable();
assertThat(Collections.unmodifiableList(new ArrayList<>())).isUnmodifiable();
assertThat(Collections.unmodifiableSet(new HashSet<>())).isUnmodifiable();

// assertions will fail
assertThat(new ArrayList<>()).isUnmodifiable();
assertThat(new HashSet<>()).isUnmodifiable();
Returns:SELF

this assertion object.

Annotations
@Beta
Exceptions
AssertionError:
if the actual collection is modifiable.
See Also
Collections#unmodifiableCollection(Collection), Collections#unmodifiableList(List), Collections#unmodifiableSet(Set)