KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > mockobjects > dynamic > MockCallableAddable


1 package test.mockobjects.dynamic;
2
3 import com.mockobjects.*;
4
5 import com.mockobjects.dynamic.Callable;
6 import com.mockobjects.dynamic.CallableAddable;
7 import com.mockobjects.dynamic.Mock;
8 import com.mockobjects.util.NotImplementedException;
9
10 //Mock modified for []args
11
public class MockCallableAddable extends MockObject implements CallableAddable {
12     private ExpectationCounter myAddMatchCalls = new ExpectationCounter("com.mockobjects.dynamic.CallableAddable AddMatchCalls");
13     private ExpectationList myAddMatchParameter0Values = new ExpectationList("com.mockobjects.dynamic.CallableAddable AddMatchParameter0Values");
14     private ExpectationCounter myAddExpectCalls = new ExpectationCounter("com.mockobjects.dynamic.CallableAddable AddExpectCalls");
15     private ExpectationList myAddExpectParameter0Values = new ExpectationList("com.mockobjects.dynamic.CallableAddable AddExpectParameter0Values");
16     private ExpectationCounter myMatchesCalls = new ExpectationCounter("com.mockobjects.dynamic.CallableAddable MatchesCalls");
17     private ReturnValues myActualMatchesReturnValues = new ReturnValues(true);
18     private ExpectationList myMatchesParameter0Values = new ExpectationList("com.mockobjects.dynamic.CallableAddable MatchesParameter0Values");
19     private ExpectationList myMatchesParameter1Values = new ExpectationList("com.mockobjects.dynamic.CallableAddable MatchesParameter1Values");
20     private ExpectationCounter myGetDescriptionCalls = new ExpectationCounter("com.mockobjects.dynamic.CallableAddable GetDescriptionCalls");
21     private ReturnValues myActualGetDescriptionReturnValues = new ReturnValues(true);
22     private ExpectationCounter myCallCalls = new ExpectationCounter("com.mockobjects.dynamic.CallableAddable CallCalls");
23     private ReturnValues myActualCallReturnValues = new ReturnValues(true);
24     private ExpectationList myCallParameter0Values = new ExpectationList("com.mockobjects.dynamic.CallableAddable CallParameter0Values");
25     private ExpectationList myCallParameter1Values = new ExpectationList("com.mockobjects.dynamic.CallableAddable CallParameter1Values");
26     private ExpectationList myCallParameter2Values = new ExpectationList("com.mockobjects.dynamic.CallableAddable CallParameter2Values");
27     private ExpectationCounter myVerifyCalls = new ExpectationCounter("com.mockobjects.dynamic.CallableAddable VerifyCalls");
28
29     public void reset() {
30         throw new NotImplementedException();
31     }
32     
33     public void setExpectedAddMatchCalls(int calls) {
34         myAddMatchCalls.setExpected(calls);
35     }
36
37     public void addExpectedAddMatch(Callable arg0) {
38         myAddMatchParameter0Values.addExpected(arg0);
39     }
40
41     public void addMatch(Callable arg0) {
42         myAddMatchCalls.inc();
43         myAddMatchParameter0Values.addActual(arg0);
44     }
45
46     public void setExpectedAddExpectCalls(int calls) {
47         myAddExpectCalls.setExpected(calls);
48     }
49
50     public void addExpectedAddExpect(Callable arg0) {
51         myAddExpectParameter0Values.addExpected(arg0);
52     }
53
54     public void addExpect(Callable arg0) {
55         myAddExpectCalls.inc();
56         myAddExpectParameter0Values.addActual(arg0);
57     }
58
59     public void setExpectedMatchesCalls(int calls) {
60         myMatchesCalls.setExpected(calls);
61     }
62
63     public void addExpectedMatches(String JavaDoc arg0, Object JavaDoc[] arg1) {
64         myMatchesParameter0Values.addExpected(arg0);
65         myMatchesParameter1Values.addExpected(arg1);
66     }
67
68     public boolean matches(String JavaDoc arg0, Object JavaDoc[] arg1) {
69         myMatchesCalls.inc();
70         myMatchesParameter0Values.addActual(arg0);
71         myMatchesParameter1Values.addActual(arg1);
72
73         Object JavaDoc nextReturnValue = myActualMatchesReturnValues.getNext();
74
75         return ((Boolean JavaDoc) nextReturnValue).booleanValue();
76     }
77
78     public void setupMatches(boolean arg) {
79         myActualMatchesReturnValues.add(new Boolean JavaDoc(arg));
80     }
81
82     public void setExpectedGetDescriptionCalls(int calls) {
83         myGetDescriptionCalls.setExpected(calls);
84     }
85
86     public String JavaDoc getDescription() {
87         myGetDescriptionCalls.inc();
88
89         Object JavaDoc nextReturnValue = myActualGetDescriptionReturnValues.getNext();
90
91         return (String JavaDoc) nextReturnValue;
92     }
93
94     public void setupGetDescription(String JavaDoc arg) {
95         myActualGetDescriptionReturnValues.add(arg);
96     }
97
98     public void setExpectedCallCalls(int calls) {
99         myCallCalls.setExpected(calls);
100     }
101
102     public void addExpectedCall(Mock arg0, String JavaDoc arg1, Object JavaDoc[] arg2) {
103         myCallParameter0Values.addExpected(arg0);
104         myCallParameter1Values.addExpected(arg1);
105         myCallParameter2Values.addExpectedMany(arg2);
106     }
107
108     public Object JavaDoc call(Mock arg0, String JavaDoc arg1, Object JavaDoc[] arg2)
109         throws Throwable JavaDoc {
110         myCallCalls.inc();
111         myCallParameter0Values.addActual(arg0);
112         myCallParameter1Values.addActual(arg1);
113         myCallParameter2Values.addActualMany(arg2);
114
115         Object JavaDoc nextReturnValue = myActualCallReturnValues.getNext();
116
117         return (Object JavaDoc) nextReturnValue;
118     }
119
120     public void setupCall(Object JavaDoc arg) {
121         myActualCallReturnValues.add(arg);
122     }
123
124     public void setExpectedVerifyCalls(int calls) {
125         myVerifyCalls.setExpected(calls);
126     }
127
128     /** @deprected use verifyExpectations as this is a mockmock */
129     public void verify() {
130         myVerifyCalls.inc();
131     }
132
133     public void verifyExpectations() {
134         myAddMatchCalls.verify();
135         myAddMatchParameter0Values.verify();
136         myAddExpectCalls.verify();
137         myAddExpectParameter0Values.verify();
138         myMatchesCalls.verify();
139         myMatchesParameter0Values.verify();
140         myMatchesParameter1Values.verify();
141         myGetDescriptionCalls.verify();
142         myCallCalls.verify();
143         myCallParameter0Values.verify();
144         myCallParameter1Values.verify();
145         myCallParameter2Values.verify();
146         myVerifyCalls.verify();
147     }
148 }
149
Popular Tags