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:
-
Field Summary
Fields inherited from interface org.soliscode.test.contract.support.CollectionContractSupport
DEFAULT_SIZE
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
Test that theretainAll
method works on a container with elements.default void
Tests that theretainAll
method works on an empty container.default void
Tests that theretainAll
method works with incompatible objects.default void
Tests that theretainAll
method throws on a null collection.Methods inherited from interface org.soliscode.test.contract.CollectionContractConfig
permitDuplicates, permitIncompatibleTypes, permitNulls
Methods inherited from interface org.soliscode.test.contract.support.CollectionProviderSupport
provider
Methods inherited from interface org.soliscode.test.contract.support.ElementProviderSupport
elementProvider
Methods inherited from interface org.soliscode.test.SupportedMethods
supportsMethod
-
Method Details
-
testRetainAllOnEmptyContainer
@Test @DisplayName("The retainAll method can be called on an empty container") default void testRetainAllOnEmptyContainer()Tests that theretainAll
method works on an empty container. -
testRetainAllOnContainerWithElements
@Test @DisplayName("The retainAll method works on a container with elements") default void testRetainAllOnContainerWithElements()Test that theretainAll
method works on a container with elements. -
testRetainAllOnIncompatibleObject
@Test @DisplayName("The retainAll method works with incompatible types") default void testRetainAllOnIncompatibleObject()Tests that theretainAll
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 anIllegalArgumentException
here, so either exception type is accepted.
-