Test Data Generator for EPCIS 2.0 Events and JSON-LD

Generate EPCIS 2.0 test events in JSON/JSON-LD for any use case or supply chain, from a single demo event to millions for a load test.

The web application, the API and the source code are linked below. Trying the tool while you read is the quickest way to learn it:

• Test data generator web application: https://tools.openepcis.io/

• 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. Its output is JSON/JSON-LD. Businesses that need XML, either according to EPCIS 1.2 or 2.0, can convert the events with other open-source tools.

Key Features

The generator:

• 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, which other tools can translate to XML;

• 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 Test Data Generator can be set up locally in several ways. The quickest is a container started with Podman or Docker.

Running with Podman

Podman is an open-source platform for developing, testing and deploying applications, and it has to be installed first. These pages describe Podman and its installation:

Official Podman: https://github.com/containers/podman\ Documentation: https://github.com/containers/podman/tree/main/docs\ Installation instructions for Windows/macOS: https://podman.io/getting-started/installation

Once Podman is installed, run this command in a terminal or command prompt:

podman run --rm -t --name testdata-generator -p 8080:8080 openepcis/testdata-generator

Running with Docker or Podman

For this route Docker has to be installed on your system. Note that commercial use of Docker is subject to license restrictions. These pages describe the installation:

For Windows: https://docs.docker.com/desktop/install/windows-install/\ For macOS: https://docs.docker.com/desktop/install/mac-install/\ For Linux: https://docs.docker.com/desktop/install/linux-install/

Both tools can run the Testdata Generator Container Image provided on GitHub.

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:

FilenamePlatform
testdata-generator-quarkus-rest-app-runner-${VERSION}-linux-amd64Linux (AMD64)
testdata-generator-quarkus-rest-app-runner-${VERSION}-linux-arm64Linux (ARM64)
testdata-generator-quarkus-rest-app-runner-${VERSION}-macmacOS
testdata-generator-quarkus-rest-app-runner-${VERSION}-windows.exeWindows

Replace ${VERSION} with the version number of the release. A generic .jar file is available as well: testdata-generator-quarkus-rest-app-.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. It presents all components of EPCIS visually, grouped by dimension, so you can fill in the fields your requirements or your supply chain call for and generate the matching events.

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 application consists of three modules: testdata-generator-common, testdata-generator-rest-api and testdata-generator-ui.

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 connects the front end to the generator. It receives the InputTemplate a user submits, 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.

testdata-generator-ui (user interface for generating testdata events)

The user interface is where users work with the EPCIS fields and enter their values. It converts those values into the InputTemplate that the other modules expect. It is built with HTML, CSS and the Nuxt.js/Vue.js framework, together with front-end libraries such as Drawflow, Bootstrap, Bootstrap icons and CodeMirror.

Direct usage

The EPCISEventGenerator class within testdata-generator-common provides the Java method generate, which you can call from your own code. Prepare an inputTemplate JSON with all necessary data and pass it to the method to obtain the events:

// Pass the required JSON inputTemplate to generate EPCIS testdata events.
EPCISEventGenerator.generate(inputTemplate).collect().asList().await().indefinitely().forEach(e- >{
        try{
        System.out.println(e.toString());
        }catch(JsonProcessingException ex){
        throw new CompletionException(ex);
        }
        });

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
    }
  ]
}