public class ReturnsArgumentAt extends Object implements Answer<Object>, ValidableAnswer, 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) |
void |
validateFor(InvocationOnMock invocation)
Validation of the answer at stub time for the given invocation.
|
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 (LAST_ARGUMENT).public Object answer(InvocationOnMock invocation) throws Throwable
public void validateFor(InvocationOnMock invocation)
ValidableAnswerThis method will be called by Mockito.
The implementation must throw an MockitoException to indicate that this answer is not valid for the given invocation. If the validation succeed the implementation must simply return without throwing.
validateFor in interface ValidableAnswerinvocation - The stubbed invocationCopyright © 2024. All rights reserved.