Package org.mockito.internal.invocation
Class InvocationMatcher
java.lang.Object
org.mockito.internal.invocation.InvocationMatcher
- All Implemented Interfaces:
Serializable
,DescribedInvocation
,MatchableInvocation
- Direct Known Subclasses:
StubbedInvocationMatcher
public class InvocationMatcher
extends Object
implements MatchableInvocation, DescribedInvocation, Serializable
In addition to all content of the invocation, the invocation matcher contains the argument matchers. Invocation matcher is used during verification and stubbing. In those cases, the user can provide argument matchers instead of 'raw' arguments. Raw arguments are converted to 'equals' matchers anyway.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionInvocationMatcher
(Invocation invocation) InvocationMatcher
(Invocation invocation, List<ArgumentMatcher> matchers) -
Method Summary
Modifier and TypeMethodDescriptionvoid
captureArgumentsFrom
(Invocation invocation) This method is used by Mockito to implement argument captor functionality (seeArgumentCaptor
.static List
<InvocationMatcher> createFrom
(List<Invocation> invocations) The actual invocation Mockito will match against.The place in the code where the invocation happened.The argument matchers of this invocation.boolean
hasSameMethod
(Invocation candidate) Returns true if the candidate invocation has the same method (method name and parameter types)boolean
hasSimilarMethod
(Invocation candidate) similar means the same method name, same mock, unverified and: if arguments are the same cannot be overloadedboolean
matches
(Invocation candidate) Same method, mock and all arguments match.toString()
Describes the invocation in the human friendly way.
-
Constructor Details
-
InvocationMatcher
-
InvocationMatcher
-
-
Method Details
-
createFrom
-
getMethod
-
getInvocation
Description copied from interface:MatchableInvocation
The actual invocation Mockito will match against.- Specified by:
getInvocation
in interfaceMatchableInvocation
-
getMatchers
Description copied from interface:MatchableInvocation
The argument matchers of this invocation. When the invocation is declared without argument matchers (e.g. using plain arguments) Mockito still converts them intoArgumentMatcher
instances that use 'eq' matching viaArgumentMatchers.eq(Object)
.- Specified by:
getMatchers
in interfaceMatchableInvocation
-
toString
Description copied from interface:DescribedInvocation
Describes the invocation in the human friendly way.- Specified by:
toString
in interfaceDescribedInvocation
- Overrides:
toString
in classObject
- Returns:
- the description of this invocation.
-
matches
Description copied from interface:MatchableInvocation
Same method, mock and all arguments match.- Specified by:
matches
in interfaceMatchableInvocation
-
hasSimilarMethod
similar means the same method name, same mock, unverified and: if arguments are the same cannot be overloaded- Specified by:
hasSimilarMethod
in interfaceMatchableInvocation
-
hasSameMethod
Description copied from interface:MatchableInvocation
Returns true if the candidate invocation has the same method (method name and parameter types)- Specified by:
hasSameMethod
in interfaceMatchableInvocation
-
getLocation
Description copied from interface:DescribedInvocation
The place in the code where the invocation happened.- Specified by:
getLocation
in interfaceDescribedInvocation
- Returns:
- the location of the invocation.
-
captureArgumentsFrom
Description copied from interface:MatchableInvocation
This method is used by Mockito to implement argument captor functionality (seeArgumentCaptor
.Makes this instance of matchable invocation capture all arguments of provided invocation.
- Specified by:
captureArgumentsFrom
in interfaceMatchableInvocation
- Parameters:
invocation
- the invocation to capture the arguments from
-