RedG

Ridiculously Easy Data Generation

RedG makes modelling database test data for unit tests incredibly simple.
It reduces modelling to the theoretically reachable minimum.

RedG redG = new RedG(); GCustomer c = redG.addCustomer().firstName("Joe"); redG.addCreditCard(c).cardNumber(1234_5678_8765_4321); redG.insertDataIntoDatabase(jdbcConnection);

Focus on the important stuff

Only model what you really need, RedG takes care of the rest. No need to specify any attributes that you are not interested in, even if they are technically mandatory! RedG provides default values and generates dummy entities for you.

Compile-Time is when errors should occur

RedG leverages the power of the Java compiler to check for type safety and data integrity. Errors occur while writing test data, not at run-time. No more super long round trips for fixing these kinds of errors in your test data!

It's Java with all its power

You write your code in Java. So why not write your test data in Java? With RedG you enjoy all the power of the Java language: Loops, conditions, random values, fantastic IDE support...

Customizable to your very needs

Every project has its own requirements, code style and conventions. We understand that and made every part of RedG as customizable as possible while keeping it easy to use. It'll fit perfectly into your project as well!

How it works

1. RedG generates Java classes

RedG generates a Java API that matches your database schema. You get an easy-to-use fluent API that is type-safe and references other entities via object references instead of the foreign key values.

2. RedG provides default values

RedG redG = new RedG(); GCustomer c = redG.addCustomer() .lastName("Smith"); redG.addCreditCard(c) .cardNumber(1234_5678_8765_4321); redG.insertDataIntoDatabase(jdbcConnection);
CUSTOMER
ID 123
LAST_NAME 'Smith'
FIRST_NAME '-'
DATE_OF_BIRTH 1970-01-01T00.00.00Z
ADDRESS_ID NULL
CREDIT_CARD
CARD_NUMBER 1234567887654321
CVC 0
CARD_HOLDER '-'
ISSUING_BANK_ID NULL
CUSTOMER_ID 123

All the values that are marked red are non-nullable fields. You do not need to specify values for those, if you omit them RedG generates default values. As you can see, the foreign key to the credit card is automatically inserted by RedG based on the object reference.

3. RedG generates dummy entities

RedG redG = new RedG(); redG.addCustomer(redG.dummyBank(), redG.dummyAddress()) .lastName("Smith"); redG.insertDataIntoDatabase(jdbcConnection);

If your schema has many mandatory foreign keys but your test case does not require them, RedG can generate complete dummy entities. Note that dummies are transitively generated. In this case, the dummy factory reuses existing dummies, but you can provide your own implementation.

Features

Dummy data generation

Only specify the data you really need. RedG generated default values for columns and can create complete dummy entities for use in foreign key relations. And everything is highly customizable, so it can fit even the most complex requirements.

Visualizer

Need to debug your test data set? Simply visualize the current state of your data with the RedG Visualizer. Enable the visualization support for the generated code, call redG.getVisualization(), paste the JSON into the visualizer and see your complete data with all dependencies, the default values RedG generated and more.

Data extractor

Migration never was that easy. Simply extract all the data from an existing database and get the matching RedG code. Afterwards you can start to reduce your data to the needed minimum and let RedG do the rest.

JPA support

When generating the code for your database schema RedG can read the name and type information from a JPA metamodel. This makes configuration far easier when using JPA in your project.

Maven Integration

The RedG Code Generator can be integrated into your project via a Maven plugin. If you are not using Maven you can use an easy API as a powerful and flexible alternative.

Use other data

Need to use another framework to get data into your database? Want to reference entities that are already present in your database from within RedG? No problem.

SQL or JDBC

You have the freedom of choice. Either let RedG generate SQL statements or let it insert the data directly via JDBC.

Supported databases

Works with Oracle, H2, MySQL, Postgres and many more...

Interested?

Fine!
Documentation Visualizer GitHub