• 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 package org.mockito.invocation;
6 
7 import org.mockito.NotExtensible;
8 
9 /**
10  * A method call on a mock object. Contains all information and state needed for the Mockito framework to operate.
11  * This API might be useful for developers who extend Mockito.
12  * <p>
13  * The javadoc does not have lots of examples or documentation because its audience is different.
14  * Vast majority of users don't need to use the Invocation. It's mostly useful for other framework authors
15  * that extend Mockito.
16  * <p>
17  * Creating own implementations of this interface is not recommended.
18  * If you are a framework integrator and you need to programmatically create instances of invocations see {@link InvocationFactory}.
19  *
20  * @since 1.9.5
21  */
22 @NotExtensible
23 public interface Invocation extends InvocationOnMock, DescribedInvocation {
24 
25     /**
26      * @return whether the invocation has been already verified.
27      * Needed for {@link org.mockito.Mockito#verifyNoMoreInteractions(Object...)}
28      */
isVerified()29     boolean isVerified();
30 
31     /**
32      * @return the sequence number of the Invocation. Useful to determine the order of invocations.
33      * Used by verification in order.
34      */
getSequenceNumber()35     int getSequenceNumber();
36 
37     /**
38      * @return the location in code of this invocation.
39      */
getLocation()40     Location getLocation();
41 
42     /**
43      * Returns unprocessed arguments whereas {@link #getArguments()} returns
44      * arguments already processed (e.g. varargs expended, etc.).
45      *
46      * @return unprocessed arguments, exactly as provided to this invocation.
47      */
getRawArguments()48     Object[] getRawArguments();
49 
50     /**
51      * Returns unprocessed arguments whereas {@link #getArguments()} returns
52      * arguments already processed (e.g. varargs expended, etc.).
53      *
54      * @return unprocessed arguments, exactly as provided to this invocation.
55      */
getRawReturnType()56     Class<?> getRawReturnType();
57 
58     /**
59      * Marks this invocation as verified so that it will not cause verification error at
60      * {@link org.mockito.Mockito#verifyNoMoreInteractions(Object...)}
61      */
markVerified()62     void markVerified();
63 
64     /**
65      * @return the stubbing information for this invocation. May return null - this means
66      * the invocation was not stubbed.
67      */
stubInfo()68     StubInfo stubInfo();
69 
70     /**
71      * Marks this invocation as stubbed.
72      *
73      * @param stubInfo the information about stubbing.
74      */
markStubbed(StubInfo stubInfo)75     void markStubbed(StubInfo stubInfo);
76 
77     /**
78      * Informs if the invocation participates in verify-no-more-invocations or verification in order.
79      *
80      * @return whether this invocation should be ignored for the purposes of
81      * verify-no-more-invocations or verification in order.
82      */
isIgnoredForVerification()83     boolean isIgnoredForVerification();
84 
85     /**
86      * Configures this invocation to be ignored for verify-no-more-invocations or verification in order.
87      * See also {@link #isIgnoredForVerification()}
88      */
ignoreForVerification()89     void ignoreForVerification();
90 }
91