• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2007 Mockito contributors
3  * This program is made available under the terms of the MIT License.
4  */
5 
6 package org.mockito.invocation;
7 
8 import java.io.Serializable;
9 import java.lang.reflect.Method;
10 
11 /**
12  * An invocation on a mock.
13  *
14  * <p>
15  * A placeholder for mock, the method that was called and the arguments that were passed.
16  */
17 public interface InvocationOnMock extends Serializable {
18 
19     /**
20      * returns the mock object
21      *
22      * @return mock object
23      */
getMock()24     Object getMock();
25 
26     /**
27      * returns the method
28      *
29      * @return method
30      */
getMethod()31     Method getMethod();
32 
33     /**
34      * Returns arguments passed to the method.
35      *
36      * Vararg are expanded in this array.
37      *
38      * @return arguments
39      */
getArguments()40     Object[] getArguments();
41 
42     /**
43      * Returns casted argument at the given index.
44      *
45      * Can lookup in expanded arguments form {@link #getArguments()}.
46      *
47      * @param index argument index
48      * @return casted argument at the given index
49      * @since 2.1.0
50      */
getArgument(int index)51     <T> T getArgument(int index);
52 
53     /**
54      * calls real method
55      * <p>
56      * <b>Warning:</b> depending on the real implementation it might throw exceptions
57      *
58      * @return whatever the real method returns / throws
59      * @throws Throwable in case real method throws
60      */
callRealMethod()61     Object callRealMethod() throws Throwable;
62 }
63