How ekino/jcv works
Based on our analysis of the provided file tree and README, this project is a Java/Kotlin-based open-source library called “JSON Content Validator (JCV)”. Its purpose is to provide a JSON comparator with embedded validators for making assertions on JSON content in tests. It is structured as a multi-module Gradle project with several modules that extend the core functionality (jcv-core) into integrations with AssertJ, Hamcrest, and WireMock.
Overall Architecture Identification
• Project Type & Purpose: Emphasize that JCV is a testing utility library designed to simplify JSON content assertions. The main core module provides the underlying JSON comparison logic and validator interfaces, and the “integration” modules (jcv-assertj, jcv-hamcrest, jcv-wiremock) serve as adapters for different testing frameworks.
• Project Structure: The repository is divided into submodules (jcv-core, jcv-assertj, jcv-hamcrest, jcv-wiremock) each addressing a specific testing integration.
Main Components to Illustrate
• Build System & Configuration:
• Gradle build scripts (build.gradle.kts, gradlew, gradlew.bat, gradle wrapper).
• GitHub workflows (.github/workflows) and configuration files (e.g., .editorconfig, gradle.properties) showing the build, test, release, and quality pipelines.
• Core Module (jcv-core):
• The heart of the library. Include components/classes such as JsonComparator, various JSON validators (like DefaultJsonValidator), comparator implementations (JsonComparator.kt, comparator classes including ContainsComparator, DateTimeFormatComparator, etc.), and initializers for comparators.
• Sub-packages like “core”, “comparator”, “initializer”, “validator” – these demonstrate a layered or modular design internally.
• Integration Modules:
• jcv-assertj: Provides an AssertJ-based assertion layer. Show that it depends on jcv-core and extends its capabilities with a fluent JSON assertion API.
• jcv-hamcrest: Implements Hamcrest matchers for JSON validations. Connect it to the core module, illustrating its reuse of the underlying JSON comparison functionality.
• jcv-wiremock: Allows integration with WireMock for stubbing and validating JSON requests/responses using JCV. Note its usage of a custom WireMock extension (e.g., JcvRequestMatcherExtension) that hooks into the core validation logic.
• Testing and Examples:
• The file structure includes several test directories (src/test, both in Java and Kotlin) and resource JSON files that provide ready-made examples.
Relationships and Interactions
• The dependency of each integration module on jcv-core.
• The build pipeline influencing all modules via the Gradle configuration.
• The test components interacting with both the core and integration modules to validate different use cases.
• How external libraries (JSONassert, AssertJ, Hamcrest, WireMock) interact with corresponding modules by being passed into the system (for example, through dependency injection or extension registration in WireMock).
Architectural Patterns and Design Principles
• Modularization: Each module stands alone with its own test suite and build file (organizing responsibilities and dependencies).
• Layered/Adapter Pattern: The core module abstracts JSON validation, while each adapter/integration layer (AssertJ, Hamcrest, WireMock) transforms validation results into idiomatic assertions for different frameworks.
• Configuration and Extensibility: Indicate that the configuration files (in the config/detekt directory, for instance) enforce code quality, and the library supports custom validations (as seen with embedded notations like {#uuid#} or {#date_time_format:iso_instant#}).