Skip to content
Ignacio Tomas Crespo edited this page Mar 16, 2017 · 2 revisions

Welcome to the Mr Polite wiki!

Polite Desires

withDepth

By default Mr Polite will search 3 levels in the fields hierarchy to create objects.

Parameters:

depth - how many levels

withNumberRange

A range for all the fields containing numbers.

Parameters:

min - the minimum

max - the maximum

withStringsMaxLength

The maximum length for all the generated strings.

Parameters:

len - the maximum length

withFieldNamesInStrings

Generate strings using the field name. For instance, a field String name; will contain the value "name".

withFieldEqualTo

Set a specific value in some fields, searching by name.

Parameters:

fieldNameRegex - A regular expression to identify the field by name.

value - the value to set

withClassEqualTo

Set a specific value in fields with a specific type.

Type Parameters:

K - the class and the value must be of the same type

Parameters:

clazz - the type of the field

value - the value to set

withFieldImageLink

Set a http link to an image, on fields searching by name. It creates a link using the excellent service "http://lorempixel.com".

Parameters:

fieldNameRegex - A regular expression to identify the field by name.

width - the image width

height - the image height

withSeed

A seed to randomize the generated values. Useful when you want to generate the same values, for instance, for testing purposes.

Parameters:

seed - the seed value

withCollectionSizeRange

Mr Polite will try to create collections/arrays. Define here a range for the desired size.

Parameters:

min - the minimum size

max - the maximum size

exclude

Exclude fields searching by name. The excluded fields will not be changed.

Parameters:

fieldNameRegex - A regular expression to identify the field by name.

exclude

Exclude fields searching by type. The excluded fields will not be changed.

Parameters:

clazz - The type to be ignored.

withGenerics

Mr Polite needs to know which types must be used in the generic fields. For instance:

Listener<Foo> listener = MrPolite.one(Listener.class).please();

Mr Polite doesn't know you want a type Foo in the generics, so you must specify it.

Listener<Foo> listener = MrPolite.one(Listener.class).withGenerics(Foo.class).please();

Parameters:

clazz - the class or classes to use for generics. The number of classes must be the same number of generics declared in the expected object.

overrideValues

By default all the values in all the fields are set to a new value. Here the default behavior can be changed.

Parameters:

override - true to override all values, false otherwise.

overrideFinals

By default all final values in all the fields are not touched. Here you can force to override them, useful for Kotlin data classes.