Package org.mockito.internal.invocation
Class InvocationMatcher
- java.lang.Object
-
- org.mockito.internal.invocation.InvocationMatcher
-
- All Implemented Interfaces:
java.io.Serializable,DescribedInvocation,MatchableInvocation
- Direct Known Subclasses:
StubbedInvocationMatcher
public class InvocationMatcher extends java.lang.Object implements MatchableInvocation, DescribedInvocation, java.io.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private Invocationinvocationprivate java.util.List<ArgumentMatcher<?>>matchers
-
Constructor Summary
Constructors Constructor Description InvocationMatcher(Invocation invocation)InvocationMatcher(Invocation invocation, java.util.List<ArgumentMatcher> matchers)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleanargumentsMatch(Invocation actual)private ArgumentMatcherActioncaptureArgument()voidcaptureArgumentsFrom(Invocation invocation)This method is used by Mockito to implement argument captor functionality (seeArgumentCaptor.static java.util.List<InvocationMatcher>createFrom(java.util.List<Invocation> invocations)InvocationgetInvocation()The actual invocation Mockito will match against.LocationgetLocation()The place in the code where the invocation happened.java.util.List<ArgumentMatcher>getMatchers()The argument matchers of this invocation.java.lang.reflect.MethodgetMethod()booleanhasSameMethod(Invocation candidate)Returns true if the candidate invocation has the same method (method name and parameter types)booleanhasSimilarMethod(Invocation candidate)similar means the same method name, same mock, unverified and: if arguments are the same cannot be overloadedbooleanmatches(Invocation candidate)Same method, mock and all arguments match.java.lang.StringtoString()Describes the invocation in the human friendly way.
-
-
-
Field Detail
-
invocation
private final Invocation invocation
-
matchers
private final java.util.List<ArgumentMatcher<?>> matchers
-
-
Constructor Detail
-
InvocationMatcher
public InvocationMatcher(Invocation invocation, java.util.List<ArgumentMatcher> matchers)
-
InvocationMatcher
public InvocationMatcher(Invocation invocation)
-
-
Method Detail
-
createFrom
public static java.util.List<InvocationMatcher> createFrom(java.util.List<Invocation> invocations)
-
getMethod
public java.lang.reflect.Method getMethod()
-
getInvocation
public Invocation getInvocation()
Description copied from interface:MatchableInvocationThe actual invocation Mockito will match against.- Specified by:
getInvocationin interfaceMatchableInvocation
-
getMatchers
public java.util.List<ArgumentMatcher> getMatchers()
Description copied from interface:MatchableInvocationThe argument matchers of this invocation. When the invocation is declared without argument matchers (e.g. using plain arguments) Mockito still converts them intoArgumentMatcherinstances that use 'eq' matching viaArgumentMatchers.eq(Object).- Specified by:
getMatchersin interfaceMatchableInvocation
-
toString
public java.lang.String toString()
Description copied from interface:DescribedInvocationDescribes the invocation in the human friendly way.- Specified by:
toStringin interfaceDescribedInvocation- Overrides:
toStringin classjava.lang.Object- Returns:
- the description of this invocation.
-
matches
public boolean matches(Invocation candidate)
Description copied from interface:MatchableInvocationSame method, mock and all arguments match.- Specified by:
matchesin interfaceMatchableInvocation
-
hasSimilarMethod
public boolean hasSimilarMethod(Invocation candidate)
similar means the same method name, same mock, unverified and: if arguments are the same cannot be overloaded- Specified by:
hasSimilarMethodin interfaceMatchableInvocation
-
hasSameMethod
public boolean hasSameMethod(Invocation candidate)
Description copied from interface:MatchableInvocationReturns true if the candidate invocation has the same method (method name and parameter types)- Specified by:
hasSameMethodin interfaceMatchableInvocation
-
getLocation
public Location getLocation()
Description copied from interface:DescribedInvocationThe place in the code where the invocation happened.- Specified by:
getLocationin interfaceDescribedInvocation- Returns:
- the location of the invocation.
-
captureArgumentsFrom
public void captureArgumentsFrom(Invocation invocation)
Description copied from interface:MatchableInvocationThis 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:
captureArgumentsFromin interfaceMatchableInvocation- Parameters:
invocation- the invocation to capture the arguments from
-
captureArgument
private ArgumentMatcherAction captureArgument()
-
argumentsMatch
private boolean argumentsMatch(Invocation actual)
-
-