Package com.epam.reportportal.utils
Class Waiter
- java.lang.Object
-
- com.epam.reportportal.utils.Waiter
-
public class Waiter extends java.lang.ObjectThe simplest waiter, just to not include a new dependency into the project.
-
-
Constructor Summary
Constructors Constructor Description Waiter(java.lang.String description)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WaiterapplyRandomDiscrepancy(float maximumDiscrepancy)Waiterduration(long duration, java.util.concurrent.TimeUnit timeUnit)Waiterignore(java.lang.Class<? extends java.lang.Throwable> exception)WaiterpollingEvery(long duration, java.util.concurrent.TimeUnit timeUnit)<T> Ttill(java.util.concurrent.Callable<T> waitFor)Waits until the supplied callable returns a non-null result, polling at the configured interval, or until the wait times out or the thread is interrupted.WaitertimeoutFail()
-
-
-
Method Detail
-
duration
public Waiter duration(long duration, java.util.concurrent.TimeUnit timeUnit)
-
pollingEvery
public Waiter pollingEvery(long duration, java.util.concurrent.TimeUnit timeUnit)
-
ignore
public Waiter ignore(java.lang.Class<? extends java.lang.Throwable> exception)
-
applyRandomDiscrepancy
public Waiter applyRandomDiscrepancy(float maximumDiscrepancy)
-
timeoutFail
public Waiter timeoutFail()
-
till
public <T> T till(java.util.concurrent.Callable<T> waitFor)
Waits until the supplied callable returns a non-null result, polling at the configured interval, or until the wait times out or the thread is interrupted.Important:
falseis still a non-null value forBooleanand will stop waiting as a successful result.Exceptions matching those configured via
ignore(Class)are swallowed and the wait is retried; any other exception aborts the wait and is wrapped intoInternalReportPortalClientException.If the timeout elapses:
- when
timeoutFail()was configured, anInternalReportPortalClientExceptionis thrown; - otherwise,
nullis returned.
nullis returned.- Type Parameters:
T- type of the result supplied by the callable- Parameters:
waitFor- a callable that is evaluated repeatedly until it returns a non-null result- Returns:
- the first non-null result returned by the callable;
nullon timeout/interruption when not configured to fail - Throws:
InternalReportPortalClientException- if an unexpected exception occurs in the callable or if timeout occurs andtimeoutFail()was configured
- when
-
-