|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| IExpectationSetters.java | - | - | - | - |
|
||||||||||||||
| 1 | /* | |
| 2 | * Copyright (c) 2001-2006 OFFIS, Tammo Freese. | |
| 3 | * This program is made available under the terms of the MIT License. | |
| 4 | */ | |
| 5 | package org.easymock; | |
| 6 | ||
| 7 | /** | |
| 8 | * Allows setting expectations for an associated expected invocation. | |
| 9 | * Implementations of this interface are returned by | |
| 10 | * {@link EasyMock#expect(Object)}, and by {@link EasyMock#expectLastCall()}. | |
| 11 | */ | |
| 12 | public interface IExpectationSetters<T> { | |
| 13 | ||
| 14 | /** | |
| 15 | * Sets a return value that will be returned for the expected invocation. | |
| 16 | * | |
| 17 | * @param value | |
| 18 | * the value to return. | |
| 19 | * @return this object to allow method call chaining. | |
| 20 | */ | |
| 21 | IExpectationSetters<T> andReturn(T value); | |
| 22 | ||
| 23 | /** | |
| 24 | * Sets a throwable that will be thrown for the expected invocation. | |
| 25 | * | |
| 26 | * @param throwable | |
| 27 | * the throwable to throw. | |
| 28 | * @return this object to allow method call chaining. | |
| 29 | */ | |
| 30 | IExpectationSetters<T> andThrow(Throwable throwable); | |
| 31 | ||
| 32 | /** | |
| 33 | * Sets an object that will be used to calculate the answer for the expected | |
| 34 | * invocation (either return a value, or throw an exception). | |
| 35 | * | |
| 36 | * @param answer | |
| 37 | * the object used to answer the invocation. | |
| 38 | * @return this object to allow method call chaining. | |
| 39 | */ | |
| 40 | IExpectationSetters<T> andAnswer(IAnswer<T> answer); | |
| 41 | ||
| 42 | /** | |
| 43 | * Sets a stub return value that will be returned for the expected | |
| 44 | * invocation. | |
| 45 | * | |
| 46 | * @param value | |
| 47 | * the value to return. | |
| 48 | */ | |
| 49 | void andStubReturn(Object value); | |
| 50 | ||
| 51 | /** | |
| 52 | * Sets a stub throwable that will be thrown for the expected invocation. | |
| 53 | * | |
| 54 | * @param throwable | |
| 55 | * the throwable to throw. | |
| 56 | */ | |
| 57 | void andStubThrow(Throwable throwable); | |
| 58 | ||
| 59 | /** | |
| 60 | * Sets a stub object that will be used to calculate the answer for the | |
| 61 | * expected invocation (either return a value, or throw an exception). | |
| 62 | * | |
| 63 | * @param answer | |
| 64 | * the object used to answer the invocation. | |
| 65 | */ | |
| 66 | void andStubAnswer(IAnswer<T> answer); | |
| 67 | ||
| 68 | /** | |
| 69 | * Sets stub behavior for the expected invocation (this is needed for void | |
| 70 | * methods). | |
| 71 | */ | |
| 72 | void asStub(); | |
| 73 | ||
| 74 | /** | |
| 75 | * Expect the last invocation <code>count</code> times. | |
| 76 | * | |
| 77 | * @param count | |
| 78 | * the number of invocations expected. | |
| 79 | * @return this object to allow method call chaining. | |
| 80 | */ | |
| 81 | IExpectationSetters<T> times(int count); | |
| 82 | ||
| 83 | /** | |
| 84 | * Expect the last invocation between <code>min</code> and | |
| 85 | * <code>max</code> times. | |
| 86 | * | |
| 87 | * @param min | |
| 88 | * the minimum number of invocations expected. | |
| 89 | * @param max | |
| 90 | * the maximum number of invocations expected. | |
| 91 | * @return this object to allow method call chaining. | |
| 92 | */ | |
| 93 | IExpectationSetters<T> times(int min, int max); | |
| 94 | ||
| 95 | /** | |
| 96 | * Expect the last invocation once. This is default in EasyMock. | |
| 97 | * | |
| 98 | * @return this object to allow method call chaining. | |
| 99 | */ | |
| 100 | IExpectationSetters<T> once(); | |
| 101 | ||
| 102 | /** | |
| 103 | * Expect the last invocation at least once. | |
| 104 | * | |
| 105 | * @return this object to allow method call chaining. | |
| 106 | */ | |
| 107 | IExpectationSetters<T> atLeastOnce(); | |
| 108 | ||
| 109 | /** | |
| 110 | * Expect the last invocation any times. | |
| 111 | * | |
| 112 | * @return this object to allow method call chaining. | |
| 113 | */ | |
| 114 | IExpectationSetters<T> anyTimes(); | |
| 115 | } |
|
||||||||||