Interface RetainAllContract<E,C extends Collection<E>>

Type Parameters:
E - The element type being tested.
C - The collection type being tested.
All Superinterfaces:
CollectionContractConfig, CollectionContractSupport<E,C>, CollectionProviderSupport<E,C>, ContractSupport<C>, ElementProviderSupport<E>, ProviderSupport<C>, SupportedMethods
All Known Subinterfaces:
CollectionContract<E,C>, ListContract<E,L>, SequencedCollectionContract<E,C>

public interface RetainAllContract<E,C extends Collection<E>> extends CollectionContractSupport<E,C>
This interface tests if a collection class has implemented the retainAll method correctly.
Since:
1.0.0
Author:
evanbergstrom
See Also:
  • Method Details

    • testRetainAllOnEmptyContainer

      @Test @DisplayName("The retainAll method can be called on an empty container") default void testRetainAllOnEmptyContainer()
      Tests that the retainAll method works on an empty container.
    • testRetainAllOnContainerWithElements

      @Test @DisplayName("The retainAll method works on a container with elements") default void testRetainAllOnContainerWithElements()
      Test that the retainAll method works on a container with elements.
    • testRetainAllOnIncompatibleObject

      @Test @DisplayName("The retainAll method works with incompatible types") default void testRetainAllOnIncompatibleObject()
      Tests that the retainAll method works with incompatible objects.
    • testRetainAllThrowsOnNullCollection

      @Test @DisplayName("The retainAll method throws on a null collection") default void testRetainAllThrowsOnNullCollection()

      Tests that the retainAll method throws on a null collection.

      Implementation Notes

      This test checks that the retainAll function throws the correct exception if it is called on a null value. IntelliJ will detect a problem when it is called with a null argument since the method declaration has a NotNull annotation. Since this is what we are trying to test, the inspection is suppressed here.

      Any implementations that use the NotNull annotation for the collection parameter may throw an IllegalArgumentException here, so either exception type is accepted.