1 /** 2 * Copyright the original author or authors. 3 * 4 * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (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.mozilla.org/MPL/MPL-1.1.html 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 import org.as2lib.core.BasicInterface; 18 import org.as2lib.test.mock.MethodCallRange; 19 import org.as2lib.test.mock.MethodCall; 20 import org.as2lib.test.mock.MethodResponse; 21 import org.as2lib.test.mock.ArgumentsMatcher; 22 23 /** 24 * {@code MethodBehavior} stores the expected and actual behaviors of one method 25 * and verifies the expectation against the actual method calls. 26 * 27 * @author Simon Wacker 28 */ 29 interface org.as2lib.test.mock.MethodBehavior extends BasicInterface { 30 31 /** 32 * Returns the expected method call. 33 * 34 * @return the expected method call 35 */ 36 public function getExpectedMethodCall(Void):MethodCall; 37 38 /** 39 * Adds a new actual method call. 40 * 41 * @param actualMethodCall the new actual method call 42 * @throws AssertionFailedError if the maximum number of expected actual method 43 * calls has been passed 44 */ 45 public function addActualMethodCall(actualMethodCall:MethodCall):Void; 46 47 /** 48 * Adds the new {@code methodResponse} together with the {@code methodCallRange} 49 * that indicates when and how often the response shall take place. 50 * 51 * <p>If you set no response, the behavior expects exactly one method call. 52 * 53 * @param methodResponse the response to do a given number of times 54 * @param methodCallRange the range that indicates how often the response can take 55 * place 56 */ 57 public function addMethodResponse(methodResponse:MethodResponse, methodCallRange:MethodCallRange):Void; 58 59 /** 60 * Sets the passed-in {@code argumentsMatcher} for the expected method call. 61 * 62 * @param argumentsMatcher the arguments matcher for the expected method call 63 */ 64 public function setArgumentsMatcher(argumentsMatcher:ArgumentsMatcher):Void; 65 66 /** 67 * Checks whether this behavior expects another method call. 68 * 69 * @return {@code true} if a further method call is expected else {@code false} 70 */ 71 public function expectsAnotherMethodCall(Void):Boolean; 72 73 /** 74 * Responses depending on the current number of actual method calls. 75 * 76 * @return the response's return value 77 * @throw the response's throwable 78 */ 79 public function response(Void); 80 81 /** 82 * Verifies that the expactations have been met. 83 * 84 * @throws AssertionFailedError if the verification fails 85 */ 86 public function verify(Void):Void; 87 88 }