Class AbstractCollectionTester<E extends @Nullable Object>

java.lang.Object
junit.framework.Assert
junit.framework.TestCase
Type Parameters:
E - the element type of the collection to be tested.
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AbstractListTester, AbstractMultisetTester, AbstractQueueTester, AbstractSetTester, CollectionAddAllTester, CollectionAddTester, CollectionClearTester, CollectionContainsAllTester, CollectionContainsTester, CollectionCreationTester, CollectionEqualsTester, CollectionForEachTester, CollectionIsEmptyTester, CollectionIteratorTester, CollectionRemoveAllTester, CollectionRemoveIfTester, CollectionRemoveTester, CollectionRetainAllTester, CollectionSerializationEqualTester, CollectionSerializationTester, CollectionSizeTester, CollectionSpliteratorTester, CollectionStreamTester, CollectionToArrayTester, CollectionToStringTester

@GwtCompatible @NullMarked public abstract class AbstractCollectionTester<E extends @Nullable Object> extends AbstractContainerTester<Collection<E>, E>
Base class for collection testers.
Author:
Kevin Bourrillion
  • Field Details

  • Constructor Details

    • AbstractCollectionTester

      public AbstractCollectionTester()
  • Method Details

    • actualContents

      protected Collection<E> actualContents()
      Specified by:
      actualContents in class AbstractContainerTester<Collection<E extends @Nullable Object>, E extends @Nullable Object>
      Returns:
      the contents of the container under test, for use by expectContents(E...) and its friends.
    • resetContainer

      @CanIgnoreReturnValue protected Collection<E> resetContainer(Collection<E> newContents)
      Description copied from class: AbstractContainerTester
      Replaces the existing container under test with a new container. This is useful when a single test method needs to create multiple containers while retaining the ability to use expectContents(E...) and other convenience methods. The creation of multiple containers in a single method is discouraged in most cases, but it is vital to the iterator tests.
      Overrides:
      resetContainer in class AbstractContainerTester<Collection<E extends @Nullable Object>, E extends @Nullable Object>
      Parameters:
      newContents - the new container instance
      Returns:
      the new container instance
    • resetCollection

      protected void resetCollection()
      See Also:
    • createArrayWithNullElement

      protected E[] createArrayWithNullElement()
      Returns:
      an array of the proper size with null inserted into the middle element.
    • initCollectionWithNullElement

      protected void initCollectionWithNullElement()
    • expectNullMissingWhenNullUnsupported

      protected void expectNullMissingWhenNullUnsupported(String message)
      Equivalent to expectMissing(null) except that the call to contains(null) is permitted to throw a NullPointerException.
      Parameters:
      message - message to use upon assertion failure