Interface ForEachContract<E,I extends Iterable<E>>

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

public interface ForEachContract<E,I extends Iterable<E>> extends CollectionContractSupport<E,I>
This interface tests if a collection class has implemented the forEach() method correctly based upon the specification provided in Iterable.forEach(Consumer).
Since:
1.0
Author:
evanbergstrom
See Also:
  • Method Details

    • testForEachForEmptyCollection

      @Test @DisplayName("ForEach does not call the action for an iterable with no elements") default void testForEachForEmptyCollection()
      Tests that the Iterable.forEach(java.util.function.Consumer<? super T>) works for an empty collection.
    • testForeEachOverCollectionWithElements

      @Test @DisplayName("ForEach calls the action each element in an iterable") default void testForeEachOverCollectionWithElements()
      Tests that the forEach() works for a collection with elements.
    • testForEachWithNullAction

      @Test @DisplayName("ForEach throws a NullPointerException when called with a null action") default void testForEachWithNullAction()
      Tests that the Iterable.forEach(java.util.function.Consumer<? super T>) throws the correct exception for a null action.