org.mockito.internal.stubbing.answers
public class ReturnsArgumentAt extends Object implements Answer<Object>, Serializable
The argumentIndex represents the index in the argument array of the invocation.
If this number equals -1 then the last argument is returned.
AdditionalAnswers,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static int |
LAST_ARGUMENT |
| Constructor and Description |
|---|
ReturnsArgumentAt(int wantedArgumentPosition)
Build the identity answer to return the argument at the given position in the argument array.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
answer(InvocationOnMock invocation) |
Class<?> |
returnedTypeOnSignature(InvocationOnMock invocation) |
void |
validateIndexWithinInvocationRange(InvocationOnMock invocation) |
int |
wantedArgumentPosition() |
public static final int LAST_ARGUMENT
public ReturnsArgumentAt(int wantedArgumentPosition)
wantedArgumentPosition - The position of the argument identity to return in the invocation.
Using -1 indicates the last argument.public Object answer(InvocationOnMock invocation) throws Throwable
public int wantedArgumentPosition()
public void validateIndexWithinInvocationRange(InvocationOnMock invocation)
public Class<?> returnedTypeOnSignature(InvocationOnMock invocation)