Skip to content

aselcrombie/mdm-autotests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MDM E2E Autotests

A demo/training E2E test project for a Master Data Management (MDM) service. It validates the async flow Kafka → processing → MongoDB using a child entity (detail) linked to a parent entity. Suitable as a reference architecture for E2E tests in enterprise systems with message queues and a document database.


What the tests cover

  • Consuming messages from Kafka (IN topic)
  • Data updates and consistency in MongoDB (Instance / Master)
  • Business rules: updating an existing master vs creating a new one when the business key changes
  • Instance ↔ Master linkage and belonging to the parent entity

Tests focus on business behavior (that changes occur and rules are correct), not on exact payload matching.


Stack

Technology Purpose
Java 17 Language
JUnit 5 Test runner
Awaitility Waiting for async results
MongoDB Java Driver Reading from MongoDB
Apache Kafka Clients Producing/consuming messages
AssertJ Fluent assertions
Maven Build

Running the tests

Requirements

  • JDK 17+
  • Access to Kafka (bootstrap servers) and MongoDB
  • MDM service that consumes from the IN topic and writes to the DB (and optionally to the OUT topic)

Configuration

  1. Copy the example config:
    cp src/test/resources/application.properties.example src/test/resources/application.properties
  2. Edit application.properties: set your kafka.bootstrap.servers, mongo.uri, mongo.database, topic names and, if needed, test.detail.parent_master_guid / test.detail.parent_source_id (E2E requires existing test data).
  3. Do not commit application.properties with real hosts and passwords — only application.properties.example should be in the repo. If the file was already tracked:
    git rm --cached src/test/resources/application.properties

Run tests

mvn test

Single test:

mvn test -Dtest=DetailUpdateE2ETest

Project architecture

Structure is organized by entities, not by technical layers — easy to scale to other domains.

example.mdm
├── common
│   └── assertions          # Shared assertions (instance, master, versioning)
├── config
│   └── TestConfig          # Loads application.properties
├── entities
│   └── detail              # Child entity (detail)
│       ├── context         # ScenarioContext (input data + before/after snapshots)
│       ├── payload         # Kafka payload building
│       ├── dao             # MongoDB collection access
│       ├── steps           # Flow: snapshot → Kafka IN → wait → snapshot
│       ├── assertions      # Domain assertions + Kafka OUT
│       └── tests           # E2E tests
└── infrastructure
    ├── kafka               # Producer, Consumer, event awaiting
    └── mongo               # Client and versioning strategy

Key concepts

  • Parent entity — identifier parentMasterGuid to which child records (detail) are linked.
  • Detail Master — one document of the child entity; business key is the number field.
  • Detail Instance — versions of one master; relation instance.masterGuid = master._id.

Business rule: master is updated only when the business key is unchanged; a new key creates a new master.

E2E flow (Update)

  1. Snapshot instance + master before (if any).
  2. Send message to Kafka (IN topic).
  3. Wait for instance to appear/update in MongoDB (Awaitility).
  4. Snapshot instance + master after.
  5. Assert: structure, parent linkage, field deltas, versioning rule (same master vs new master).

License

Use the code as a reference or base for your own projects. Configuration and environment are your own.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages