T - result type of get()public class DefaultCondition<T> extends Object implements Condition<T>, FailSafeCondition<T>
An abstract implementation for conditions. Using this you only have to override the method get() to retrieve
the value/state to check directly. Everything else, waiting, asserting etc. is done by this condition implementation.
To override this class and provide the same syntax for configuration you should override any methods returning
a self reference, call the super method and just return this.
| Constructor and Description |
|---|
DefaultCondition(Expression<T> expression,
Timeout timeout) |
| Modifier and Type | Method and Description |
|---|---|
void |
assertEquals(T expected)
Assert that the condition evaluates to the expected value within a given time.
|
void |
assertThat(org.hamcrest.Matcher<? super T> matcher)
Uses
Matcher to assert that a condition is met in time. |
void |
assumeEquals(T expected)
Assumes that the condition evaluates to the expected value within a given time.
|
void |
assumeThat(org.hamcrest.Matcher<? super T> matcher)
Uses
Matcher to assume that a condition is met in time. |
T |
await()
Retrieve the result of the condition as soon as it is evaluated without any exception.
|
T |
await(org.hamcrest.Matcher<? super T> matcher)
Wait for the condition value until it fulfills the given matcher and return it.
|
T |
get()
Conditions need to implement this method to return the value
which will be checked.
|
DefaultCondition<T> |
runBefore(Runnable runnable)
Define runnable to execute before the condition is being performed.
|
DefaultCondition<T> |
runFinally(Runnable runnable)
Define runnable to execute after the condition has been performed.
|
String |
toString() |
void |
waitUntil(org.hamcrest.Matcher<? super T> matcher)
Uses
Matcher to wait until a condition is met in time. |
void |
waitUntilEquals(T expected)
Wait until the condition evaluates to the expected value within a given time.
|
DefaultCondition<T> |
withMessage(String newMessage)
The message to print on failure.
|
DefaultCondition<T> |
withTimeoutFactor(double newFactor)
Sets a factor to speed up or slow down tests.
|
public DefaultCondition(@Nonnull Expression<T> expression, @Nonnull Timeout timeout)
public final T get()
Conditionget in interface Condition<T>Expression.get()public final T await()
ConditionRetrieve the result of the condition as soon as it is evaluated without any exception.
public T await(@Nonnull org.hamcrest.Matcher<? super T> matcher)
ConditionWait for the condition value until it fulfills the given matcher and return it.
public void waitUntil(@Nonnull org.hamcrest.Matcher<? super T> matcher)
ConditionMatcher to wait until a condition is met in time.public void waitUntilEquals(@Nullable T expected)
ConditionWait until the condition evaluates to the expected value within a given time.
waitUntilEquals in interface Condition<T>expected - expected valuepublic void assumeThat(@Nonnull org.hamcrest.Matcher<? super T> matcher)
ConditionMatcher to assume that a condition is met in time.assumeThat in interface Condition<T>matcher - the matcher to usepublic final void assumeEquals(@Nullable T expected)
ConditionAssumes that the condition evaluates to the expected value within a given time.
assumeEquals in interface Condition<T>expected - expected valuepublic void assertThat(@Nonnull org.hamcrest.Matcher<? super T> matcher)
ConditionMatcher to assert that a condition is met in time.assertThat in interface Condition<T>matcher - the matcher to usepublic final void assertEquals(@Nullable T expected)
ConditionAssert that the condition evaluates to the expected value within a given time.
assertEquals in interface Condition<T>expected - expected value@Nonnull public DefaultCondition<T> runFinally(@Nullable Runnable runnable)
FailSafeConditionrunFinally in interface FailSafeCondition<T>runnable - runnable to execute; null to disable execution@Nonnull public DefaultCondition<T> runBefore(@Nullable Runnable runnable)
FailSafeConditionrunBefore in interface FailSafeCondition<T>runnable - runnable to execute; null to disable execution@Nonnull public DefaultCondition<T> withTimeoutFactor(@Nonnegative double newFactor)
ConditionwithTimeoutFactor in interface Condition<T>withTimeoutFactor in interface FailSafeCondition<T>newFactor - factor by which to increase the timeout for this condition@Nonnull public DefaultCondition<T> withMessage(@Nullable String newMessage)
ConditionwithMessage in interface Condition<T>withMessage in interface FailSafeCondition<T>newMessage - message with debugging hints; null to remove the messageCopyright © 2011-2017 CoreMedia AG. All Rights Reserved.