public abstract class TestObjects extends Object
TestObjects provides a generic utility which transforms a builder object of type T, by calling its configuration methods with default values.
A builder object of type T is an object with a build() method returning a built object whose type has a builder of type T.
A built object of type B is an object with a builder() method returning a builder object which builds type B.
The exported static methods are T fill(T, String) and T fill(T). The T argument must be an object of builder type (which is returned as result),
and the String is a modifier which is used to augment the String values set. The modifier must not be null.
fill(b) is equivalent to fill(b, "").
TestObjects populates builder objects with test values. Builder setter methods are called with standard values based upon the parameter type and the name of the setter method.
enum types are set to the first enumerated constant value.Boolean types are set to true.Date types are set to new Date(0).Double types are set to 1.0.Duration types are set to a duration of 15 seconds.Integer or Long types are set to 1.Iterable types are set to empty.Map types are set to empty.String types are set to "test-"+modifier+settername.fill()ed builder instance.Only public, chainable, single-parameter setter methods which have a corresponding getter (on the type built) are configured.
Non-builder objects, or builder objects that build *Request types, are rejected (by assertion failure).
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
fill(T builder)
Fill a builder by calling its configuration methods with default values.
|
static <T> T |
fill(T builder,
String modifier)
Fill a builder by calling its configuration methods with default values.
|
Copyright © 2016 Pivotal Software, Inc.. All rights reserved.