| 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)
|