Test Data Generator for EPCIS Events
Generate EPCIS test events in JSON/JSON-LD or XML for any use case or supply chain, from a single demo event to millions for a load test.
Quick links
The Test Data Generator appears as two pages in OpenEPCIS Tools. Both run on the same generator and produce the same kind of EPCIS events. They differ in how you describe the events you want:
• Event Data Generator: fill in a form with the event details and generate the events.
• Event Data Designer: simulate your supply chain as connected steps and generate linked events.
• Test data generator API endpoint: https://tools.openepcis.io/q/swagger-ui/#/Test%20Data%20Generator
• Test data generator application code: https://github.com/openepcis/epcis-testdata-generator
Introduction
Traceability of goods and assets, process automation, compliance and supply chain management all depend on the same thing: you and your trading partners have to capture and share visibility data alongside master data (such as the description and weight of a trade item) and transactional data (such as an order or an invoice). EPCIS is the open standard for this category of data. It is endorsed by GS1, ISO and IEC and already in wide use across many industries.
EPCIS comes with a ready-to-use data model that consolidates every stage of a business process into a single dataset. Each EPCIS event records what happened, when, where, why and how. Items become traceable when every relevant event along the supply network is recorded, from harvesting and production through packing and shipping to the sale.
Need for EPCIS Test Data Generator
End users, solution providers and research institutions regularly need EPCIS test data: for load and performance tests, for proof-of-concept work, to populate test databases and to start data exchange with business partners. Writing those events by hand is tedious. The Test Data Generator lets you describe supply chain shapes such as commissioning, packing, shipping and transformation as a template and produces conformant EPCIS events from it. Because it builds events on a reactive streaming pipeline, it can produce a single event for a demo or millions of events for a load test without holding the full output in memory.
OpenEPCIS test data generator
The first version of the generator was developed as part of a master's thesis in collaboration with GS1 Germany between June and November 2020. Users from the EPCIS community took part in the development, which let the application grow along their needs and requirements. The current version was developed further at benelog GmbH & Co. KG and adds many improvements and more advanced functionality. It is an open-source project, so anyone who is adopting or implementing EPCIS can use it.
The generator works for any industry, use case or application domain, and the events it produces follow the current specification, EPCIS 2.0. The API returns JSON/JSON-LD. The web pages also show the events as EPCIS 2.0 XML, and the Format Converter turns JSON events into XML according to EPCIS 1.2 or 2.0.
Key Features
• follows the most recent revisions of CBV 2.0 and EPCIS 2.0;
• supports object and location IDs as GS1 Digital Link URIs as well as EPC/EPC Class URIs;
• generates JSON/JSON-LD events and shows them as EPCIS 2.0 XML in the web pages;
• randomizes elements such as timestamps and serial numbers;
• identifies events with UUIDs or with EPCIS Event Hash IDs;
• models event sequences tailored to your process;
• lets you copy or export designs and events for later use.
Local set-up
The quickest way to run the Test Data Generator locally is the Testdata Generator Container Image published on GitHub. You need Docker or Podman installed:
• Docker Desktop for Windows, macOS or Linux. Note that commercial use of Docker Desktop is subject to license restrictions.
• Podman, an open-source alternative.
Then start the container with one of the commands below in a terminal or command prompt.
Docker
docker run --rm -t --name testdata-generator -p 8080:8080 ghcr.io/openepcis/testdata-generator:latest
Podman
podman run --rm -t --name testdata-generator -p 8080:8080 ghcr.io/openepcis/testdata-generator:latest
Native Testdata Generator Quarkus REST App Artifacts
The service runtime is also available as a Quarkus native build. Quarkus native builds take longer to build and in return start faster and use less memory, which helps when the generator runs as a container in a CI pipeline. The latest native binaries are on the GitHub release page https://github.com/openepcis/epcis-testdata-generator/releases/, one per platform:
| Filename | Platform |
|---|---|
| testdata-generator-quarkus-rest-app-runner-${VERSION}-linux-amd64 | Linux (AMD64) |
| testdata-generator-quarkus-rest-app-runner-${VERSION}-linux-arm64 | Linux (ARM64) |
| testdata-generator-quarkus-rest-app-runner-${VERSION}-mac | macOS |
| testdata-generator-quarkus-rest-app-runner-${VERSION}-windows.exe | Windows |
Replace ${VERSION} with the version number of the release. A generic .jar file is available as well: testdata-generator-quarkus-rest-app-${VERSION}.jar
A multi-architecture native container image is published at github.com/openepcis/epcis-testdata-generator/pkgs/container/testdata-generator-native.
Usage
You can generate events in the web application, through the API in Swagger-UI or from the command line.
Web application
The web application suits users who are new to EPCIS. Use the Event Data Generator to fill in the fields for an event, or the Event Data Designer to model a sequence of steps. Both show the result as a table, as JSON and as XML. The web pages accept up to 1,000 events per event; for more, use the API or the command line below.
API endpoint
Developers who want to see what the request and response bodies of the underlying API look like will find them in Swagger-UI, an open-source application that renders every API of an OpenAPI description as a web page with a summary and an illustration of each request and response body.
With a container running as described in the set-up section, Swagger-UI is at
http://localhost:8080/q/swagger-ui/, and you can send requests with an input
template to the Test Data Generator API from there. Swagger-UI has no limit on the
number of events, unlike the web application, although it is slower than the
command line.
Command Line
For large amounts of test data, meaning more than 1,000 events, send a cURL (Client URL) request from your terminal. With the container from the set-up section running, post your
input template to http://localhost:8080/api/generateTestData?pretty=true. Here is a request with a sample InputTemplate that you can replace with your own:
curl -X 'POST' \
'http://localhost:8080/api/generateTestData?pretty=true' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"events": [
{
"nodeId": 1,
"eventType": "ObjectEvent",
"eventCount": 10,
"locationPartyIdentifierSyntax": "URN",
"ordinaryEvent": true,
"action": "ADD",
"eventID": false,
"eventTime": {
"timeZoneOffset": "+02:00",
"fromTime": "2022-10-01T10:22:16+02:00",
"toTime": "2022-10-31T10:22:16+02:00"
},
"businessStep": "COMMISSIONING",
"disposition": "ACTIVE",
"referencedIdentifier": [
{
"identifierId": 1,
"epcCount": 10,
"classCount": 0
}
],
"parentReferencedIdentifier": {},
"outputReferencedIdentifier": []
}
],
"identifiers": [
{
"identifierId": 1,
"objectIdentifierSyntax": "URN",
"instanceData": {
"sgtin": {
"identifierType": "sgtin",
"gcpLength": 10,
"sgtin": "40584954485984",
"serialType": "random",
"randomCount": 10,
"randomType": "NUMERIC",
"randomMinLength": 2,
"randomMaxLength": 10
}
},
"classData": null,
"parentData": null
}
]
}'
Application code
The two main modules are testdata-generator-common and testdata-generator-rest-api.
testdata-generator-common (Generic java library for generating testdata events)
The core module generates the events. It contains the generation logic and formats the values according to the EPCIS standard. It follows the Reactive Streams approach and keeps only one event in memory at a time, which keeps memory use low and lets it produce large numbers of events quickly. It is written in Java with libraries such as Jackson, Lombok and SmallRye Mutiny.
testdata-generator-rest-api (REST service wrapper for generating testdata events)
The REST service is the entry point to the generator. It receives an InputTemplate, validates it against all constraints and rules, and passes a valid template to testdata-generator-common, which generates the events. You can also call the service directly with cURL or from Swagger-UI. It is written in Java on the Quarkus framework with libraries such as Jackson, OpenAPI and Hibernate Validator.
Direct usage
The EPCISEventGenerator class
within testdata-generator-common provides the Java method generate, which you can
call from your own code. It takes an InputTemplate object (io.openepcis.testdata.generator.template.InputTemplate), the Java form of the JSON sample below, and streams the
generated events one at a time:
// generate() streams the events one at a time; print each as it arrives
EPCISEventGenerator.generate(inputTemplate).subscribe().asStream().forEach(System.out::println);
Sample inputTemplate:
{
"events": [
{
"nodeId": 1,
"eventType": "ObjectEvent",
"eventCount": 5,
"locationPartyIdentifierSyntax": "URN",
"ordinaryEvent": true,
"action": "ADD",
"eventID": true,
"eventTime": {
"timeZoneOffset": "+02:00",
"fromTime": "2022-04-01T18:30:04+02:00",
"toTime": "2022-04-05T18:30:04+02:00"
},
"recordTimeType": "CURRENT_TIME",
"businessStep": "COMMISSIONING",
"disposition": "ACTIVE",
"referencedIdentifier": [
{
"identifierId": 1,
"epcCount": 10,
"classCount": 5
}
],
"parentReferencedIdentifier": {},
"outputReferencedIdentifier": []
}
],
"identifiers": [
{
"identifierId": 1,
"objectIdentifierSyntax": "URN",
"instanceData": {
"sgtin": {
"identifierType": "sgtin",
"gcpLength": 10,
"sgtin": "89384989388934",
"serialType": "range",
"rangeFrom": 100,
"rangeTo": 110
}
},
"classData": {
"grai": {
"identifierType": "grai",
"gcpLength": 10,
"quantityType": null,
"uom": null,
"serialType": "",
"grai": "8384783874378",
"classIdentifiersCount": 5
}
},
"parentData": null
}
]
}