Scheduler { @VisibleForTesting static long randomizedDelay() { return ThreadLocalRandom.current().nextLong(RANDOMIZED_DELAY_BASE / 2, (long) (RANDOMIZED_DELAY_BASE * 1.5)); } Scheduler(Time time, StateManager stateManager, Storage storage,
            WorkflowResourceDecorator resourceDecorator, Stats stats, RateLimiter dequeueRateLimiter,
            ShardedCounter shardedCounter, Executor executor);   Scheduler(Time time, StateManager stateManager, Storage storage,
            WorkflowResourceDecorator resourceDecorator, Stats stats, RateLimiter dequeueRateLimiter,
            ShardedCounter shardedCounter, Executor executor, Logger log);   }
@Test public void shouldGiveRandomizedDelay() { var statistics = LongStream.range(0, 10000) .map(i -> Scheduler.randomizedDelay()) .summaryStatistics(); assertThat(statistics.getAverage(), is(closeTo(RANDOMIZED_DELAY_BASE, RANDOMIZED_DELAY_BASE / 2.0))); assertThat(statistics.getMin(), is( both(greaterThanOrEqualTo(RANDOMIZED_DELAY_BASE / 2)) .and(lessThanOrEqualTo((long) (RANDOMIZED_DELAY_BASE * 1.5))))); assertThat(statistics.getMax(), is( both(greaterThanOrEqualTo(RANDOMIZED_DELAY_BASE)) .and(lessThanOrEqualTo((long) (RANDOMIZED_DELAY_BASE * 1.5))))); }