public class Invocation extends Object
Delegate
classes.
With the Mockups API, it can appear in @Mock
methods.Modifier | Constructor and Description |
---|---|
protected |
Invocation(Object invokedInstance,
Object[] invokedArguments,
int invocationCount,
int minInvocations,
int maxInvocations)
For internal use only.
|
Modifier and Type | Method and Description |
---|---|
int |
getInvocationCount()
Returns the current invocation count.
|
int |
getInvocationIndex()
Returns the index for the current invocation.
|
Object[] |
getInvokedArguments()
Returns the actual argument values passed in the invocation to the mocked method/constructor.
|
<T> T |
getInvokedInstance()
Returns the instance on which the current invocation was made, or
null for a static method
invocation. |
<M extends Member> |
getInvokedMember()
Returns the
Method or Constructor object corresponding to the mocked method or constructor,
respectively. |
int |
getMaxInvocations()
Returns the current value of the maximum invocation count for the matching expectation or mock method
(
-1 indicates that it's unlimited). |
int |
getMinInvocations()
Returns the current value of the minimum invocation count associated with the matching expectation or mock method.
|
<T> T |
proceed(Object... replacementArguments)
Allows execution to proceed into the real implementation of the mocked method/constructor.
|
public final int getInvocationCount()
public final int getInvocationIndex()
getInvocationCount()
- 1.public final Object[] getInvokedArguments()
public final <T> T getInvokedInstance()
null
for a static
method
invocation.public final <M extends Member> M getInvokedMember()
Method
or Constructor
object corresponding to the mocked method or constructor,
respectively.public final int getMaxInvocations()
-1
indicates that it's unlimited).
For an expectation, this call will return the value specified through the
times or maxTimes field, if that was the case;
if not, the value will be -1
for a regular or non-strict expectation, or 1
for a strict one.
For a @Mock
method, it will return the value specified for the invocations
or maxInvocations attribute, or -1
if none.public final int getMinInvocations()
1
for a regular or strict expectation, or 0
for a non-strict one.
For a @Mock
method, it will return the value specified for the invocations
or minInvocations attribute, or 0
if none.public final <T> T proceed(Object... replacementArguments)
super
" is executed, using the original argument values; replacement arguments are not supported.
If the execution of said code throws an exception or error, it is propagated out to the caller of the mocked
constructor (even in the case of a checked exception).
Contrary to proceeding into a mocked method, it's not possible to actually execute test code inside the delegate
method after proceeding into the real constructor, nor to proceed into it more than once.T
- the return type of the mocked methodreplacementArguments
- the argument values to be passed to the real method, as replacement for the values
received by the mock method; if those received values should be passed without
replacement, then this method should be called with no valuesUnsupportedOperationException
- if attempting to proceed into a mocked method which does not belong to an
injectable mocked type nor to a dynamic
partially mocked type, into a native
method, or into a mocked constructor while passing replacement
arguments