org.mockito.internal.invocation
Class InvocationImpl

java.lang.Object
  extended by 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
InvocationImpl(java.lang.Object mock, MockitoMethod mockitoMethod, java.lang.Object[] args, int sequenceNumber, RealMethod realMethod)
           
 
Method Summary
 java.lang.Object callRealMethod()
          calls real method
 boolean equals(java.lang.Object o)
           
 java.lang.Object[] getArguments()
          returns arguments passed to the method
 Location getLocation()
          The place in the code where the invocation happened.
 java.lang.reflect.Method getMethod()
          returns the method
 java.lang.Object getMock()
          returns the mock object
 java.lang.Object[] getRawArguments()
          Returns unprocessed arguments whereas InvocationOnMock.getArguments() returns arguments already processed (e.g.
 int getSequenceNumber()
           
 int hashCode()
           
 void ignoreForVerification()
          Configures this invocation to be ignored for verify-no-more-invocations or verification in order.
 boolean isIgnoredForVerification()
          Informs if the invocation participates in verify-no-more-invocations or verification in order.
 boolean isVerified()
           
 void markStubbed(StubInfo stubInfo)
          Marks this invocation as stubbed.
 void markVerified()
          Marks this invocation as verified so that it will not cause verification error at Mockito.verifyNoMoreInteractions(Object...)
 StubInfo stubInfo()
           
 java.lang.String toString()
          Describes the invocation in the human friendly way.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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: InvocationOnMock
returns the mock object

Specified by:
getMock in interface InvocationOnMock
Returns:
mock object

getMethod

public java.lang.reflect.Method getMethod()
Description copied from interface: InvocationOnMock
returns the method

Specified by:
getMethod in interface InvocationOnMock
Returns:
method

getArguments

public java.lang.Object[] getArguments()
Description copied from interface: InvocationOnMock
returns arguments passed to the method

Specified by:
getArguments in interface InvocationOnMock
Returns:
arguments

isVerified

public boolean isVerified()
Specified by:
isVerified in interface VerificationAwareInvocation
Specified by:
isVerified in interface Invocation
Returns:
whether the invocation has been already verified. Needed for Mockito.verifyNoMoreInteractions(Object...)

getSequenceNumber

public int getSequenceNumber()
Specified by:
getSequenceNumber in interface Invocation
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:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Description copied from interface: DescribedInvocation
Describes the invocation in the human friendly way.

Specified by:
toString in interface PrintableInvocation
Specified by:
toString in interface DescribedInvocation
Overrides:
toString in class java.lang.Object
Returns:
the description of this invocation.

getLocation

public Location getLocation()
Description copied from interface: DescribedInvocation
The place in the code where the invocation happened.

Specified by:
getLocation in interface PrintableInvocation
Specified by:
getLocation in interface DescribedInvocation
Specified by:
getLocation in interface Invocation
Returns:
the location in code of this invocation.

getRawArguments

public java.lang.Object[] getRawArguments()
Description copied from interface: Invocation
Returns unprocessed arguments whereas InvocationOnMock.getArguments() returns arguments already processed (e.g. varargs expended, etc.).

Specified by:
getRawArguments in interface Invocation
Returns:
unprocessed arguments, exactly as provided to this invocation.

callRealMethod

public java.lang.Object callRealMethod()
                                throws java.lang.Throwable
Description copied from interface: InvocationOnMock
calls real method

Warning: depending on the real implementation it might throw exceptions

Specified by:
callRealMethod in interface InvocationOnMock
Returns:
whatever the real method returns / throws
Throws:
java.lang.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 at Mockito.verifyNoMoreInteractions(Object...)

Specified by:
markVerified in interface Invocation

stubInfo

public StubInfo stubInfo()
Specified by:
stubInfo in interface Invocation
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: Invocation
Marks this invocation as stubbed.

Specified by:
markStubbed in interface Invocation
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 interface Invocation
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 also Invocation.isIgnoredForVerification()

Specified by:
ignoreForVerification in interface Invocation