### Question:
RetryHelper { @VisibleForTesting static long getSleepDuration(RetryParams retryParams, int attemptsSoFar) { long initialDelay = retryParams.getInitialRetryDelayMillis(); double backoff = retryParams.getRetryDelayBackoffFactor(); long maxDelay = retryParams.getMaxRetryDelayMillis(); long retryDelay = getExponentialValue(initialDelay, backoff, maxDelay, attemptsSoFar); return (long) ((Math.random() / 2.0 + .75) * retryDelay); } @VisibleForTesting  RetryHelper(Callable<V> callable, RetryParams params, ExceptionHandler exceptionHandler,
      Stopwatch stopwatch); @Override String toString(); static V runWithRetries(Callable<V> callable); static V runWithRetries(Callable<V> callable, RetryParams params,
      ExceptionHandler exceptionHandler);  }### Answer:
@Test public void testBackoffIsExponential() { RetryParams params = new RetryParams.Builder() .initialRetryDelayMillis(10) .maxRetryDelayMillis(10_000_000) .retryDelayBackoffFactor(2) .totalRetryPeriodMillis(60_000) .retryMinAttempts(0) .retryMaxAttempts(100) .build(); long sleepDuration = RetryHelper.getSleepDuration(params, 1); assertTrue("" + sleepDuration, sleepDuration < 13 && sleepDuration >= 7); sleepDuration = RetryHelper.getSleepDuration(params, 2); assertTrue("" + sleepDuration, sleepDuration < 25 && sleepDuration >= 15); sleepDuration = RetryHelper.getSleepDuration(params, 3); assertTrue("" + sleepDuration, sleepDuration < 50 && sleepDuration >= 30); sleepDuration = RetryHelper.getSleepDuration(params, 4); assertTrue("" + sleepDuration, sleepDuration < 100 && sleepDuration >= 60); sleepDuration = RetryHelper.getSleepDuration(params, 5); assertTrue("" + sleepDuration, sleepDuration < 200 && sleepDuration >= 120); sleepDuration = RetryHelper.getSleepDuration(params, 6); assertTrue("" + sleepDuration, sleepDuration < 400 && sleepDuration >= 240); sleepDuration = RetryHelper.getSleepDuration(params, 7); assertTrue("" + sleepDuration, sleepDuration < 800 && sleepDuration >= 480); sleepDuration = RetryHelper.getSleepDuration(params, 8); assertTrue("" + sleepDuration, sleepDuration < 1600 && sleepDuration >= 960); sleepDuration = RetryHelper.getSleepDuration(params, 9); assertTrue("" + sleepDuration, sleepDuration < 3200 && sleepDuration >= 1920); sleepDuration = RetryHelper.getSleepDuration(params, 10); assertTrue("" + sleepDuration, sleepDuration < 6400 && sleepDuration >= 3840); sleepDuration = RetryHelper.getSleepDuration(params, 11); assertTrue("" + sleepDuration, sleepDuration < 12800 && sleepDuration >= 7680); sleepDuration = RetryHelper.getSleepDuration(params, 12); assertTrue("" + sleepDuration, sleepDuration < 25600 && sleepDuration >= 15360); }