Class AssertContainsSame

java.lang.Object
org.soliscode.test.assertions.collection.IterableAssertion
org.soliscode.test.assertions.collection.AssertContainsSame

public final class AssertContainsSame extends IterableAssertion

A collection of utility methods that support asserting that two collections contain the same elements. The iterators must have the same number of elements, and for each element in the iterator being tested (actual), there must be an element in the comparison iterator (expected) that returns true when the equals()` method is called.

This function should be called through the CollectionAssertions class:

   Iterable<Integer> actual = ...
   Iterable<Integer> expected = ...
   CollectionAssertions.assertContainsSame(expected, actual);
Since:
1.0.0
Author:
evanbergstrom
See Also:
  • Method Details

    • assertContainsSame

      public static void assertContainsSame(Iterable<?> expected, Iterable<?> actual)
      Test if two iterables contain the same set of elements. The elements are considered the same if the equals method returns true.
      Parameters:
      expected - The iterable with the expected set of elements.
      actual - The iterable with the actual set of elements.
      Throws:
      org.opentest4j.AssertionFailedError - if the iterable does not contain all the elements.
    • assertContainsSame

      public static void assertContainsSame(Iterable<?> expected, Iterable<?> actual, String message)
      Test if two iterables contain the same set of elements. The elements are considered the same if the equals method returns true.
      Parameters:
      expected - The iterable with the expected set of elements.
      actual - The iterable with the actual set of elements.
      message - The message to supply if the assertion fails.
      Throws:
      org.opentest4j.AssertionFailedError - if the iterable does not contain all the elements.
    • assertContainsSame

      public static void assertContainsSame(Iterable<?> expected, Iterable<?> actual, Supplier<String> messageSupplier)
      Test if two iterables contain the same set of elements. The elements are considered the same if the equals method returns true.
      Parameters:
      expected - The iterable with the expected set of elements.
      actual - The iterable with the actual set of elements.
      messageSupplier - The supplier to call top generate message to supply if the assertion fails.
      Throws:
      org.opentest4j.AssertionFailedError - if the iterable does not contain all the elements.