org.unitils.easymock.util
Class ReflectionArgumentMatcher<T>

java.lang.Object
  extended by org.easymock.internal.matchers.Equals
      extended by 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:

Author:
Tim Ducheyne, Filip Neven
See Also:
ReflectionComparator, ReflectionComparatorMode

Constructor Summary
ReflectionArgumentMatcher(T expected, ReflectionComparatorMode... modes)
          Creates a matcher for the expected argument value.
 
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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 null
modes - the comparator modes
Method Detail

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.