public abstract class Ordering
extends java.lang.Object
Ordering can reverse the order of tests, sort the
order or even shuffle the order.
In general you will not need to use a Ordering directly.
Instead, use Request.orderWith(Ordering).
| Modifier and Type | Class and Description |
|---|---|
static class |
Ordering.Context
Context about the ordering being applied.
|
static interface |
Ordering.Factory
Factory for creating
Ordering instances. |
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
CONSTRUCTOR_ERROR_FORMAT |
| Constructor and Description |
|---|
Ordering() |
| Modifier and Type | Method and Description |
|---|---|
void |
apply(java.lang.Object target)
Order the tests in
target using this ordering. |
static Ordering |
definedBy(java.lang.Class<? extends Ordering.Factory> factoryClass,
Description annotatedTestClass)
Creates an
Ordering from the given factory class. |
static Ordering |
definedBy(Ordering.Factory factory,
Description annotatedTestClass)
Creates an
Ordering from the given factory. |
private static java.lang.String |
getClassName(java.lang.Class<?> clazz) |
protected abstract java.util.List<Description> |
orderItems(java.util.Collection<Description> descriptions)
Implemented by sub-classes to order the descriptions.
|
static Ordering |
shuffledBy(java.util.Random random)
Creates an
Ordering that shuffles the items using the given
Random instance. |
(package private) boolean |
validateOrderingIsCorrect()
Returns
true if this ordering could produce invalid results (i.e. |
private static final java.lang.String CONSTRUCTOR_ERROR_FORMAT
public static Ordering shuffledBy(java.util.Random random)
Ordering that shuffles the items using the given
Random instance.public static Ordering definedBy(java.lang.Class<? extends Ordering.Factory> factoryClass, Description annotatedTestClass) throws InvalidOrderingException
Ordering from the given factory class. The class must have a public no-arg
constructor.factoryClass - class to use to create the orderingannotatedTestClass - test class that is annotated with OrderWith.InvalidOrderingException - if the instance could not be createdpublic static Ordering definedBy(Ordering.Factory factory, Description annotatedTestClass) throws InvalidOrderingException
Ordering from the given factory.factory - factory to use to create the orderingannotatedTestClass - test class that is annotated with OrderWith.InvalidOrderingException - if the instance could not be createdprivate static java.lang.String getClassName(java.lang.Class<?> clazz)
public void apply(java.lang.Object target)
throws InvalidOrderingException
target using this ordering.InvalidOrderingException - if ordering does something invalid (like remove or add
children)boolean validateOrderingIsCorrect()
true if this ordering could produce invalid results (i.e.
if it could add or remove values).protected abstract java.util.List<Description> orderItems(java.util.Collection<Description> descriptions)