### Question:
RetryerUtils { public static Retryer<Boolean> getDefaultRetryer(boolean checkResult) { return checkResult ? getDefaultRetryer() : getDefaultRetryerResultNoCheck(); } private  RetryerUtils(); static Retryer<Boolean> getDefaultRetryer(boolean checkResult); static Retryer<Boolean> getDefaultRetryer(); static Boolean retryCall(final Callable<Boolean> callable, boolean checkResult); static Boolean retryCall(final Callable<Boolean> callable); static boolean retryCallSilent(final Callable<Boolean> callable, boolean checkResult); static boolean retryCallSilent(final Callable<Boolean> callable);  }### Answer:
@Test public void testDefaultRetryer() { Retryer<Boolean> retryer = RetryerUtils.getDefaultRetryer(); Assert.assertNotNull(retryer); try { boolean result = retryer.call(() -> true); Assert.assertTrue(result); } catch (ExecutionException | RetryException e) { Assert.fail("Retry call failed " + e.getMessage()); } Retryer<Boolean> retryer1 = RetryerUtils.getDefaultRetryer(true); Assert.assertEquals(retryer, retryer1); }
@Test public void testDefaultRetryerResultCheck() { Retryer<Boolean> retryer = RetryerUtils.getDefaultRetryer(); Assert.assertNotNull(retryer); try { for (int execTarget = 1; execTarget <= 3; execTarget++) { int finalExecTarget = execTarget; int[] execTime = {0}; boolean result = retryer.call(() -> { execTime[0]++; return execTime[0] == finalExecTarget; }); Assert.assertEquals(finalExecTarget, execTime[0]); Assert.assertTrue(result); } } catch (ExecutionException | RetryException e) { Assert.fail("Retry call failed " + e.getMessage()); } int[] execTime = {0}; try { retryer.call(() -> { execTime[0]++; return execTime[0] == 4; }); Assert.fail("Retry times not reached"); } catch (RetryException e) { Assert.assertEquals(3, e.getNumberOfFailedAttempts()); Assert.assertEquals(3, execTime[0]); } catch (ExecutionException e) { Assert.fail("Retry call failed " + e.getMessage()); } }
@Test public void testDefaultRetryerResultNoCheck() { Retryer<Boolean> retryer = RetryerUtils.getDefaultRetryer(false); Assert.assertNotNull(retryer); try { for (int execTarget = 1; execTarget <= 5; execTarget++) { int[] execTime = {0}; boolean result = retryer.call(() -> { execTime[0]++; return execTime[0] > 1; }); Assert.assertEquals(1, execTime[0]); Assert.assertFalse(result); } } catch (ExecutionException | RetryException e) { Assert.fail("Retry call failed " + e.getMessage()); } }