1
2
3 package org.virtualmock.matcher;
4
5 /***
6 * An implementation of ArgMatcher that uses the equals() method to perform
7 * matching.
8 *
9 * @author Chad Woolley
10 * @version $Revision: 1.6 $
11 */
12 public class EqualsMatcher implements ArgMatcher {
13 /***
14 * Returns true if expectedArgument.equals(actualArgument).
15 *
16 * @param expectedArgument The expected argument value that was passed when
17 * the mocked call was recorded
18 * @param actualArgument The actual argument value that was passed when the
19 * class under test invoked the recorded call.
20 *
21 * @return true if expectedArgument.equals(actualArgument)
22 */
23 public boolean matches(Object expectedArgument, Object actualArgument) {
24 MatcherUtils matcherUtils = new MatcherUtils();
25
26 if (matcherUtils.areBothNull(expectedArgument, actualArgument)) {
27 return true;
28 }
29
30 if (!matcherUtils.areBothNotNull(expectedArgument, actualArgument)) {
31 return false;
32 }
33
34 return expectedArgument.equals(actualArgument);
35 }
36 }