Class CollectionTester


  • public final class CollectionTester
    extends java.lang.Object
    If you want to assert that the content of two collections are equals use this tester here.
    Since:
    1.2 (13.01.2012)
    Author:
    oliver (ob@aosd.de)
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void assertEquals​(java.util.Collection<?> c1, java.util.Collection<?> c2)
      Checks if each object in collection c1 is equals to that of Collection c2.
      protected static void assertEquals​(java.util.Collection<?> c1, java.util.Collection<?> c2, java.lang.String msg)
      Assert equals.
      static void assertEquals​(java.util.List<?> l1, java.util.List<?> l2)
      Checks if each object in list l1 is equals to that of list l2.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • assertEquals

        public static void assertEquals​(java.util.Collection<?> c1,
                                        java.util.Collection<?> c2)
        Checks if each object in collection c1 is equals to that of Collection c2. If not this method will tell you which element is different. If the collection have different size this method will tell you which element is missing.

        The order of the elements is not relevant. I.e. two collections with different ordering of its elements are equals if they have both the same elements (independent from the internal ordering).

        Note: Use Lists if ordering is important.

        Parameters:
        c1 - the c1
        c2 - the c2
      • assertEquals

        protected static void assertEquals​(java.util.Collection<?> c1,
                                           java.util.Collection<?> c2,
                                           java.lang.String msg)
        Assert equals. This method is not for public use but is used by MapTester. This is the reason why this method is 'protected'.
        Parameters:
        c1 - the c1
        c2 - the c2
        msg - the msg
      • assertEquals

        public static void assertEquals​(java.util.List<?> l1,
                                        java.util.List<?> l2)
        Checks if each object in list l1 is equals to that of list l2. If not this method will tell you which element is different. If the collection have different size this method will tell you which element is missing.

        Because two lists are compared the order of the element is important. I.e. two lists with the same elements but different order are not equals.

        Parameters:
        l1 - the list 1
        l2 - the list 2