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 MockControlState} determines most of the actual behavior of the
    25   * {@link MockControl} class.
    26   * 
    27   * <p>The actual behavior of the specific methods of this class depends largely on
    28   * the implementing class. Thus refer to these implementation classes.
    29   * 
    30   * @author Simon Wacker
    31   * @see org.as2lib.test.mock.support.ReplayState
    32   * @see org.as2lib.test.mock.support.RecordState
    33   */
    34  interface org.as2lib.test.mock.MockControlState extends BasicInterface {
    35  	
    36  	/**
    37  	 * Is called when a method is called on the mock proxy.
    38  	 *
    39  	 * @param call contains all information about the method call
    40  	 * @return the return value of the method invocation in replay state
    41  	 * @throws * if the method is set up to throw a throwable in replay state
    42  	 */
    43  	public function invokeMethod(call:MethodCall);
    44  	
    45  	/**
    46  	 * Sets a new method response.
    47  	 *
    48  	 * <dl>
    49  	 *   <dt>Record State</dt>
    50  	 *   <dd>Records that the mock object will expect the last method call the
    51  	 *       specified number of times, and will react by either returning the
    52  	 *       return value, throwing an exception or just doing nothing.</dd>
    53  	 *   <dt>Replay State</dt>
    54  	 *   <dd>Throws an {@code IllegalStateException}.</dd>
    55  	 * </dl>
    56  	 *
    57  	 * @param methodResponse handles incoming requests appropriately
    58  	 * @param methodCallRange stores the minimum and maximum quantity of method calls
    59  	 * @throws org.as2lib.env.except.IllegalArgumentException when in replay state
    60  	 */ 
    61  	public function setMethodResponse(methodResponse:MethodResponse, methodCallRange:MethodCallRange):Void;
    62  	
    63  	/**
    64  	 * Sets a new arguments matcher.
    65  	 *
    66  	 * <dl>
    67  	 *   <dt>Record State</dt>
    68  	 *   <dd>Sets the arguments matcher that will be used for the last method specified
    69  	 *       by a method call.</dd>
    70  	 *   <dt>Replay State</dt>
    71  	 *   <dd>Throws an {@code IllegalStateException}.</dd>
    72  	 * </dl>
    73  	 *
    74  	 * @param argumentsMatcher the arguments matcher to use for the specific method
    75  	 * @throws org.as2lib.env.except.IllegalArgumentException when in replay state
    76  	 */
    77  	public function setArgumentsMatcher(argumentsMatcher:ArgumentsMatcher):Void;
    78  
    79  	/**
    80  	 * Verifies the beahvior.
    81  	 *
    82  	 * <dl>
    83  	 *   <dt>Replay State</dt>
    84  	 *   <dd>Verifies that all expectations have been met.</dd>
    85  	 *   <dt>Record State</dt>
    86  	 *   <dd>Throws an {@code IllegalStateException}.</dd>
    87  	 *
    88  	 * @throws org.as2lib.test.mock.AssertionFailedError if any expectation has not
    89  	 * been met in replay state
    90  	 * @throws org.as2lib.env.except.IllegalArgumentException when in record state
    91  	 */
    92  	public function verify(Void):Void;
    93  	
    94  }