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; }
@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)); } }