org.rhq.test
Class AssertUtils

java.lang.Object
  extended by org.rhq.test.AssertUtils

public class AssertUtils
extends Object


Constructor Summary
AssertUtils()
           
 
Method Summary
static
<T> void
assertCollectionEqualsNoOrder(Collection<T> expected, Collection<T> actual, String msg)
          Verifies that two collections are equal, according to the definition of equals() of the contained elements.
static
<T> void
assertCollectionMatchesNoOrder(Collection<T> expected, Collection<T> actual, String msg)
          Verifies that the two collections contain the same number of matching elements as is done in assertPropertiesMatch(String, Object, Object, String...).
static
<T> void
assertCollectionMatchesNoOrder(String msg, Collection<T> expected, Collection<T> actual, String... ignoredProperties)
           
static
<T> void
assertPropertiesMatch(String msg, T expected, T actual, List<String> ignoredProperties)
          Verifies that all public, accessible properties of the two objects are equal, excluding those specified in the ignoredProperties argument.
static
<T> void
assertPropertiesMatch(String msg, T expected, T actual, String... ignoredProperties)
           
static
<T> void
assertPropertiesMatch(T expected, T actual, String msg)
          Verifies that all public, accessible properties of the two objects are equal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AssertUtils

public AssertUtils()
Method Detail

assertPropertiesMatch

public static <T> void assertPropertiesMatch(T expected,
                                             T actual,
                                             String msg)
Verifies that all public, accessible properties of the two objects are equal. This method might be used when you want to compare two objects without using their equals() methods or when they do not implement equals().

Type Parameters:
T - The type of the objects to be compared
Parameters:
expected - The expected object to compare against. Should be non-null.
actual - The actual object to be compared. Should be non-null.
msg - An error message

assertPropertiesMatch

public static <T> void assertPropertiesMatch(String msg,
                                             T expected,
                                             T actual,
                                             String... ignoredProperties)
Type Parameters:
T - The type of the objects to be compared.
Parameters:
msg - An error message
expected - The expected object to compare against. Should be non-null.
actual - The actual object to be compared. Should be non-null.
ignoredProperties - A list of property names to exclude from comparison.

assertPropertiesMatch

public static <T> void assertPropertiesMatch(String msg,
                                             T expected,
                                             T actual,
                                             List<String> ignoredProperties)
Verifies that all public, accessible properties of the two objects are equal, excluding those specified in the ignoredProperties argument. This method might be used when you want to compare two objects without using their equals() methods or when they do not implement equals.

Type Parameters:
T - The type of the objects to be compared.
Parameters:
msg - An error message
expected - The expected object to compare against. Should be non-null.
actual - The actual object to be compared. Should be non-null.
ignoredProperties - A list of property names to exclude from comparison.

assertCollectionEqualsNoOrder

public static <T> void assertCollectionEqualsNoOrder(Collection<T> expected,
                                                     Collection<T> actual,
                                                     String msg)
Verifies that two collections are equal, according to the definition of equals() of the contained elements. Order is ignored as well as the runtime type of the collections.

Type Parameters:
T - The type of the elements in the collections
Parameters:
expected - The expected collection to compare against
actual - The actual collection to compare against
msg - An error message

assertCollectionMatchesNoOrder

public static <T> void assertCollectionMatchesNoOrder(Collection<T> expected,
                                                      Collection<T> actual,
                                                      String msg)
Verifies that the two collections contain the same number of matching elements as is done in assertPropertiesMatch(String, Object, Object, String...). If the collections differ in size, an assertion error will be thrown; otherwise, elements are compared, ignoring order. Note that all element properties are are compared in this method.

Type Parameters:
T - The type of the elements in the collections
Parameters:
expected - The expected collection to compare against
actual - The actual collection under test
msg - An error message

assertCollectionMatchesNoOrder

public static <T> void assertCollectionMatchesNoOrder(String msg,
                                                      Collection<T> expected,
                                                      Collection<T> actual,
                                                      String... ignoredProperties)


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.