Package org.mockito.internal.invocation
Class InvocationImpl
java.lang.Object
org.mockito.internal.invocation.InvocationImpl
- All Implemented Interfaces:
Serializable
,PrintableInvocation
,VerificationAwareInvocation
,DescribedInvocation
,Invocation
,InvocationOnMock
Method call on a mock object.
Contains sequence number which should be globally unique and is used for verification in order.
Contains stack trace of invocation
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionInvocationImpl
(Object mock, MockitoMethod mockitoMethod, Object[] args, int sequenceNumber, RealMethod realMethod) -
Method Summary
Modifier and TypeMethodDescriptioncalls real methodboolean
<T> T
getArgumentAt
(int index, Class<T> clazz) Returns casted argument using positionObject[]
returns arguments passed to the methodThe place in the code where the invocation happened.returns the methodgetMock()
returns the mock objectObject[]
Returns unprocessed arguments whereasInvocationOnMock.getArguments()
returns arguments already processed (e.g.int
int
hashCode()
void
Configures this invocation to be ignored for verify-no-more-invocations or verification in order.boolean
Informs if the invocation participates in verify-no-more-invocations or verification in order.boolean
void
markStubbed
(StubInfo stubInfo) Marks this invocation as stubbed.void
Marks this invocation as verified so that it will not cause verification error atMockito.verifyNoMoreInteractions(Object...)
stubInfo()
toString()
Describes the invocation in the human friendly way.
-
Constructor Details
-
InvocationImpl
public InvocationImpl(Object mock, MockitoMethod mockitoMethod, Object[] args, int sequenceNumber, RealMethod realMethod)
-
-
Method Details
-
getMock
Description copied from interface:InvocationOnMock
returns the mock object- Specified by:
getMock
in interfaceInvocationOnMock
- Returns:
- mock object
-
getMethod
Description copied from interface:InvocationOnMock
returns the method- Specified by:
getMethod
in interfaceInvocationOnMock
- Returns:
- method
-
getArguments
Description copied from interface:InvocationOnMock
returns arguments passed to the method- Specified by:
getArguments
in interfaceInvocationOnMock
- Returns:
- arguments
-
getArgumentAt
Description copied from interface:InvocationOnMock
Returns casted argument using position- Specified by:
getArgumentAt
in interfaceInvocationOnMock
- Parameters:
index
- argument positionclazz
- argument type- Returns:
- casted argument on position
-
isVerified
public boolean isVerified()- Specified by:
isVerified
in interfaceInvocation
- Specified by:
isVerified
in interfaceVerificationAwareInvocation
- Returns:
- whether the invocation has been already verified.
Needed for
Mockito.verifyNoMoreInteractions(Object...)
-
getSequenceNumber
public int getSequenceNumber()- Specified by:
getSequenceNumber
in interfaceInvocation
- Returns:
- the sequence number of the Invocation. Useful to determine the order of invocations. Used by verification in order.
-
equals
-
hashCode
public int hashCode() -
toString
Description copied from interface:DescribedInvocation
Describes the invocation in the human friendly way.- Specified by:
toString
in interfaceDescribedInvocation
- Specified by:
toString
in interfacePrintableInvocation
- Overrides:
toString
in classObject
- Returns:
- the description of this invocation.
-
getLocation
Description copied from interface:DescribedInvocation
The place in the code where the invocation happened.- Specified by:
getLocation
in interfaceDescribedInvocation
- Specified by:
getLocation
in interfaceInvocation
- Specified by:
getLocation
in interfacePrintableInvocation
- Returns:
- the location in code of this invocation.
-
getRawArguments
Description copied from interface:Invocation
Returns unprocessed arguments whereasInvocationOnMock.getArguments()
returns arguments already processed (e.g. varargs expended, etc.).- Specified by:
getRawArguments
in interfaceInvocation
- Returns:
- unprocessed arguments, exactly as provided to this invocation.
-
callRealMethod
Description copied from interface:InvocationOnMock
calls real methodWarning: depending on the real implementation it might throw exceptions
- Specified by:
callRealMethod
in interfaceInvocationOnMock
- Returns:
- whatever the real method returns / throws
- Throws:
Throwable
- in case real method throws
-
markVerified
public void markVerified()Description copied from interface:Invocation
Marks this invocation as verified so that it will not cause verification error atMockito.verifyNoMoreInteractions(Object...)
- Specified by:
markVerified
in interfaceInvocation
-
stubInfo
- Specified by:
stubInfo
in interfaceInvocation
- Returns:
- the stubbing information for this invocation. May return null - this means the invocation was not stubbed.
-
markStubbed
Description copied from interface:Invocation
Marks this invocation as stubbed.- Specified by:
markStubbed
in interfaceInvocation
- Parameters:
stubInfo
- the information about stubbing.
-
isIgnoredForVerification
public boolean isIgnoredForVerification()Description copied from interface:Invocation
Informs if the invocation participates in verify-no-more-invocations or verification in order.- Specified by:
isIgnoredForVerification
in interfaceInvocation
- Returns:
- whether this invocation should be ignored for the purposes of verify-no-more-invocations or verification in order.
-
ignoreForVerification
public void ignoreForVerification()Description copied from interface:Invocation
Configures this invocation to be ignored for verify-no-more-invocations or verification in order. See alsoInvocation.isIgnoredForVerification()
- Specified by:
ignoreForVerification
in interfaceInvocation
-