Skip to content

Commit 9738004

Browse files
committed
updated README to reflect the implemented changes
1 parent a5d89aa commit 9738004

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

README.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
## Overview
66
This project implements a Groovy DSL that can be used to populate a database using JPA entities. Its indented use is testing but it could be used in other scenarios as well.
7-
The DSL is implemented in Groovy but can be used from pure Java. Entities are modularly defined in separate .groovy files using the DSL syntax. Those entitiy definition files can then be loaded as needed using the `de.triology.blog.testdataloader.TestDataLoader`, which also provides access to loaded entities. Thus, the client code does not need to deal with any database or JPA specific concerns other than providing an initialized EntityManager.
7+
The DSL is implemented in Groovy but can be used from pure Java. Entities are modularly defined in separate .groovy files using the DSL syntax. Those entity definition files can then be loaded as needed using the `de.triology.blog.testdata.loader.TestDataLoader`, which also provides access to loaded entities. Thus, the client code does not need to deal with any database or JPA specific concerns other than providing an initialized EntityManager.
88

99
This project was started while working on an article published in [Java aktuell](http://www.ijug.eu/java-aktuell/das-magazin.html) 03/2017:
1010
[A Groovy DSL for the Creation of Test Data using JPA](https://www.triology.de/en/blog-entries/groovy-dsl-test-data).
11-
The original article (🇩🇪) can be found here: [Eine Groovy-DSL zum Erzeugen von Testdaten über JPA](https://www.triology.de/wp-content/uploads/2017/09/Eine-Groovy-DSL-zum-Erzeugen-von-Testdaten-ueber-JPA.pdf).
11+
The original article (🇩🇪) can be found here: [Eine Groovy-DSL zum Erzeugen von Testdaten über JPA](https://www.triology.de/wp-content/uploads/2017/09/Eine-Groovy-DSL-zum-Erzeugen-von-Testdaten-ueber-JPA.pdf).
12+
13+
Please note that from version 1.x the implementation as described in the article referenced above has changed. For more information about the changes, please refer to the release notes of each [release](https://github.com/triologygmbh/test-data-loader/releases).
1214

1315
## Configuration
1416
You can use JitPack to configure the test-data-loader as a dependency in your project.<br/>
@@ -26,22 +28,21 @@ And the test-data-loader dependency:
2628
<dependency>
2729
<groupId>com.github.triologygmbh</groupId>
2830
<artifactId>test-data-loader</artifactId>
29-
<version>0.2.1</version>
31+
<version>${version.test-data-loader}</version>
3032
</dependency>
3133
```
3234
Current version is [![](https://jitpack.io/v/triologygmbh/test-data-loader.svg)](https://jitpack.io/#triologygmbh/test-data-loader).<br/>
3335
For further details and options refer to the [JitPack website](https://jitpack.io/#triologygmbh/test-data-loader).
3436

3537
## Usage
36-
An example entity definition can be found here: https://github.com/triologygmbh/test-data-loader/blob/master/src/test/resources/demo/testData.groovy
38+
An example entity definition Groovy script file can be found here: https://github.com/triologygmbh/test-data-loader/blob/master/src/test/resources/tests/itTestData.groovy
3739

38-
And [`de.triology.blog.testdataloader.demo.Demo`](https://github.com/triologygmbh/test-data-loader/blob/master/src/test/java/de/triology/blog/testdataloader/demo/Demo.java) shows how to load that file. (Notice that `Demo` is a Java class.)
40+
The [`de.triology.blog.testdata.loader.TestDataLoaderIT`](https://github.com/triologygmbh/test-data-loader/blob/master/src/test/java/de/triology/blog/testdata/loader/TestDataLoaderIT.java) integration test shows how to load that file.
3941

4042
### Entity Definitions
41-
Use the following syntax in a separate .groovy file to define a `User` entity. The entitiy will be created, persisted and registered under the name "Peter" when the definition file is loaded. _**Note:** Entity definition files are expected to be UTF-8 encoded._
43+
Use the following syntax in a separate .groovy file to define a `User` entity. The entity will be created, persisted and registered under the name "Peter" when the definition file is loaded. _**Note:** Entity definition files are expected to be UTF-8 encoded._
4244
```Groovy
43-
import static de.triology.blog.testdataloader.EntityBuilder.create
44-
import de.triology.blog.testdataloader.demo.User
45+
import de.triology.blog.testdata.loader.testentities.User
4546
4647
create User, 'Peter', {
4748
id = 123
@@ -53,9 +54,8 @@ create User, 'Peter', {
5354
```
5455
Create nested entities by simply nesting their definitions:
5556
```Groovy
56-
import static de.triology.blog.testdataloader.EntityBuilder.create
57-
import de.triology.blog.testdataloader.demo.User
58-
import de.triology.blog.testdataloader.demo.Department
57+
import de.triology.blog.testdata.loader.testentities.User
58+
import de.triology.blog.testdata.loader.testentities.Department
5959
6060
create User, 'Peter', {
6161
// ...
@@ -67,9 +67,8 @@ create User, 'Peter', {
6767
```
6868
And reference previously created entities by their name like so:
6969
```Groovy
70-
import static de.triology.blog.testdataloader.EntityBuilder.create
71-
import de.triology.blog.testdataloader.demo.User
72-
import de.triology.blog.testdataloader.demo.Department
70+
import de.triology.blog.testdata.loader.testentities.User
71+
import de.triology.blog.testdata.loader.testentities.Department
7372
7473
create User, 'Peter', {
7574
// ...
@@ -86,10 +85,9 @@ create User, 'Tinker', {
8685
department = lostBoys
8786
}
8887
```
89-
Since entity definition files are just plain Groovy scripts you are free to use any control structures like loops and conditions, e.g.:
88+
Since entity definition files are just plain Groovy scripts, you are free to use any control structures, like loops and conditions, e.g.:
9089
```Groovy
91-
import static de.triology.blog.testdataloader.EntityBuilder.create
92-
import de.triology.blog.testdataloader.demo.User
90+
import de.triology.blog.testdata.loader.testentities.User
9391
9492
5.times { count ->
9593
create User, "user_$count", {
@@ -109,8 +107,8 @@ For now, we must work around this, by setting the field to `protected` or creati
109107
See [this issue](https://github.com/triologygmbh/test-data-loader/issues/7).
110108

111109
### Loading entity definitions
112-
Use the `de.triology.blog.testdataloader.TestDataLoader` to load entitiy definition files (from classpath or file system) and persist the defined entities.
113-
The `TestDataLoader` requires a fully initialized, ready-to-use entitiy manager and can then be used to load entity definition files and access the persisted entities.
110+
Use the `de.triology.blog.testdata.loader.TestDataLoader` to load entity definition files (from classpath or file system) and persist the defined entities.
111+
The `TestDataLoader` requires a fully initialized, ready-to-use `EntityManager` and can then be used to load entity definition files and access the persisted entities.
114112
```Java
115113
EntityManager entityManager = // ... init EntityManager
116114
TestDataLoader testDataLoader = new TestDataLoader(entityManager);
@@ -124,7 +122,7 @@ assert "Bell".equals(tinker.getLastName());
124122
```
125123

126124
### Clean up afterwards
127-
To reset the database as well as the TestDataLoader to a clean state after a test case simply call `testDataLoader.clear()`. That will delete all created entites from the database and from TestDataLoader's entity cache.
125+
To reset the database as well as the TestDataLoader to a clean state after a test case simply call `testDataLoader.clear()`. That will delete all created entities from the database and from TestDataLoader's entity cache.
128126

129127
## Tested with...
130128

@@ -135,4 +133,4 @@ We have approved TestDataLoader in multiple projects and use cases including
135133
* Integration tests with arquillian, IBM WebSphere Liberty Profile and IBM DB2
136134

137135
## Contributions
138-
The test-data-loader has been derived and generalized from real world development projects but has yet to prove itself as standalone library. **Any feedback or contributions are highly welcome!**
136+
The test-data-loader has been derived and generalized from real world development projects but has yet to prove itself as stand-alone library. **Any feedback or contributions are highly welcome!**

0 commit comments

Comments
 (0)