public class AssertUtils extends Object
| Constructor and Description |
|---|
AssertUtils() |
| Modifier and Type | Method and Description |
|---|---|
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,
Double tolerance,
String... ignoredProperties)
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,
Double maxDifference,
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,
Double maxDifference,
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.
|
public static <T> void assertPropertiesMatch(T expected,
T actual,
String msg)
equals() methods or when they do not implement
equals().T - The type of the objects to be comparedexpected - The expected object to compare against. Should be non-null.actual - The actual object to be compared. Should be non-null.msg - An error messagepublic static <T> void assertPropertiesMatch(String msg, T expected, T actual, String... ignoredProperties)
T - The type of the objects to be compared.msg - An error messageexpected - 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.public static <T> void assertPropertiesMatch(String msg, T expected, T actual, Double maxDifference, String... ignoredProperties)
T - The type of the objects to be compared.msg - An error messageexpected - 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.maxDifference - When matching doubles, the max roundoff difference still considered equal. If null Double.equals() is used.public static <T> void assertPropertiesMatch(String msg, T expected, T actual, List<String> ignoredProperties)
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.T - The type of the objects to be compared.msg - An error messageexpected - 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.public static <T> void assertPropertiesMatch(String msg, T expected, T actual, Double maxDifference, List<String> ignoredProperties)
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.T - The type of the objects to be compared.msg - An error messageexpected - The expected object to compare against. Should be non-null.actual - The actual object to be compared. Should be non-null.maxDifference - When matching doubles, the max roundoff difference still considered equal. If null Double.equals() is used.ignoredProperties - A list of property names to exclude from comparison.public static <T> void assertCollectionEqualsNoOrder(Collection<T> expected, Collection<T> actual, String msg)
equals() of the contained
elements. Order is ignored as well as the runtime type of the collections.T - The type of the elements in the collectionsexpected - The expected collection to compare againstactual - The actual collection to compare againstmsg - An error messagepublic static <T> void assertCollectionMatchesNoOrder(Collection<T> expected, Collection<T> actual, String msg)
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.T - The type of the elements in the collectionsexpected - The expected collection to compare againstactual - The actual collection under testmsg - An error messagepublic static <T> void assertCollectionMatchesNoOrder(String msg, Collection<T> expected, Collection<T> actual, String... ignoredProperties)
public static <T> void assertCollectionMatchesNoOrder(String msg, Collection<T> expected, Collection<T> actual, Double tolerance, String... ignoredProperties)
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.
This version takes an additional argument that specifies a tolerance for comparing doubles. When the expected and actual property is a double the absolute difference between the values has to be within the tolerance.
T - The type of elements in the collectionmsg - An error messageexpected - The expected collection to compare againstactual - The actual collection under testtolerance - The absolute tolerance between the expected and actual value of
properties that are of type double.ignoredProperties - Properties to exclude from comparisonCopyright © 2008-2013 Red Hat, Inc.. All Rights Reserved.