LeaderElector { protected static Duration jitter(Duration duration, double maxFactor) { maxFactor = maxFactor > 0 ? maxFactor : 1.0; return duration.plusMillis(Double.valueOf(duration.toMillis() * Math.random() * maxFactor).longValue()); } LeaderElector(C kubernetesClient, LeaderElectionConfig leaderElectionConfig); void run();  }
@Test void jitterWithPositiveShouldReturnPositiveDouble() { final Duration test = Duration.of(1, ChronoUnit.SECONDS); final Duration result = jitter(test, 1); assertTrue(result.toMillis() < 2000L); assertTrue(result.toMillis() > 1000L); }
@Test void jitterWithNegativeShouldReturnDuration() { final Duration test = Duration.of(1, ChronoUnit.SECONDS); final Duration result = jitter(test, -1); assertTrue(result.toMillis() < 2000L); assertTrue(result.toMillis() > 1000L); }