/** * Start building an await statement. * * @return the condition factory */ public static ConditionFactory await() { return await(null); }
/** Returns a configured {@link ConditionFactory} that polls at a short interval. */ public static ConditionFactory await() { return Awaitility.with() .pollDelay(1, TimeUnit.MILLISECONDS).and() .pollInterval(1, TimeUnit.MILLISECONDS); } }
/** * Create a new instance of the {@link FixedPollInterval}. * * @param pollInterval The poll interval amount * @param unit The time unit */ public FixedPollInterval(long pollInterval, TimeUnit unit) { this(new Duration(pollInterval, unit)); }
private long getRemainingTimeInMS(long elapsedTimeInMS, Duration maxWaitTime) { return maxWaitTime.equals(Duration.FOREVER) ? Long.MAX_VALUE : maxWaitTime.getValueInMS() - elapsedTimeInMS; }
public CountDownBean call() throws Exception { countDown.setSecondCountDown(countDown.getSecondCountDown() - 1); return get(); }
public int compareTo(Duration other) { if (other == null) return 1; long x = getValueInMS(); long y = other.getValueInMS(); return (x < y) ? -1 : ((x == y) ? 0 : 1); }
/** * Add a duration with the given time unit. For example: * <pre> * new Duration(2, SECONDS).plus(Duration.FIVE_HUNDRED_MILLISECONDS) * </pre> * will return a Duration of 2500 {@link TimeUnit#MILLISECONDS}. * <p> * * @param duration The duration to add * @return A new duration */ public Duration minus(Duration duration) { return new Minus().apply(this, duration); }
/** * Add a duration with the given time unit. For example: * <pre> * new Duration(2, SECONDS).plus(Duration.FIVE_HUNDRED_MILLISECONDS) * </pre> * will return a Duration of 2500 {@link TimeUnit#MILLISECONDS}. * <p> * * @param duration The duration to add * @return A new duration */ public Duration plus(Duration duration) { return new Plus().apply(this, duration); }
@Override public int hashCode() { return duration.hashCode(); }
/** * Sets the default poll delay all await statements will use. * * @param pollDelay the poll delay * @param unit the unit */ public static void setDefaultPollDelay(long pollDelay, TimeUnit unit) { defaultPollDelay = new Duration(pollDelay, unit); }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof FixedPollInterval)) return false; FixedPollInterval that = (FixedPollInterval) o; return duration.equals(that.duration); }
/** * <p>isZero</p> * * @return a boolean. */ public boolean isZero() { return this.equals(ZERO); }