### Question:
BackoffHelper { public <E extends Exception> void doUntilSuccess(final ExceptionalSupplier<Boolean, E> task) throws InterruptedException, BackoffStoppedException, E { doUntilResult(() -> { Boolean result = task.get(); return Boolean.TRUE.equals(result) ? result : null; }); } BackoffHelper();  BackoffHelper(Amount<Long, Time> initialBackoff, Amount<Long, Time> maxBackoff);  BackoffHelper(BackoffStrategy backoffStrategy); @VisibleForTesting  BackoffHelper(Clock clock, BackoffStrategy backoffStrategy); void doUntilSuccess(final ExceptionalSupplier<Boolean, E> task); BackoffStrategy getBackoffStrategy(); T doUntilResult(ExceptionalSupplier<T, E> task);  }### Answer:
@Test public void testDoUntilSuccess() throws Exception { ExceptionalSupplier<Boolean, RuntimeException> task = createMock(new Clazz<ExceptionalSupplier<Boolean, RuntimeException>>() { }); expect(task.get()).andReturn(false); expect(backoffStrategy.shouldContinue(0L)).andReturn(true); expect(backoffStrategy.calculateBackoffMs(0L)).andReturn(42L); clock.waitFor(42L); expect(task.get()).andReturn(true); control.replay(); backoffHelper.doUntilSuccess(task); control.verify(); }
@Test public void testDoUntilSuccessTransparentException() throws Exception { ExceptionalSupplier<Boolean, RuntimeException> task = createMock(new Clazz<ExceptionalSupplier<Boolean, RuntimeException>>() { }); IllegalArgumentException thrown = new IllegalArgumentException(); expect(task.get()).andThrow(thrown); control.replay(); try { backoffHelper.doUntilSuccess(task); fail("Expected exception to be bubbled"); } catch (IllegalArgumentException e) { assertSame(thrown, e); } control.verify(); }