@Test public void retriesIfPredicateFails() throws ExecutionException { ListenableFuture<Integer> result = retrier.execute(function); future.set(-1); scheduler.runUntilIdle(); verify(function, times(1)).get(); tick(RETRY_PERIOD.minus(DELTA)); verify(function, times(1)).get(); assertThat(result).isNotDone(); tick(DELTA); verify(function, times(2)).get(); assertThat(result).isNotDone(); tick(RETRY_PERIOD.minus(DELTA)); verify(function, times(2)).get(); future = SettableFuture.create(); future.set(2); tick(DELTA); assertThat(Futures.getDone(result)).isEqualTo(2); }
public ListenableFuture<T> execute(Supplier<ListenableFuture<T>> supplier) { return execute(supplier, maxAttempts); }
AsyncRetrier { public ListenableFuture<T> execute(Supplier<ListenableFuture<T>> supplier) { return execute(supplier, maxAttempts); } }
AsyncRetrier { public ListenableFuture<T> execute(Supplier<ListenableFuture<T>> supplier) { return execute(supplier, maxAttempts); } AsyncRetrier(
            int maxAttempts,
            Duration delayBetweenAttempts,
            ListeningScheduledExecutorService schedulingExecutor,
            ListeningExecutorService executionExecutor,
            Predicate<T> predicate); }
AsyncRetrier { public ListenableFuture<T> execute(Supplier<ListenableFuture<T>> supplier) { return execute(supplier, maxAttempts); } AsyncRetrier(
            int maxAttempts,
            Duration delayBetweenAttempts,
            ListeningScheduledExecutorService schedulingExecutor,
            ListeningExecutorService executionExecutor,
            Predicate<T> predicate); ListenableFuture<T> execute(Supplier<ListenableFuture<T>> supplier); }
AsyncRetrier { public ListenableFuture<T> execute(Supplier<ListenableFuture<T>> supplier) { return execute(supplier, maxAttempts); } AsyncRetrier(
            int maxAttempts,
            Duration delayBetweenAttempts,
            ListeningScheduledExecutorService schedulingExecutor,
            ListeningExecutorService executionExecutor,
            Predicate<T> predicate); ListenableFuture<T> execute(Supplier<ListenableFuture<T>> supplier);  }