com.atlassian.pageobjects.elements.query
Class Poller

java.lang.Object
  extended by com.atlassian.pageobjects.elements.query.Poller

@PublicApi
public final class Poller
extends Object

Utility class to poll and wait for a particular states of timeout-based queries inheriting from PollingQuery.

See Also:
PollingQuery, TimedQuery, TimedCondition

Nested Class Summary
static class Poller.WaitTimeout
           
 
Method Summary
static Poller.WaitTimeout by(long timeoutInMillis)
          Custom assertion timeout expressed in milliseconds.
static Poller.WaitTimeout by(long timeout, TimeUnit unit)
          Custom assertion timeout expressed in a number of time units.
static Poller.WaitTimeout byDefaultTimeout()
          Timeout indicating that the assertion method will wait for the default timeout of exercised timed query for the condition to become true.
static Poller.WaitTimeout now()
          Timeout indicating that the assertion method will evaluate the assertion condition immediately, without waiting.
static
<T> T
waitUntil(String message, TimedQuery<T> query, org.hamcrest.Matcher<? super T> matcher)
           Wait until given query fulfils certain condition specified by the matcher, by default timeout of the query.
static
<T> T
waitUntil(String message, TimedQuery<T> query, org.hamcrest.Matcher<? super T> matcher, Poller.WaitTimeout timeout)
           Wait until given query fulfils certain condition specified by given the matcher, by given timeout.
static
<T> T
waitUntil(TimedQuery<T> query, org.hamcrest.Matcher<? super T> matcher)
           Wait until given query fulfils certain condition specified by the matcher, by default timeout of the query.
static
<T> T
waitUntil(TimedQuery<T> query, org.hamcrest.Matcher<? super T> matcher, Poller.WaitTimeout timeout)
           Wait until given query fulfils certain condition specified by given the matcher, by given timeout.
static
<T> T
waitUntilEquals(String message, T expectedValue, TimedQuery<T> query)
          Wait until given query evaluates to actual value that is equal to expectedValue by default timeout, with custom error message.
static
<T> T
waitUntilEquals(T expectedValue, TimedQuery<T> query)
          Wait until given query evaluates to actual value that is equal to expectedValue by default timeout.
static void waitUntilFalse(String message, TimedQuery<Boolean> condition)
          Wait until given condition is false by default timeout, with custom error message.
static void waitUntilFalse(TimedQuery<Boolean> condition)
          Wait until given condition is false by default timeout
static void waitUntilTrue(String message, TimedQuery<Boolean> condition)
          Wait until given condition is true by default timeout, with custom error message.
static void waitUntilTrue(TimedQuery<Boolean> condition)
          Wait until given condition is true by default timeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

waitUntilTrue

public static void waitUntilTrue(TimedQuery<Boolean> condition)
Wait until given condition is true by default timeout

Parameters:
condition - condition to exercise

waitUntilTrue

public static void waitUntilTrue(String message,
                                 TimedQuery<Boolean> condition)
Wait until given condition is true by default timeout, with custom error message.

Parameters:
message - error message
condition - condition to exercise

waitUntilFalse

public static void waitUntilFalse(TimedQuery<Boolean> condition)
Wait until given condition is false by default timeout

Parameters:
condition - condition to exercise

waitUntilFalse

public static void waitUntilFalse(String message,
                                  TimedQuery<Boolean> condition)
Wait until given condition is false by default timeout, with custom error message.

Parameters:
message - error message
condition - condition to exercise

waitUntilEquals

public static <T> T waitUntilEquals(T expectedValue,
                                    TimedQuery<T> query)
Wait until given query evaluates to actual value that is equal to expectedValue by default timeout.

Parameters:
expectedValue - expected value
query - query to evaluate
Returns:
last value from the query, satisfying the expected value

waitUntilEquals

public static <T> T waitUntilEquals(String message,
                                    T expectedValue,
                                    TimedQuery<T> query)
Wait until given query evaluates to actual value that is equal to expectedValue by default timeout, with custom error message.

