public abstract class TestObjects extends Object
TestObjects provides a utility which calls setters of an object of *Builder type and returns the resulting builder object.
The exported static methods are <T>fill(T,String) and <T>fillPage(T,String). The T argument is a builder object, and the String is a
modifier which is used to augment the String values set. fill(b) is equivalent to fill(b,"") and fillPage(b) is equivalent to fillPage(b,"").
TestObjects is designed to populate builder objects with test values. Object setters are called with standard values based upon the parameter type and the name of the setter method.
Setters which take collections or Singular generated setters are ignored.
String types are set to "test-"+modifier+settername, where modifier is supplied on the call fill(b,modifier) or fillPage(b,modifier).Boolean types are set to true.Integer or Long types are set to 1.Float or Double types are set to 1.0.Entity or Metadata1 are recursively filled, using fill(builder-of-type, modifier), if their builder types can be found.Paginated builder objects1 (built type subclassing PaginatedRequest or PaginatedResponse) can only be filled with fillPage(T) (which will call Assert.fail() if the builder does not build a paginated type). The setters are treated specially, to set page request fields consistently with the operations
implementations. In particular the setters resultsPerPage and orderDirection are not set.
fill(T) will call Assert.fail() if the builder object builds an object of paginated type.
If fillPage(T) or fill(T) recurses (on Entity or Metadata types), it is assumed that these are not paginated.
1These special cases make the TestObjects class specific to v2 CloudFoundry REST api interfaces.
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
fill(T builder)
Fill the builder "fields" by calling their setters with default values.
|
static <T> T |
fill(T builder,
String modifier)
Fill the builder "fields" by calling their setters with default values.
|
static <T> T |
fillPage(T builder)
Fill the builder "fields" by calling their setters with default values.
|
static <T> T |
fillPage(T builder,
String modifier)
Fill the builder "fields" by calling their setters with default values.
|
public static <T> T fill(T builder)
T - the type of the builder objectbuilder - an object of type T which is a builder typepublic static <T> T fill(T builder,
String modifier)
T - the type of the builder objectbuilder - an object of type T which is a builder of a type which is not paginatedmodifier - a modifier for String types which are setpublic static <T> T fillPage(T builder)
T - the type of the builder objectbuilder - an object of type T which is a builder typepublic static <T> T fillPage(T builder,
String modifier)
T - the type of the builder objectbuilder - an object of type T which is a builder of a paginated typemodifier - a modifier for String types which are setCopyright © 2016 Pivotal Software, Inc.. All rights reserved.