### Question:
Backoff { public static Stream<Long> exponential(long startMs, int multiplier, long maxMs) { return Stream.iterate(startMs, lastMs -> Math.min(lastMs * multiplier, maxMs)); }  static Stream<Long> constant(long startMs); static Stream<Long> exponential(long startMs,
                                           int multiplier,
                                           long maxMs); static Stream<Long> exponentialJittered(long startMs,
                                                   long maxMs); static Stream<Long> decorrelatedJittered(long startMs,
                                                    long maxMs); static Stream<Long> equalJittered(long startMs,
                                             long maxMs); static final Policy DEFAULT; }### Answer:
@Test public void testExponential() throws Exception { Stream<Long> backoffs = Backoff.exponential(1000, 2, Long.MAX_VALUE).limit(10); Stream<Long> expectedBackoffs = LongStream.range(0L, 10L).mapToObj(i -> (1000L << i)); assertStreamEquals(expectedBackoffs, backoffs); }
@Test public void testExponentialWithUpperLimit() throws Exception { Stream<Long> backoffs = Backoff.exponential(1000, 2, 32000).limit(10); Stream<Long> expectedBackoffs = LongStream.range(0L, 10L).mapToObj(i -> Math.min(1000L << i, 32000)); assertStreamEquals(expectedBackoffs, backoffs); }