patterntesting.runtime.junit
Class CollectionTester

Package class diagram package CollectionTester
java.lang.Object
  extended by patterntesting.runtime.junit.CollectionTester

public final class CollectionTester
extends 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
static void assertEquals(Collection<?> c1, Collection<?> c2)
          Checks if each object in collection c1 is equals to that of Collection c2.
protected static void assertEquals(Collection<?> c1, Collection<?> c2, String msg)
          Assert equals.
static void assertEquals(List<?> l1, 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(Collection<?> c1,
                                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 ordering is important.

Parameters:
c1 - the c1
c2 - the c2

assertEquals

protected static void assertEquals(Collection<?> c1,
                                   Collection<?> c2,
                                   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(List<?> l1,
                                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


Copyright © 2002–2014 PatternTesting Team. All rights reserved.