public ExponentialBackoff(long initialInterval, int multiplier, long maxInterval, double jitter) {
        this.initialInterval = Math.min(maxInterval, initialInterval);
        this.multiplier = multiplier;
        this.maxInterval = maxInterval;
        this.jitter = jitter;
        this.expMax = maxInterval > initialInterval ?
                Math.log(maxInterval / (double) Math.max(initialInterval, 1)) / Math.log(multiplier) : 0;
    }
@Test
    public void testExponentialBackoff() {
        long scaleFactor = 100;
        int ratio = 2;
        long backoffMax = 2000;
        double jitter = 0.2;
        ExponentialBackoff exponentialBackoff = new ExponentialBackoff(
                scaleFactor, ratio, backoffMax, jitter
        );

        for (int i = 0; i <= 100; i++) {
            for (int attempts = 0; attempts <= 10; attempts++) {
                if (attempts <= 4) {
                    assertEquals(scaleFactor * Math.pow(ratio, attempts),
                            exponentialBackoff.backoff(attempts),
                            scaleFactor * Math.pow(ratio, attempts) * jitter);
                } else {
                    assertTrue(exponentialBackoff.backoff(attempts) <= backoffMax * (1 + jitter));
                }
            }
        }
    }