|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.unitils.reflectionassert.ReflectionAssert
public class ReflectionAssert
A class for asserting that 2 objects/collections are equal by comparing properties and fields of the objects/collections using reflection.
The (combination of) comparator modes specify how strict the comparison must be:
ReflectionComparator,
ReflectionComparatorMode| Nested Class Summary | |
|---|---|
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 Summary | |
|---|---|
ReflectionAssert()
|
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ReflectionAssert()
| Method Detail |
|---|
public static void assertLenientEquals(Object expected,
Object actual)
throws junit.framework.AssertionFailedError
expected - the expected objectactual - the given object
junit.framework.AssertionFailedError - when both objects are not equals
public static void assertReflectionEquals(Object expected,
Object actual,
ReflectionComparatorMode... modes)
throws junit.framework.AssertionFailedError
expected - the expected objectactual - the given objectmodes - the comparator modes
junit.framework.AssertionFailedError - when both objects are not equals
public 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 object
junit.framework.AssertionFailedError - when both objects are not equals
public 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 modes
junit.framework.AssertionFailedError - when both objects are not equals
protected 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 null
public 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 property
junit.framework.AssertionFailedError - when both objects are not equals
public 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 modes
junit.framework.AssertionFailedError - when both objects are not equals
public 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 property
junit.framework.AssertionFailedError - when both objects are not equals
public 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 modes
junit.framework.AssertionFailedError - when both objects are not equals
public 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 property
junit.framework.AssertionFailedError - when both objects are not equals
public 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 modes
junit.framework.AssertionFailedError - when both objects are not equals
public 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 property
junit.framework.AssertionFailedError - when both objects are not equals
public 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 modes
junit.framework.AssertionFailedError - when both objects are not equals
protected static String formatMessage(String suppliedMessage,
String specificMessage)
suppliedMessage - the user supplied messagespecificMessage - the reason
protected static Object getProperty(Object object,
String ognlExpression)
object - The object on which the expression is evaluatedognlExpression - The OGNL expression that is evaluated
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||