Parameters:
message - error message
expectedValue - expected value
query - query to evaluate
Returns:
last value from the query, satisfying the expected value

waitUntil

public static <T> T waitUntil(TimedQuery<T> query,
                              org.hamcrest.Matcher<? super T> matcher)

Wait until given query fulfils certain condition specified by the matcher, by default timeout of the query.

Use any matcher from the available libraries (e.g. Hamcrest, JUnit etc.), or a custom one.

Parameters:
query - timed query to evaluate
matcher - a matcher representing the assertion condition
Returns:
last value from the query, satisfying the matcher
See Also:
Matcher, Matchers

waitUntil

public static <T> T waitUntil(String message,
                              TimedQuery<T> query,
                              org.hamcrest.Matcher<? super T> matcher)

Wait until given query fulfils certain condition specified by the matcher, by default timeout of the query.

Use any matcher from the available libraries (e.g. Hamcrest, JUnit etc.), or a custom one.

Parameters:
message - message displayed in case of failure
query - timed query to evaluate
matcher - a matcher representing the assertion condition
Returns:
last value from the query, satisfying the matcher
See Also:
Matcher, Matchers

waitUntil

public static <T> T waitUntil(TimedQuery<T> query,
                              org.hamcrest.Matcher<? super T> matcher,
                              Poller.WaitTimeout timeout)

Wait until given query fulfils certain condition specified by given the matcher, by given timeout.

Use any matcher from the available libraries (e.g. Hamcrest, JUnit etc.), or a custom one.

To specify desired timeout, use one of four provided timeouts: now(), byDefaultTimeout(), #by(long), by(long, java.util.concurrent.TimeUnit).

Parameters:
query - timed query to evaluate
matcher - a matcher representing the assertion condition
timeout - time limit for this wait
Returns:
last value from the query, satisfying the matcher
See Also:
Matcher, Matchers, now(), by(long), by(long, java.util.concurrent.TimeUnit), byDefaultTimeout()

waitUntil

public static <T> T waitUntil(String message,
                              TimedQuery<T> query,
                              org.hamcrest.Matcher<? super T> matcher,
                              Poller.WaitTimeout timeout)

Wait until given query fulfils certain condition specified by given the matcher, by given timeout.

Use any matcher from the libraries available (e.g. Hamcrest, JUnit etc.), or a custom one.

To specify desired timeout, use one of four provided timeouts: now(), byDefaultTimeout(), #by(long), by(long, java.util.concurrent.TimeUnit).

Parameters:
message - message displayed for failed assertion
query - timed query to verify
matcher - a matcher representing the assertion condition
timeout - timeout of the assertion
Returns:
last value from the query, satisfying the matcher
See Also:
Matcher, Matchers, now(), by(long), by(long, java.util.concurrent.TimeUnit), byDefaultTimeout()

now

public static Poller.WaitTimeout now()
Timeout indicating that the assertion method will evaluate the assertion condition immediately, without waiting.

Returns:
new immediate assertion timeout

byDefaultTimeout

public static Poller.WaitTimeout byDefaultTimeout()
Timeout indicating that the assertion method will wait for the default timeout of exercised timed query for the condition to become true.

Returns:
new default assertion timeout

by

public static Poller.WaitTimeout by(long timeoutInMillis)
Custom assertion timeout expressed in milliseconds. E.g. TimedAssertions.by(500L); passed to an assertion method will make it wait 500 milliseconds for given condition to become true.

Parameters:
timeoutInMillis - number of milliseconds to wait for the assertion condition
Returns:
new custom timeout assertion

by

public static Poller.WaitTimeout by(long timeout,
                                    TimeUnit unit)
Custom assertion timeout expressed in a number of time units. E.g. TimedAssertions.by(5, TimeUnit.SECONDS); passed to an assertion method will make it wait 5 seconds for given condition to become true.

Parameters:
timeout - timeout count
unit - unit of the timeout
Returns:
new custom timeout assertion


Copyright © 2014 Atlassian. All rights reserved.