@Test
public void paged() {
ArgumentCaptor<Integer> requestCapture = ArgumentCaptor.forClass(Integer.class);
Mockito.when(callIntList.futureCall(requestCapture.capture(), (ApiCallContext) Mockito.any()))
.thenReturn(ApiFutures.immediateFuture(Arrays.asList(0, 1, 2)))
.thenReturn(ApiFutures.immediateFuture(Arrays.asList(3, 4)))
.thenReturn(ApiFutures.immediateFuture(Collections.<Integer>emptyList()));
UnaryCallable<Integer, ListIntegersPagedResponse> callable =
FakeCallableFactory.createPagedCallable(
callIntList,
PagedCallSettings.newBuilder(new ListIntegersPagedResponseFactory()).build(),
clientContext);
Truth.assertThat(ImmutableList.copyOf(callable.call(0).iterateAll()))
.containsExactly(0, 1, 2, 3, 4)
.inOrder();
Truth.assertThat(requestCapture.getAllValues()).containsExactly(0, 2, 4).inOrder();
}