@Retention(value=RUNTIME) @Target(value={FIELD,PARAMETER,ANNOTATION_TYPE}) @Documented public @interface Random
Usage example:
// create a random instance of String
@Random String anyString;
// create a random, fully populated instance of MyDomainObject
@Random private DomainObject fullyPopulatedDomainObject;
// create a random, partially populated instance of MyDomainObject, ignoring these fields: "wotsits", "id", "nestedDomainObject.address"
@Random(excludes = {"wotsits", "id", "nestedDomainObject.address"}) MyDomainObject partiallyPopulatedDomainObject;
// create a List containing the default size of randomly generated instances of String
@Random(type = String.class) List anyStrings;
// create a Stream containing two randomly generated instances of MyDomainObject
@Random(size = 2, type = MyDomainObject.class) Stream anyStrings;
| Modifier and Type | Optional Element and Description |
|---|---|
String[] |
excludes
When generating a random type you may want to exclude some properties
|
int |
size
When generating a collection of random type you may want to limit its size.
|
Class<?> |
type
When generating a collection of random type you'll want to tell the generator what that type
is.
|
public abstract String[] excludes
public abstract int size
public abstract Class<?> type
Copyright © 2022. All rights reserved.