### Question:
B2DefaultRetryPolicy implements B2RetryPolicy { @Override public Integer gotRetryableAfterDelay(String operation, int attemptsSoFar, long tookMillis, B2Exception e) { if (attemptsSoFar < MAX_ATTEMPTS) { final Integer secsFromServer = e.getRetryAfterSecondsOrNull(); if (secsFromServer != null) { waitBetweenRetrySecs = 1; return secsFromServer; } else { final int secsToSleep = waitBetweenRetrySecs; waitBetweenRetrySecs *= 2; return secsToSleep; } } else { return null; } }  static Supplier<B2RetryPolicy> supplier(); @Override Integer gotRetryableAfterDelay(String operation,
                                          int attemptsSoFar,
                                          long tookMillis,
                                          B2Exception e); @Override boolean gotRetryableImmediately(String operation,
                                           int attemptsSoFar,
                                           long tookMillis,
                                           B2Exception e);  }### Answer:
@Test public void testDoubling() { final B2Exception e = new B2InternalErrorException("eek!"); int iAttempt = 1; assertEquals((Integer) 1, policy.gotRetryableAfterDelay(OP, iAttempt, 0, e)); iAttempt++; assertEquals((Integer) 2, policy.gotRetryableAfterDelay(OP, iAttempt, 0, e)); iAttempt++; assertEquals((Integer) 4, policy.gotRetryableAfterDelay(OP, iAttempt, 0, e)); iAttempt++; assertEquals((Integer) 8, policy.gotRetryableAfterDelay(OP, iAttempt, 0, e)); iAttempt++; assertEquals((Integer) 16, policy.gotRetryableAfterDelay(OP, iAttempt, 0, e)); iAttempt++; assertEquals((Integer) 32, policy.gotRetryableAfterDelay(OP, iAttempt, 0, e)); iAttempt++; assertEquals((Integer) 64, policy.gotRetryableAfterDelay(OP, iAttempt, 0, e)); iAttempt++; assertNull(policy.gotRetryableAfterDelay(OP, iAttempt, 0, e)); }
@Test public void test_gotRetryableAfterDelay() { final B2Exception e = new B2InternalErrorException("eek!"); final B2Exception withDelayFromServer = new B2InternalErrorException("test", 6, "wow!"); int iAttempt = 1; assertEquals((Integer) 1, policy.gotRetryableAfterDelay(OP, iAttempt, 0, e)); iAttempt++; assertEquals((Integer) 2, policy.gotRetryableAfterDelay(OP, iAttempt, 0, e)); iAttempt++; assertEquals((Integer) 6, policy.gotRetryableAfterDelay(OP, iAttempt, 0, withDelayFromServer)); iAttempt++; assertEquals((Integer) 1, policy.gotRetryableAfterDelay(OP, iAttempt, 0, e)); iAttempt++; assertEquals((Integer) 2, policy.gotRetryableAfterDelay(OP, iAttempt, 0, e)); iAttempt++; assertEquals((Integer) 6, policy.gotRetryableAfterDelay(OP, iAttempt, 0, withDelayFromServer)); iAttempt++; assertEquals((Integer) 6, policy.gotRetryableAfterDelay(OP, iAttempt, 0, withDelayFromServer)); iAttempt++; assertNull(policy.gotRetryableAfterDelay(OP, iAttempt, 0, e)); }