• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2016 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.ArgumentMatcher;
8 
9 import java.util.List;
10 
11 /**
12  * <code>MatchableInvocation</code> wraps {@link Invocation} instance
13  * and holds argument matchers associated with that invocation.
14  * It is used during verification process:
15  *
16  * <pre class="code"><code class="java">
17  *   mock.foo();   // <- invocation
18  *   verify(mock).bar();  // <- matchable invocation
19  * </code></pre>
20  *
21  * @since 2.2.12
22  */
23 public interface MatchableInvocation extends DescribedInvocation {
24 
25     /**
26      * The actual invocation Mockito will match against.
27      *
28      * @since 2.2.12
29      */
getInvocation()30     Invocation getInvocation();
31 
32     /**
33      * The argument matchers of this invocation.
34      * When the invocation is declared without argument matchers (e.g. using plain arguments)
35      * Mockito still converts them into {@link ArgumentMatcher} instances
36      * that use 'eq' matching via {@link org.mockito.Mockito#eq(Object)}.
37      *
38      * @since 2.2.12
39      */
getMatchers()40     List<ArgumentMatcher> getMatchers();
41 
42     /**
43      * Same method, mock and all arguments match.
44      *
45      * @since 2.2.12
46      */
matches(Invocation candidate)47     boolean matches(Invocation candidate);
48 
49     /**
50      * Candidate invocation has the similar method.
51      * 'Similar' means the same method name, same mock, unverified, not overloaded, but not necessarily matching arguments
52      *
53      * @since 2.2.12
54      */
hasSimilarMethod(Invocation candidate)55     boolean hasSimilarMethod(Invocation candidate);
56 
57     /**
58      * Returns true if the candidate invocation has the same method (method name and parameter types)
59      *
60      * @since 2.2.12
61      */
hasSameMethod(Invocation candidate)62     boolean hasSameMethod(Invocation candidate);
63 
64     /**
65      * This method is used by Mockito to implement argument captor functionality (see {@link org.mockito.ArgumentCaptor}.
66      * <p>
67      * Makes this instance of matchable invocation capture all arguments of provided invocation.
68      *
69      * @param invocation the invocation to capture the arguments from
70      *
71      * @since 2.2.12
72      */
captureArgumentsFrom(Invocation invocation)73     void captureArgumentsFrom(Invocation invocation);
74 }
75