Repeater implements Callable<Boolean> { public Repeater every(long period, TimeUnit unit) { return every(Duration.of(period, unit)); } Repeater();  Repeater(String description); static Repeater create(); static Repeater create(String description); Repeater repeat(Runnable body); Repeater repeat(Callable<?> body); Repeater threaded(); Repeater threaded(ExecutorService executor); Repeater every(long period, TimeUnit unit); Repeater every(Duration duration); @Deprecated Repeater every(groovy.time.Duration duration); Repeater delayOnIteration(Function<? super Integer,Duration> delayFunction); Repeater backoff(final Duration initialDelay, final double multiplier, @Nullable final Duration finalDelay); Repeater backoffTo(final Duration finalDelay); Repeater until(Callable<Boolean> exitCondition); Repeater until(final T target, final Predicate<T> exitCondition); Repeater until(final Supplier<T> supplier, final Predicate<T> exitCondition); Repeater rethrowException(); Repeater rethrowExceptionImmediately(); Repeater rethrowExceptionImmediately(Predicate<? super Throwable> val); Repeater suppressWarnings(); Repeater limitIterationsTo(int iterationLimit); Repeater limitTimeTo(long deadline, TimeUnit unit); Repeater limitTimeTo(Duration duration); boolean run(); void runRequiringTrue(); ReferenceWithError<Boolean> runKeepingError(); String getDescription(); Duration getTimeLimit(); @Override Boolean call(); static final Duration DEFAULT_REAL_QUICK_PERIOD; }
@Test(expectedExceptions = { NullPointerException.class, IllegalArgumentException.class }) public void everyFailsIfPeriodIsZero() { new Repeater("everyFailsIfPeriodIsZero").every(Duration.ZERO); fail("Expected exception was not thrown"); }
@Test(expectedExceptions = { NullPointerException.class, IllegalArgumentException.class }) public void everyFailsIfPeriodIsNegative() { new Repeater("everyFailsIfPeriodIsNegative").every(Duration.millis(-1)); fail("Expected exception was not thrown"); }
@Test(expectedExceptions = { NullPointerException.class, IllegalArgumentException.class }) public void everyFailsIfUnitsIsNull() { new Repeater("everyFailsIfUnitsIsNull").every(10, null); fail("Expected exception was not thrown"); }
@Test public void everySucceedsIfPeriodIsPositiveAndUnitsIsNonNull() { new Repeater("repeatSucceedsIfClosureIsNonNull").every(Duration.millis(10)); }
@Test public void everyAcceptsDuration() { new Repeater("everyAcceptsDuration").every(Duration.ONE_SECOND); }
@Test public void everyAcceptsTimeUnit() { new Repeater("everyAcceptsTimeUnit").every(1000000L, TimeUnit.MICROSECONDS); }