|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
IExpectationSetters | Line # 29 | 0 | - | 0 | 0 | - |
-1.0
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
No Tests | |||
1 | /** | |
2 | * Copyright 2001-2010 the original author or authors. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | package org.easymock; | |
18 | ||
19 | /** | |
20 | * Allows setting expectations for an associated expected invocation. | |
21 | * Implementations of this interface are returned by | |
22 | * {@link EasyMock#expect(Object)}, and by {@link EasyMock#expectLastCall()}. | |
23 | * | |
24 | * @param <T> | |
25 | * type of what should be returned by this expected call | |
26 | * | |
27 | * @author OFFIS, Tammo Freese | |
28 | */ | |
29 | public interface IExpectationSetters<T> { | |
30 | ||
31 | /** | |
32 | * Sets a return value that will be returned for the expected invocation. | |
33 | * | |
34 | * @param value | |
35 | * the value to return. | |
36 | * @return this object to allow method call chaining. | |
37 | */ | |
38 | IExpectationSetters<T> andReturn(T value); | |
39 | ||
40 | /** | |
41 | * Sets a throwable that will be thrown for the expected invocation. | |
42 | * | |
43 | * @param throwable | |
44 | * the throwable to throw. | |
45 | * @return this object to allow method call chaining. | |
46 | */ | |
47 | IExpectationSetters<T> andThrow(Throwable throwable); | |
48 | ||
49 | /** | |
50 | * Sets an object that will be used to calculate the answer for the expected | |
51 | * invocation (either return a value, or throw an exception). | |
52 | * | |
53 | * @param answer | |
54 | * the object used to answer the invocation. | |
55 | * @return this object to allow method call chaining. | |
56 | */ | |
57 | IExpectationSetters<T> andAnswer(IAnswer<? extends T> answer); | |
58 | ||
59 | /** | |
60 | * Sets an object implementing the same interface as the mock. The expected | |
61 | * method call will be delegated to it with the actual arguments. The answer | |
62 | * returned by this call will then be the answer returned by the mock | |
63 | * (either return a value, or throw an exception). | |
64 | * | |
65 | * @param delegateTo | |
66 | * the object the call is delegated to. | |
67 | * @return the value returned by the delegated call. | |
68 | */ | |
69 | IExpectationSetters<T> andDelegateTo(Object delegateTo); | |
70 | ||
71 | /** | |
72 | * Sets a stub return value that will be returned for the expected | |
73 | * invocation. | |
74 | * | |
75 | * @param value | |
76 | * the value to return. | |
77 | */ | |
78 | void andStubReturn(T value); | |
79 | ||
80 | /** | |
81 | * Sets a stub throwable that will be thrown for the expected invocation. | |
82 | * | |
83 | * @param throwable | |
84 | * the throwable to throw. | |
85 | */ | |
86 | void andStubThrow(Throwable throwable); | |
87 | ||
88 | /** | |
89 | * Sets a stub object that will be used to calculate the answer for the | |
90 | * expected invocation (either return a value, or throw an exception). | |
91 | * | |
92 | * @param answer | |
93 | * the object used to answer the invocation. | |
94 | */ | |
95 | void andStubAnswer(IAnswer<? extends T> answer); | |
96 | ||
97 | /** | |
98 | * Sets a stub object implementing the same interface as the mock. The | |
99 | * expected method call will be delegated to it with the actual arguments. | |
100 | * The answer returned by this call will then be the answer returned by the | |
101 | * mock (either return a value, or throw an exception). | |
102 | * | |
103 | * @param delegateTo | |
104 | * the object the call is delegated to. | |
105 | */ | |
106 | void andStubDelegateTo(Object delegateTo); | |
107 | ||
108 | /** | |
109 | * Sets stub behavior for the expected invocation (this is needed for void | |
110 | * methods). | |
111 | */ | |
112 | void asStub(); | |
113 | ||
114 | /** | |
115 | * Expect the last invocation <code>count</code> times. | |
116 | * | |
117 | * @param count | |
118 | * the number of invocations expected. | |
119 | * @return this object to allow method call chaining. | |
120 | */ | |
121 | IExpectationSetters<T> times(int count); | |
122 | ||
123 | /** | |
124 | * Expect the last invocation between <code>min</code> and <code>max</code> | |
125 | * times. | |
126 | * | |
127 | * @param min | |
128 | * the minimum number of invocations expected. | |
129 | * @param max | |
130 | * the maximum number of invocations expected. | |
131 | * @return this object to allow method call chaining. | |
132 | */ | |
133 | IExpectationSetters<T> times(int min, int max); | |
134 | ||
135 | /** | |
136 | * Expect the last invocation once. This is default in EasyMock. | |
137 | * | |
138 | * @return this object to allow method call chaining. | |
139 | */ | |
140 | IExpectationSetters<T> once(); | |
141 | ||
142 | /** | |
143 | * Expect the last invocation at least once. | |
144 | * | |
145 | * @return this object to allow method call chaining. | |
146 | */ | |
147 | IExpectationSetters<T> atLeastOnce(); | |
148 | ||
149 | /** | |
150 | * Expect the last invocation any times. | |
151 | * | |
152 | * @return this object to allow method call chaining. | |
153 | */ | |
154 | IExpectationSetters<T> anyTimes(); | |
155 | } |
|