com.atlassian.jira.webtest.framework.core.query
Class AbstractTimedQuery<T>

java.lang.Object
  extended by com.atlassian.jira.webtest.framework.core.AbstractPollingQuery
      extended by com.atlassian.jira.webtest.framework.core.query.AbstractTimedQuery<T>
All Implemented Interfaces:
ClockAware, PollingQuery, TimedQuery<T>
Direct Known Subclasses:
AbstractConditionBasedQuery, AbstractSeleniumTimedQuery, StaticQuery

@NotThreadSafe
public abstract class AbstractTimedQuery<T>
extends AbstractPollingQuery
implements TimedQuery<T>, ClockAware

Abstract query that implements byDefaultTimeout() in terms of by(long), and by(long) as a template method calling the following hooks (to be implemented by subclasses):

In addition, an ExpirationHandler must be provided to handle the case of expired query.

Since:
v4.3
See Also:
ExpirationHandler

Field Summary
 
Fields inherited from class com.atlassian.jira.webtest.framework.core.AbstractPollingQuery
defaultTimeout, interval
 
Constructor Summary
protected AbstractTimedQuery(com.atlassian.core.util.Clock clock, long defTimeout, long interval, ExpirationHandler expirationHandler)
           
protected AbstractTimedQuery(long defTimeout, long interval, ExpirationHandler expirationHandler)
           
protected AbstractTimedQuery(PollingQuery other, ExpirationHandler expirationHandler)
           
 
Method Summary
 T by(long timeout)
          Evaluate this query by given timeout.
 T by(long timeout, TimeUnit unit)
          Evaluate this query by given timeout.
 T byDefaultTimeout()
          Evaluate this query by a timeout deemed default in the given test context.
 com.atlassian.core.util.Clock clock()
          Clock used by this instance.
protected abstract  T currentValue()
          Current evaluation of the query.
 ExpirationHandler expirationHandler()
          Expiration handler of this query
 T now()
          Evaluate this query immediately.
protected  void resetLastRun()
           
protected abstract  boolean shouldReturn(T currentEval)
          If the current evaluated query value should be returned.
 String toString()
           
 
Methods inherited from class com.atlassian.jira.webtest.framework.core.AbstractPollingQuery
defaultTimeout, interval
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.atlassian.jira.webtest.framework.core.PollingQuery
defaultTimeout, interval
 

Constructor Detail

AbstractTimedQuery

protected AbstractTimedQuery(com.atlassian.core.util.Clock clock,
                             long defTimeout,
                             long interval,
                             ExpirationHandler expirationHandler)

AbstractTimedQuery

protected AbstractTimedQuery(long defTimeout,
                             long interval,
                             ExpirationHandler expirationHandler)

AbstractTimedQuery

protected AbstractTimedQuery(PollingQuery other,
                             ExpirationHandler expirationHandler)
Method Detail

by

public final T by(long timeout)
Description copied from interface: TimedQuery
Evaluate this query by given timeout. That is, return the expected T as soon as the query evaluates to the expected value, otherwise perform any appropriate operation when the timeout expires (e.g. return real value, null, or throw exception

Specified by:
by in interface TimedQuery<T>
Parameters:
timeout - timeout in milliseconds (must be greater than 0)
Returns:
expected value of T, or any suitable value, if the expected value was not returned before timeout expired

by

public final T by(long timeout,
                  TimeUnit unit)
Description copied from interface: TimedQuery
Evaluate this query by given timeout. That is, return the expected T as soon as the query evaluates to the expected value, otherwise perform any appropriate operation when the timeout expires (e.g. return real value, null, or throw exception

Specified by:
by in interface TimedQuery<T>
Parameters:
timeout - timeout (must be greater than 0)
unit - the unit that the timeout is in
Returns:
expected value of T, or any suitable value, if the expected value was not returned before timeout expired

byDefaultTimeout

public T byDefaultTimeout()
Description copied from interface: TimedQuery
Evaluate this query by a timeout deemed default in the given test context.

Specified by:
byDefaultTimeout in interface TimedQuery<T>
Returns:
expected value of T, or any suitable value, if the expected value was not returned before the default timeout expired
See Also:
PollingQuery.defaultTimeout()

now

public final T now()
Description copied from interface: TimedQuery
Evaluate this query immediately.

Specified by:
now in interface TimedQuery<T>
Returns:
current evaluation of the underlying query.

expirationHandler

public final ExpirationHandler expirationHandler()
Expiration handler of this query

Returns:
expiration handler of this query

shouldReturn

protected abstract boolean shouldReturn(T currentEval)
If the current evaluated query value should be returned.

Parameters:
currentEval - current query evaluation expires
Returns:
true, if the current query evaluation should be returned as a result of this timed query

currentValue

protected abstract T currentValue()
Current evaluation of the query.

Returns:
current evaluation of the query

clock

public com.atlassian.core.util.Clock clock()
Description copied from interface: ClockAware
Clock used by this instance.

Specified by:
clock in interface ClockAware
Returns:
clock

resetLastRun

protected void resetLastRun()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2002-2013 Atlassian. All Rights Reserved.