@Test
public void testFutureCallPollDoneOnMany() throws Exception {

  final int iterationsCount = 1000;
  String opName = "testFutureCallPollDoneOnMany";
  Color resp = getColor(0.5f);
  Currency meta = Currency.getInstance("UAH");
  OperationSnapshot initialOperation = getOperation(opName, null, null, null, false);
  OperationSnapshot[] pollOperations = new OperationSnapshot[iterationsCount];
  for (int i = 0; i < iterationsCount - 1; i++) {
    pollOperations[i] = getOperation(opName, null, null, meta, false);
  }
  pollOperations[iterationsCount - 1] = getOperation(opName, resp, null, meta, true);
  UnaryCallable<Integer, OperationSnapshot> initialCallable =
      mockGetOpSnapshotCallable(StatusCode.Code.OK, initialOperation);
  LongRunningClient longRunningClient = mockGetOperation(StatusCode.Code.OK, pollOperations);
  pollingAlgorithm =
      OperationTimedPollAlgorithm.create(
          FAST_RECHECKING_SETTINGS
              .toBuilder()
              .setTotalTimeout(Duration.ofMillis(iterationsCount))
              .build(),
          clock);
  callSettings = callSettings.toBuilder().setPollingAlgorithm(pollingAlgorithm).build();
  OperationCallable<Integer, Color, Currency> callable =
      FakeCallableFactory.createOperationCallable(
          initialCallable, callSettings, initialContext, longRunningClient);
  OperationFuture<Color, Currency> future =
      callable.futureCall(2, FakeCallContext.createDefault());
  Truth.assertThat(future.get(5, TimeUnit.SECONDS)).isEqualTo(resp);
  assertFutureSuccessMetaSuccess(opName, future, resp, meta);
  assertThat(executor.getIterationsCount()).isEqualTo(iterationsCount - 1);
}