Package org.mockito.internal.invocation
Class InvocationImpl
- java.lang.Object
-
- org.mockito.internal.invocation.InvocationImpl
-
- All Implemented Interfaces:
java.io.Serializable,PrintableInvocation,VerificationAwareInvocation,DescribedInvocation,Invocation,InvocationOnMock
public class InvocationImpl extends java.lang.Object implements Invocation, VerificationAwareInvocation
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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description InvocationImpl(java.lang.Object mock, MockitoMethod mockitoMethod, java.lang.Object[] args, int sequenceNumber, RealMethod realMethod)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectcallRealMethod()calls real methodbooleanequals(java.lang.Object o)<T> TgetArgumentAt(int index, java.lang.Class<T> clazz)Returns casted argument using positionjava.lang.Object[]getArguments()returns arguments passed to the methodLocationgetLocation()The place in the code where the invocation happened.java.lang.reflect.MethodgetMethod()returns the methodjava.lang.ObjectgetMock()returns the mock objectjava.lang.Object[]getRawArguments()Returns unprocessed arguments whereasInvocationOnMock.getArguments()returns arguments already processed (e.g.intgetSequenceNumber()inthashCode()voidignoreForVerification()Configures this invocation to be ignored for verify-no-more-invocations or verification in order.booleanisIgnoredForVerification()Informs if the invocation participates in verify-no-more-invocations or verification in order.booleanisVerified()voidmarkStubbed(StubInfo stubInfo)Marks this invocation as stubbed.voidmarkVerified()Marks this invocation as verified so that it will not cause verification error atMockito.verifyNoMoreInteractions(Object...)StubInfostubInfo()java.lang.StringtoString()Describes the invocation in the human friendly way.
-
-
-
Constructor Detail
-
InvocationImpl
public InvocationImpl(java.lang.Object mock, MockitoMethod mockitoMethod, java.lang.Object[] args, int sequenceNumber, RealMethod realMethod)
-
-
Method Detail
-
getMock
public java.lang.Object getMock()
Description copied from interface:InvocationOnMockreturns the mock object- Specified by:
getMockin interfaceInvocationOnMock- Returns:
- mock object
-
getMethod
public java.lang.reflect.Method getMethod()
Description copied from interface:InvocationOnMockreturns the method- Specified by:
getMethodin interfaceInvocationOnMock- Returns:
- method
-
getArguments
public java.lang.Object[] getArguments()
Description copied from interface:InvocationOnMockreturns arguments passed to the method- Specified by:
getArgumentsin interfaceInvocationOnMock- Returns:
- arguments
-
getArgumentAt
public <T> T getArgumentAt(int index, java.lang.Class<T> clazz)Description copied from interface:InvocationOnMockReturns casted argument using position- Specified by:
getArgumentAtin interfaceInvocationOnMock- Parameters:
index- argument positionclazz- argument type- Returns:
- casted argument on position
-
isVerified
public boolean isVerified()
- Specified by:
isVerifiedin interfaceInvocation- Specified by:
isVerifiedin interfaceVerificationAwareInvocation- Returns:
- whether the invocation has been already verified.
Needed for
Mockito.verifyNoMoreInteractions(Object...)
-
getSequenceNumber
public int getSequenceNumber()
- Specified by:
getSequenceNumberin interfaceInvocation- Returns:
- the sequence number of the Invocation. Useful to determine the order of invocations. Used by verification in order.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
Description copied from interface:DescribedInvocationDescribes the invocation in the human friendly way.- Specified by:
toStringin interfaceDescribedInvocation- Specified by:
toStringin interfacePrintableInvocation- Overrides:
toStringin classjava.lang.Object- Returns:
- the description of this invocation.
-
getLocation
public Location getLocation()
Description copied from interface:DescribedInvocationThe place in the code where the invocation happened.- Specified by:
getLocationin interfaceDescribedInvocation- Specified by:
getLocationin interfaceInvocation- Specified by:
getLocationin interfacePrintableInvocation- Returns:
- the location in code of this invocation.
-
getRawArguments
public java.lang.Object[] getRawArguments()
Description copied from interface:InvocationReturns unprocessed arguments whereasInvocationOnMock.getArguments()returns arguments already processed (e.g. varargs expended, etc.).- Specified by:
getRawArgumentsin interfaceInvocation- Returns:
- unprocessed arguments, exactly as provided to this invocation.
-
callRealMethod
public java.lang.Object callRealMethod() throws java.lang.ThrowableDescription copied from interface:InvocationOnMockcalls real methodWarning: depending on the real implementation it might throw exceptions
- Specified by:
callRealMethodin interfaceInvocationOnMock- Returns:
- whatever the real method returns / throws
- Throws:
java.lang.Throwable- in case real method throws
-
markVerified
public void markVerified()
Description copied from interface:InvocationMarks this invocation as verified so that it will not cause verification error atMockito.verifyNoMoreInteractions(Object...)- Specified by:
markVerifiedin interfaceInvocation
-
stubInfo
public StubInfo stubInfo()
- Specified by:
stubInfoin interfaceInvocation- Returns:
- the stubbing information for this invocation. May return null - this means the invocation was not stubbed.
-
markStubbed
public void markStubbed(StubInfo stubInfo)
Description copied from interface:InvocationMarks this invocation as stubbed.- Specified by:
markStubbedin interfaceInvocation- Parameters:
stubInfo- the information about stubbing.
-
isIgnoredForVerification
public boolean isIgnoredForVerification()
Description copied from interface:InvocationInforms if the invocation participates in verify-no-more-invocations or verification in order.- Specified by:
isIgnoredForVerificationin 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:InvocationConfigures this invocation to be ignored for verify-no-more-invocations or verification in order. See alsoInvocation.isIgnoredForVerification()- Specified by:
ignoreForVerificationin interfaceInvocation
-
-