Class ItemGroupAssert<T>

Type Parameters:
T - the type of object implementations of this template can verify.
Direct Known Subclasses:
ArrayAssert, ObjectGroupAssert

public abstract class ItemGroupAssert<T> extends GroupAssert<T>
Understands a template for assertion methods related to groups of items (e.g. collections or arrays.)
Since:
1.3
  • Constructor Details

    • ItemGroupAssert

      public ItemGroupAssert(T actual)
      Creates a new ItemGroupAssert.
      Parameters:
      actual -
  • Method Details

    • assertContains

      protected final void assertContains(Object... objects)
      Verifies that the actual actual group of objects contains the given objects, in any order.
      Parameters:
      objects - the objects to look for.
      Throws:
      AssertionError - if the actual actual group of objects is null.
      NullPointerException - if the given array is null.
      AssertionError - if the actual actual group of objects does not contain the given objects.
    • notFoundInActual

      private Collection<Object> notFoundInActual(Object... objects)
    • assertContainsOnly

      protected final void assertContainsOnly(Object... objects)
      Verifies that the actual group of objects contains the given objects only, in any order.
      Parameters:
      objects - the objects to look for.
      Throws:
      AssertionError - if the actual group of objects is null.
      NullPointerException - if the given group of objects is null.
      AssertionError - if the actual group of objects does not contain the given objects, or if the actual group of objects contains elements other than the ones specified.
    • actualAsSet

      protected abstract Set<Object> actualAsSet()
      Returns the actual value as a Set.
      Returns:
      the actual value as a Set.
    • asSet

      protected static Set<Object> asSet(Object[] objects)
      Returns a set containing all the elements in the given array.
      Parameters:
      objects - the given array.
      Returns:
      a set containing all the elements in the given array.
    • notFoundInCopy

      private List<Object> notFoundInCopy(Set<Object> copy, Set<Object> objects)
    • failureIfExpectedElementsNotFound

      private AssertionError failureIfExpectedElementsNotFound(Collection<Object> notFound)
    • failureIfUnexpectedElementsFound

      private AssertionError failureIfUnexpectedElementsFound(Collection<Object> unexpected)
    • assertExcludes

      protected final void assertExcludes(Object... objects)
      Verifies that the actual group of objects does not contain the given objects.
      Parameters:
      objects - the objects that the group of objects should exclude.
      Throws:
      AssertionError - if the actual group of objects is null.
      NullPointerException - if the given array is null.
      AssertionError - if the actual group of objects contains any of the given objects.
    • validateIsNotNull

      protected final void validateIsNotNull(Object[] objects)
      Validates that the given array of objects is not null.
      Parameters:
      objects - the array of objects to verify.
      Throws:
      NullPointerException - if the given array of objects is null.
    • assertDoesNotHaveDuplicates

      protected final void assertDoesNotHaveDuplicates()
      Verifies that the actual group of objects does not have duplicates.
      Throws:
      AssertionError - if the actual group of objects is null.
      AssertionError - if the actual group of objects has duplicates.
    • actualAsList

      protected abstract List<Object> actualAsList()
      Returns the actual value as a List.
      Returns:
      the actual value as a List.