public class AssertUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
AssertUtils.BooleanCondition
A condition which must evaluate to true or false.
|
| 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.
|
static void |
timedAssertion(AssertUtils.BooleanCondition booleanCondition,
String message,
long maxWait,
TimeUnit maxWaitUnit,
long step,
TimeUnit stepUnit)
Asserts a condition evaluates to true before a timeout is reached.
|
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 comparisonpublic static void timedAssertion(AssertUtils.BooleanCondition booleanCondition, String message, long maxWait, TimeUnit maxWaitUnit, long step, TimeUnit stepUnit) throws InterruptedException
booleanCondition - the condition to evaluaremessage - the message to show if this assertion failsmaxWait - the maximum amount of time to wait before the condition evaluates to truemaxWaitUnit - the time unit for maxWaitstep - the amount of time to make the executing thread sleep between condition evaluationsstepUnit - the time unit for stepAssertionError - if the conditions does not evaluate to true before the timeout is reachedInterruptedException - if the current thread is interrupted while waitingCopyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.