public class ReturnsElementsOf extends java.lang.Object implements Answer<java.lang.Object>
//this:
when(mock.foo()).thenReturn(1, 2, 3);
//is equivalent to:
when(mock.foo()).thenAnswer(new ReturnsElementsOf(Arrays.asList(1, 2, 3)));
Also you might better want to use the static factory there
AdditionalAnswers.returnsElementsOf(java.util.Collection)
AdditionalAnswers
Constructor and Description |
---|
ReturnsElementsOf(java.util.Collection<?> elements) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
answer(InvocationOnMock invocation) |
public java.lang.Object answer(InvocationOnMock invocation) throws java.lang.Throwable