Default Behaviour - FlexTradeUKLtd/jfixture GitHub Wiki
The following is a table outlining the default behaviour of JFixture. This applies if no customisations or custom builders have been added to the JFixture instance.
| Data Type | Value/s |
|---|---|
| Boolean | Alternate between TRUE and FALSE |
| Number* | Random integer; range from [1-127], then [128-32766], etc |
| String | UUID** |
| UUID | UUID |
| Character | Random; 'a'-'z' |
| Date | Random; now +-2 years |
| Calendar | Gregorian, random date; now +-2 years |
| Primitives | Boxed equivilant |
| Array | Populated array*** |
| Iterable, List | Populated ArrayList*** |
| Map | Populated HashMap*** |
| Set | Populated HashSet*** |
| Queue | Populated ArrayDeque*** |
| Enum | Shuffles values and cycles through them |
| Type/Class | Invokes smallest constructor |
| Abstract Class/Interface | Undefined**** |
*Supported Numbers are Byte, Short, Integer, Long, Float, Double, BigDecimal, BigInteger and their primitive versions where applicable
**Prefixed with field/property name where applicable
***All collection type objects are populated with 3 items by default
****For abstract classes/interfaces not covered by the default behaviour a SubTypeCustomisation could be used.
This is process involved in creating a type
- Construct instance of requested type
- Priority given to constructors, ordered by ascending parameter count
- If that fails look for factory methods (public, static methods with return type assignable to declaring type), ordered by ascending parameter count
- Create instances of all parameter types
- Invoke construction method (constructor or factory method) with parameters values
- Find all settable properties (getter, setter pairs with one argument in the setter)
- Create instance of parameter type
- Call the setter with the parameter instance
- Repeat for all settable properties
- Find all settable fields (public, non-final, non-static)
- Create instance of field type
- Invoke set method on the field with the parameter instance
- Repeat for all settable fields
- Return object
If a recursive call (Type Foo has property Bar which has property Foo) is identified JFixture will throw an exception with a detailed error message explaining which type caused the problem. You should redesign your classes to remove the cyclic dependency, or customise JFixture to prevent it resolving the problem area.