01: package net.sf.mockcreator.expectable;
02:
03: import net.sf.mockcreator.utils.CompareByValue;
04:
05: /**
06: * Expects subsequent calls to methods receive the same parameter as the first
07: * call.
08: *
09: * Usage:
10: * ExpectSame es = new ExpectSame();
11: * mock.acceptFoo(es,...); ...
12: * mock.acceptBaz(...,es,...);
13: *
14: * @author dozen
15: */
16: public class ExpectSame implements ExpectableParameter {
17:
18: private boolean called = false;
19: private Object first;
20:
21: public boolean isExpected(Object actual) {
22: if (!called) {
23: called = true;
24: first = actual;
25: return true;
26: }
27:
28: return CompareByValue.equals(first, actual);
29: }
30: }
|