Package org.assertj.core.api
Class AbstractCollectionAssert<SELF extends AbstractCollectionAssert<SELF,ACTUAL,ELEMENT,ELEMENT_ASSERT>,ACTUAL extends Collection<? extends ELEMENT>,ELEMENT,ELEMENT_ASSERT extends AbstractAssert<ELEMENT_ASSERT,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.AbstractCollectionAssert<SELF,ACTUAL,ELEMENT,ELEMENT_ASSERT>
-
- 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.
- All Implemented Interfaces:
Assert<SELF,ACTUAL>
,Descriptable<SELF>
,EnumerableAssert<SELF,ELEMENT>
,ExtensionPoints<SELF,ACTUAL>
,ObjectEnumerableAssert<SELF,ELEMENT>
- Direct Known Subclasses:
AbstractListAssert
,CollectionAssert
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,ACTUAL,ELEMENT,ELEMENT_ASSERT>
Base class for all implementations of assertions forCollection
s.- Since:
- 3.21.0
-
-
Field Summary
-
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 Modifier Constructor Description protected
AbstractCollectionAssert(ACTUAL actual, Class<?> selfType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
assertIsUnmodifiable()
private <E extends ELEMENT>
Collection<E>emptyCollection()
private void
expectUnsupportedOperationException(Runnable runnable, String method)
SELF
isUnmodifiable()
Verifies that the actual collection is unmodifiable, i.e., throws anUnsupportedOperationException
with any attempt to modify the collection.-
Methods inherited from class org.assertj.core.api.AbstractIterableAssert
allMatch, allMatch, allSatisfy, allSatisfy, anyMatch, anySatisfy, anySatisfy, are, areAtLeast, areAtLeastOne, areAtMost, areExactly, areNot, as, as, 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, describedAs, describedAs, doesNotContain, doesNotContainAnyElementsOf, doesNotContainForProxy, doesNotContainNull, doesNotContainSequence, doesNotContainSequence, doesNotContainSequenceForProxy, doesNotContainSubsequence, doesNotContainSubsequence, doesNotContainSubsequenceForProxy, doesNotHave, doesNotHaveAnyElementsOfTypes, doesNotHaveDuplicates, doesNotHaveSameClassAs, 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, has, hasAtLeastOneElementOfType, hasExactlyElementsOfTypes, hasOnlyElementsOfType, hasOnlyElementsOfTypes, hasOnlyOneElementSatisfying, hasSameClassAs, hasSameElementsAs, hasSameSizeAs, hasSameSizeAs, hasSize, hasSizeBetween, hasSizeGreaterThan, hasSizeGreaterThanOrEqualTo, hasSizeLessThan, hasSizeLessThanOrEqualTo, hasToString, have, haveAtLeast, haveAtLeastOne, haveAtMost, haveExactly, inBinary, inHexadecimal, is, isEmpty, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isNot, isNotEmpty, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNullOrEmpty, isOfAnyClassIn, isSameAs, isSubsetOf, isSubsetOf, isSubsetOfForProxy, last, last, map, map, map, navigationDescription, newAbstractIterableAssert, newAbstractIterableAssertForProxy, noneMatch, noneSatisfy, noneSatisfy, overridingErrorMessage, satisfiesExactly, satisfiesExactly, satisfiesExactlyForProxy, satisfiesExactlyInAnyOrder, satisfiesExactlyInAnyOrder, satisfiesExactlyInAnyOrderForProxy, singleElement, singleElement, size, startsWith, startsWithForProxy, toAssert, usingComparator, usingComparator, usingComparatorForElementFieldsWithNames, usingComparatorForElementFieldsWithType, usingComparatorForType, usingComparisonStrategy, usingDefaultComparator, usingDefaultElementComparator, usingElementComparator, usingElementComparatorIgnoringFields, usingElementComparatorOnFields, usingFieldByFieldElementComparator, usingRecursiveComparison, usingRecursiveComparison, usingRecursiveFieldByFieldElementComparator, usingRecursiveFieldByFieldElementComparator, usingRecursiveFieldByFieldElementComparatorIgnoringFields, usingRecursiveFieldByFieldElementComparatorOnFields, withAssertionState, withComparatorsForElementPropertyOrFieldNames, withComparatorsForElementPropertyOrFieldTypes, withFailMessage, withIterables, withThreadDumpOnError, 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, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, 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
-
-
-
-
Method Detail
-
isUnmodifiable
public SELF isUnmodifiable()
Verifies that the actual collection is unmodifiable, i.e., throws anUnsupportedOperationException
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:
this
assertion object.- Throws:
AssertionError
- if the actual collection is modifiable.- See Also:
Collections.unmodifiableCollection(Collection)
,Collections.unmodifiableList(List)
,Collections.unmodifiableSet(Set)
-
assertIsUnmodifiable
private void assertIsUnmodifiable()
-
expectUnsupportedOperationException
private void expectUnsupportedOperationException(Runnable runnable, String method)
-
emptyCollection
private <E extends ELEMENT> Collection<E> emptyCollection()
-
-