@Test public void pagedByFixedSizeCollection() { 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(Arrays.asList(5, 6, 7))) .thenReturn(ApiFutures.immediateFuture(Collections.<Integer>emptyList())); FixedSizeCollection<Integer> fixedSizeCollection = FakeCallableFactory.createPagedCallable( callIntList, PagedCallSettings.newBuilder(new ListIntegersPagedResponseFactory()).build(), clientContext) .call(0) .expandToFixedSizeCollection(5); Truth.assertThat(fixedSizeCollection.getValues()).containsExactly(0, 1, 2, 3, 4).inOrder(); Truth.assertThat(fixedSizeCollection.getNextCollection().getValues()) .containsExactly(5, 6, 7) .inOrder(); Truth.assertThat(requestCapture.getAllValues()).containsExactly(0, 2, 4, 7).inOrder(); }