public class ReflectionAssert extends Object
ReflectionComparator,
ReflectionComparatorMode| Modifier and Type | Class and Description |
|---|---|
protected static class |
ReflectionAssert.OgnlTransformer
A commons collections transformer that takes an object and returns the value of the property that is
specified by the given ognl expression.
|
| Constructor and Description |
|---|
ReflectionAssert() |
| Modifier and Type | Method and Description |
|---|---|
static void |
assertAccessablePropertiesNotNull(String message,
Object object)
All fields that have a getter with the same name will be checked by an assertNotNull.
|
static void |
assertLenientEquals(Object expected,
Object actual)
Asserts that two objects are equal.
|
static void |
assertLenientEquals(String message,
Object expected,
Object actual)
Asserts that two objects are equal.
|
static void |
assertPropertiesNotNull(String message,
Object object)
All fields are checked for null values (except the static ones).
|
static void |
assertPropertyLenientEquals(String propertyName,
Collection<?> expectedPropertyValues,
Collection<?> actualObjects)
Asserts that a property of all objects in the collection are equal to the given values.
|
static void |
assertPropertyLenientEquals(String propertyName,
Object expectedPropertyValue,
Object actualObject)
Asserts that the value of a property of an object is equal to the given value.
|
static void |
assertPropertyLenientEquals(String message,
String propertyName,
Collection<?> expectedPropertyValues,
Collection<?> actualObjects)
Asserts that a property of all objects in the collection are equal to the given values.
|
static void |
assertPropertyLenientEquals(String message,
String propertyName,
Object expectedPropertyValue,
Object actualObject)
Asserts that the value of a property of an object is equal to the given value.
|
static void |
assertPropertyReflectionEquals(String propertyName,
Collection<?> expectedPropertyValues,
Collection<?> actualObjects,
ReflectionComparatorMode... modes)
Asserts that a property of all objects in the collection are equal to the given values.
|
static void |
assertPropertyReflectionEquals(String propertyName,
Object expectedPropertyValue,
Object actualObject,
ReflectionComparatorMode... modes)
Asserts that the value of a property of an object is equal to the given value.
|
static void |
assertPropertyReflectionEquals(String message,
String propertyName,
Collection<?> expectedPropertyValues,
Collection<?> actualObjects,
ReflectionComparatorMode... modes)
Asserts that a property of all objects in the collection are equal to the given values.
|
static void |
assertPropertyReflectionEquals(String message,
String propertyName,
Object expectedPropertyValue,
Object actualObject,
ReflectionComparatorMode... modes)
Asserts that the value of a property of an object is equal to the given value.
|
static void |
assertReflectionEquals(Object expected,
Object actual,
ReflectionComparatorMode... modes)
Asserts that two objects are equal.
|
static void |
assertReflectionEquals(String message,
Object expected,
Object actual,
ReflectionComparatorMode... modes)
Asserts that two objects are equal.
|
protected static String |
formatMessage(String suppliedMessage,
String specificMessage)
Formats the exception message.
|
protected static String |
getFailureMessage(String message,
Difference difference) |
protected static Object |
getProperty(Object object,
String ognlExpression)
Evaluates the given OGNL expression, and returns the corresponding property value from the given object.
|
public static void assertLenientEquals(Object expected, Object actual) throws junit.framework.AssertionFailedError
expected - the expected objectactual - the given objectjunit.framework.AssertionFailedError - when both objects are not equalspublic static void assertReflectionEquals(Object expected, Object actual, ReflectionComparatorMode... modes) throws junit.framework.AssertionFailedError
expected - the expected objectactual - the given objectmodes - the comparator modesjunit.framework.AssertionFailedError - when both objects are not equalspublic static void assertLenientEquals(String message, Object expected, Object actual) throws junit.framework.AssertionFailedError
message - a message for when the assertion failsexpected - the expected objectactual - the given objectjunit.framework.AssertionFailedError - when both objects are not equalspublic static void assertReflectionEquals(String message, Object expected, Object actual, ReflectionComparatorMode... modes) throws junit.framework.AssertionFailedError
message - a message for when the assertion failsexpected - the expected objectactual - the given objectmodes - the comparator modesjunit.framework.AssertionFailedError - when both objects are not equalsprotected static String getFailureMessage(String message, Difference difference)
message - a custom user-provided message, null if the user didn't provide a messagedifference - the difference, not nullpublic static void assertPropertyLenientEquals(String propertyName, Object expectedPropertyValue, Object actualObject) throws junit.framework.AssertionFailedError
propertyName - the property, not nullexpectedPropertyValue - the expected valueactualObject - the object that contains the propertyjunit.framework.AssertionFailedError - when both objects are not equalspublic static void assertPropertyReflectionEquals(String propertyName, Object expectedPropertyValue, Object actualObject, ReflectionComparatorMode... modes) throws junit.framework.AssertionFailedError
propertyName - the property, not nullexpectedPropertyValue - the expected valueactualObject - the object that contains the propertymodes - the comparator modesjunit.framework.AssertionFailedError - when both objects are not equalspublic static void assertPropertyLenientEquals(String message, String propertyName, Object expectedPropertyValue, Object actualObject) throws junit.framework.AssertionFailedError
message - a message for when the assertion failspropertyName - the property, not nullexpectedPropertyValue - the expected valueactualObject - the object that contains the propertyjunit.framework.AssertionFailedError - when both objects are not equalspublic static void assertPropertyReflectionEquals(String message, String propertyName, Object expectedPropertyValue, Object actualObject, ReflectionComparatorMode... modes) throws junit.framework.AssertionFailedError
message - a message for when the assertion failspropertyName - the property, not nullexpectedPropertyValue - the expected valueactualObject - the object that contains the propertymodes - the comparator modesjunit.framework.AssertionFailedError - when both objects are not equalspublic static void assertPropertyLenientEquals(String propertyName, Collection<?> expectedPropertyValues, Collection<?> actualObjects) throws junit.framework.AssertionFailedError
propertyName - the property, not nullexpectedPropertyValues - the expected valuesactualObjects - the objects that contain the propertyjunit.framework.AssertionFailedError - when both objects are not equalspublic static void assertPropertyReflectionEquals(String propertyName, Collection<?> expectedPropertyValues, Collection<?> actualObjects, ReflectionComparatorMode... modes) throws junit.framework.AssertionFailedError
propertyName - the property, not nullexpectedPropertyValues - the expected valuesactualObjects - the objects that contain the propertymodes - the comparator modesjunit.framework.AssertionFailedError - when both objects are not equalspublic static void assertPropertyLenientEquals(String message, String propertyName, Collection<?> expectedPropertyValues, Collection<?> actualObjects) throws junit.framework.AssertionFailedError
message - a message for when the assertion failspropertyName - the property, not nullexpectedPropertyValues - the expected values, not nullactualObjects - the objects that contain the propertyjunit.framework.AssertionFailedError - when both objects are not equalspublic static void assertPropertiesNotNull(String message, Object object)
message - a message for when the assertion failsobject - the object that will be checked for null values.public static void assertPropertyReflectionEquals(String message, String propertyName, Collection<?> expectedPropertyValues, Collection<?> actualObjects, ReflectionComparatorMode... modes) throws junit.framework.AssertionFailedError
message - a message for when the assertion failspropertyName - the property, not nullexpectedPropertyValues - the expected values, not nullactualObjects - the objects that contain the propertymodes - the comparator modesjunit.framework.AssertionFailedError - when both objects are not equalsprotected static String formatMessage(String suppliedMessage, String specificMessage)
suppliedMessage - the user supplied messagespecificMessage - the reasonprotected static Object getProperty(Object object, String ognlExpression)
object - The object on which the expression is evaluatedognlExpression - The OGNL expression that is evaluatedCopyright © 2016. All Rights Reserved.