Bean Property Generator

Supports unit testing by dynamically creating bean objects and populating their fields to default values.

License

License

GroupId

GroupId

com.gregmarut.support
ArtifactId

ArtifactId

test-beangen
Last Version

Last Version

2.7-RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

Bean Property Generator
Supports unit testing by dynamically creating bean objects and populating their fields to default values.
Project URL

Project URL

https://github.com/gregmarut/test-beangen/
Source Code Management

Source Code Management

https://github.com/gregmarut/test-beangen/

Download test-beangen

How to add to project

<!-- https://jarcasting.com/artifacts/com.gregmarut.support/test-beangen/ -->
<dependency>
    <groupId>com.gregmarut.support</groupId>
    <artifactId>test-beangen</artifactId>
    <version>2.7-RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/com.gregmarut.support/test-beangen/
implementation 'com.gregmarut.support:test-beangen:2.7-RELEASE'
// https://jarcasting.com/artifacts/com.gregmarut.support/test-beangen/
implementation ("com.gregmarut.support:test-beangen:2.7-RELEASE")
'com.gregmarut.support:test-beangen:jar:2.7-RELEASE'
<dependency org="com.gregmarut.support" name="test-beangen" rev="2.7-RELEASE">
  <artifact name="test-beangen" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.gregmarut.support', module='test-beangen', version='2.7-RELEASE')
)
libraryDependencies += "com.gregmarut.support" % "test-beangen" % "2.7-RELEASE"
[com.gregmarut.support/test-beangen "2.7-RELEASE"]

Dependencies

compile (1)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.7

test (2)

Group / Artifact Type Version
org.slf4j : slf4j-log4j12 jar 1.7.7
junit : junit jar 4.4

Project Modules

There are no modules declared in this project.

test-beangen

Supports unit testing by dynamically creating bean objects and populating their fields to default values.

Maven Repository: http://mvnrepository.com/artifact/com.gregmarut.support/test-beangen

##Getting Started The easiest way to use the framework is to create a new BeanPropertyGenerator object and call the .get() method while passing in the class that you would like to be fully populated. The bean generator will then attempt to instantiate the class and traverse the entire object graph and recursively initialize all of the fields. It will then return an object with all of its fields initialized according to the default values or Rules (if any have been specified)

Example: BeanPropertyGenerator beanPropertyGenerator = new BeanPropertyGenerator(); SomeObject someObject = beanPropertyGenerator.get(SomeObject.class);

##Default Values By default, com.gregmarut.support.beangenerator.DefaultValues simply contains a Map of Class and Object which allows the framework to know what the default values should be considering the object type. If the map contains an object for a class, whenever that class is found, it is used instead of attempting to recursively initialize the object.

##Configuration BeanPropertyGenerator has a Properties object which stores the instructions for how fields are populated. These can be completely customized by either changing or setting new default values for a class, map concrete classes to interfaces, or set Rule objects that allow for unique values to be set based on attributes of the field name and type.

##Examples See the unit tests for more examples on how to use and configure the BeanPropertyGenerator to help automate your unit testing needs.

Versions

Version
2.7-RELEASE
2.6.1-RELEASE
2.6-RELEASE
2.5-RELEASE
2.4-RELEASE
2.3-RELEASE
2.0
1.2.4