@Test public void getWaitTimeMillisTest() { long waitTime; int power; for (int i = 0; i < 100; i++) { if (i < 3) { waitTime = 0; } else { power = (i / MAXIMUM_NUMBER) - 1; waitTime = TEN_MINUTES * (long) Math.pow(MAXIMUM_NUMBER, power); } assertEquals(waitTime, RetryUtil.getWaitTimeMillis(i)); } }
public static long getWaitTimeMillis(int retryTimes) { if (retryTimes < MAXIMUM_TRY_NUMBER) { return 0; } else { int power = (retryTimes / MAXIMUM_TRY_NUMBER) - 1; return TEN_MINUTES * (long) Math.pow(MAXIMUM_TRY_NUMBER, power); } }
RetryUtil { public static long getWaitTimeMillis(int retryTimes) { if (retryTimes < MAXIMUM_TRY_NUMBER) { return 0; } else { int power = (retryTimes / MAXIMUM_TRY_NUMBER) - 1; return TEN_MINUTES * (long) Math.pow(MAXIMUM_TRY_NUMBER, power); } } }
RetryUtil { public static long getWaitTimeMillis(int retryTimes) { if (retryTimes < MAXIMUM_TRY_NUMBER) { return 0; } else { int power = (retryTimes / MAXIMUM_TRY_NUMBER) - 1; return TEN_MINUTES * (long) Math.pow(MAXIMUM_TRY_NUMBER, power); } } private  RetryUtil(); }
RetryUtil { public static long getWaitTimeMillis(int retryTimes) { if (retryTimes < MAXIMUM_TRY_NUMBER) { return 0; } else { int power = (retryTimes / MAXIMUM_TRY_NUMBER) - 1; return TEN_MINUTES * (long) Math.pow(MAXIMUM_TRY_NUMBER, power); } } private  RetryUtil(); static long getWaitTimeMillis(int retryTimes); }
RetryUtil { public static long getWaitTimeMillis(int retryTimes) { if (retryTimes < MAXIMUM_TRY_NUMBER) { return 0; } else { int power = (retryTimes / MAXIMUM_TRY_NUMBER) - 1; return TEN_MINUTES * (long) Math.pow(MAXIMUM_TRY_NUMBER, power); } } private  RetryUtil(); static long getWaitTimeMillis(int retryTimes); static final int MAXIMUM_TRY_NUMBER; }