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 for Collections.
Since:
3.21.0
  • Constructor Details

    • AbstractCollectionAssert

      protected AbstractCollectionAssert(ACTUAL actual, Class<?> selfType)
  • Method Details

    • isUnmodifiable

      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:
      this assertion object.
      Throws:
      AssertionError - if the actual collection is modifiable.
      See Also: