org.unitils.easymock.util
Class ReflectionArgumentMatcher<T>
java.lang.Object
org.easymock.internal.matchers.Equals
org.unitils.easymock.util.ReflectionArgumentMatcher<T>
- All Implemented Interfaces:
- org.easymock.IArgumentMatcher
public class ReflectionArgumentMatcher<T>
- extends org.easymock.internal.matchers.Equals
An easy mock argument matcher to check whether 2 objects are equal by comparing all fields of the objects using
reflection.
The (combination of) comparator modes specify how strict the comparison must be:
- ignore defaults: compare only arguments (and inner values) that have a non default value (eg null) as exepected value
- lenient dates: do not compare actual date values, just that they both have a value or not
- lenient order: order is not important when comparing collections or arrays
- Author:
- Tim Ducheyne, Filip Neven
- See Also:
ReflectionComparator
,
ReflectionComparatorMode
Method Summary |
boolean |
matches(Object actual)
Checks whether the given actual value is equal to the expected value. |
Methods inherited from class org.easymock.internal.matchers.Equals |
appendTo, equals, getExpected, hashCode |
ReflectionArgumentMatcher
public ReflectionArgumentMatcher(T expected,
ReflectionComparatorMode... modes)
- Creates a matcher for the expected argument value.
The modes specify how to compare the expected value with the actual value.
- Parameters:
expected
- the argument value, not nullmodes
- the comparator modes
matches
public boolean matches(Object actual)
- Checks whether the given actual value is equal to the expected value.
A reflection comparator is used to compare both values. The modes determine how
strict this comparison will be.
An assertion error is thrown if expected and actual did not match. This way, a more
detailed message can be provided.
- Specified by:
matches
in interface org.easymock.IArgumentMatcher
- Overrides:
matches
in class org.easymock.internal.matchers.Equals
- Parameters:
actual
- the actual argument value
- Returns:
- true
- Throws:
AssertionError
- in case expected and actual did not match
Copyright © 2011. All Rights Reserved.