@Test
void nextDelayCalculatedAccordingToJitter() throws Exception
{

    int retries = 32;
    double jitterFactor = 0.2;
    int initialDelay = 1;
    int multiplier = 2;
    Clock clock = mock( Clock.class );
    ExponentialBackoffRetryLogic logic = newRetryLogic( MAX_VALUE, initialDelay, multiplier, jitterFactor, clock );
    retry( logic, retries );
    List<Long> sleepValues = sleepValues( clock, retries );
    List<Long> delaysWithoutJitter = delaysWithoutJitter( initialDelay, multiplier, retries );
    assertDelaysApproximatelyEqual( delaysWithoutJitter, sleepValues, jitterFactor );
}