### Question:
RandomJitter implements Jitter { long lowJitterBound(BackoffDelay backoff, long jitterOffset) { return Math.max( backoff.min.minus(backoff.delay).toMillis(), -jitterOffset); } RandomJitter(double randomFactor); @Override Duration apply(BackoffDelay backoff); @Override String toString();  }### Answer:
@Test void lowBoundNormal() { double factor = 0.5; Duration min = Duration.ofMillis(100); Duration max = Duration.ofMillis(-123); Duration delay = Duration.ofMillis(500); BackoffDelay bd = new BackoffDelay(min, max, delay); RandomJitter jitter = new RandomJitter(factor); assertThat(jitter.lowJitterBound(bd, 250)) .isEqualTo(-250); }
@Test void lowBoundFlooredAtMin() { double factor = 0.5; Duration min = Duration.ofMillis(300); Duration max = Duration.ofMillis(-123); Duration delay = Duration.ofMillis(500); BackoffDelay bd = new BackoffDelay(min, max, delay); RandomJitter jitter = new RandomJitter(factor); assertThat(jitter.lowJitterBound(bd, 250)) .as("offset over min") .isEqualTo(-200); assertThat(jitter.lowJitterBound(bd, Long.MAX_VALUE / 2)) .as("offset half long max") .isEqualTo(-200); assertThat(jitter.lowJitterBound(bd, Long.MAX_VALUE)) .as("offset long max") .isEqualTo(-200); }
@Test public void lowBoundNormal() { double factor = 0.5; Duration min = Duration.ofMillis(100); Duration max = Duration.ofMillis(-123); Duration delay = Duration.ofMillis(500); BackoffDelay bd = new BackoffDelay(min, max, delay); RandomJitter jitter = new RandomJitter(factor); assertThat(jitter.lowJitterBound(bd, 250)) .isEqualTo(-250); }
@Test public void lowBoundFlooredAtMin() { double factor = 0.5; Duration min = Duration.ofMillis(300); Duration max = Duration.ofMillis(-123); Duration delay = Duration.ofMillis(500); BackoffDelay bd = new BackoffDelay(min, max, delay); RandomJitter jitter = new RandomJitter(factor); assertThat(jitter.lowJitterBound(bd, 250)) .as("offset over min") .isEqualTo(-200); assertThat(jitter.lowJitterBound(bd, Long.MAX_VALUE / 2)) .as("offset half long max") .isEqualTo(-200); assertThat(jitter.lowJitterBound(bd, Long.MAX_VALUE)) .as("offset long max") .isEqualTo(-200); }