Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:AKSW RDFUnit Programmatic Validation

From Leeroopedia
Knowledge Sources
Domains Semantic_Web, Data_Quality, API_Design
Last Updated 2026-10-16 00:00 GMT

Overview

Architectural pattern for exposing RDF validation as a reusable Java API with a static facade, enabling applications to validate in-memory RDF models against pre-registered schemas without CLI or external processes.

Description

Programmatic Validation provides a clean Java API for embedding RDFUnit validation in any application. The central component is `RDFUnitStaticValidator`, a static facade that holds a single `RDFUnitTestSuiteGenerator` (registered once at initialization) and provides multiple `validate()` overloads for different input combinations. The validation process follows these steps:

1. Initialize: Build an `RDFUnitTestSuiteGenerator` with one or more schema URIs and register it with `RDFUnitStaticValidator.initWrapper()`. This triggers lazy initialization of the RDFUnit pattern library and test suite generation. 2. Validate: Call `validate()` with a Jena `Model` (the data to validate), an execution type (SHACL, SHACL Lite, aggregate, status), and optional dataset URI and results holder. 3. Inspect: The returned `TestExecution` object provides access to `DatasetOverviewResults` (summary statistics: total tests, failures, errors, timing) and `Collection<TestCaseResult>` (individual violation details).

The facade manages the full lifecycle internally: it creates an in-memory `TestSource` from the input model, sets up a `TestExecutor` with a monitoring `SimpleTestExecutorMonitor`, executes the test suite, and collects results. This makes programmatic validation a one-call operation for the user.

Usage

Use this principle when embedding RDF validation in Java applications, web services, or batch processors. It is ideal for scenarios where validation needs to run repeatedly against different data with the same schema set—initialize once, validate many times.

Theoretical Basis

The facade pattern with lazy initialization:

# Abstract algorithm
class RDFUnitStaticValidator:
    test_suite_generator = None  # static singleton

    @staticmethod
    def init_wrapper(generator):
        test_suite_generator = generator  # one-time setup

    @staticmethod
    def validate(input_model, execution_type, input_uri):
        # Build in-memory test source from model
        test_source = TestSourceBuilder()
            .set_prefix_uri("custom", input_uri)
            .set_inmem_dataset()
            .set_inmem_reader(RdfModelReader(input_model))
            .set_reference_schemata(test_suite_generator.get_schemas())
            .build()

        # Execute
        executor = TestExecutorFactory.create(execution_type)
        monitor = SimpleTestExecutorMonitor()
        executor.add_monitor(monitor)
        executor.execute(test_source, test_suite_generator.get_test_suite())

        return monitor.get_test_execution()

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment