Is there any way to setup JMock's onConsecutiveCalls method to loop back to the first Action passed once it reaches the end of the list of parameters passed?
In the sample code below, I would like the mock to return true->false->true->Ad infinitum
.
Mock setup:
final MyService myServiceMocked = mockery.mock(MyService.class);
mockery.checking(new Expectations() {{
atLeast(1).of(myServiceMocked).doSomething(with(any(String.class)), with(any(String.class)));
will (onConsecutiveCalls(
returnValue(true),
returnValue(false)
));
}});
Method calling doSomething method:
...
for (String id:idList){
boolean first = getMyService().doSomething(methodParam1, someString);
boolean second = getMyService().doSomething(anotherString, id);
}
...