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

Implementation:AKSW RDFUnit RDFUnitStaticValidator Validate

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

Overview

Concrete static facade that provides a simple Java API for validating in-memory RDF models against a pre-registered test suite.

Description

The RDFUnitStaticValidator is a final utility class with static methods that serve as the primary programmatic validation API. It holds a single `RDFUnitTestSuiteGenerator` registered via `initWrapper()`, then provides multiple `validate()` overloads for different input combinations.

The most commonly used overload takes a Jena `Model`, an execution type, and an optional input URI. Internally, it:

1. Creates a `SimpleTestExecutorMonitor` to collect results. 2. Creates a `TestExecutor` via `TestExecutorFactory.createTestExecutor()`. 3. Builds an in-memory `TestSource` from the input model using `TestSourceBuilder`. 4. Executes the test suite against the test source. 5. Returns the collected `TestExecution` result.

Additional overloads accept pre-built `TestSource` and `TestSuite` objects for full control, and an `agentID` for PROV provenance tracking.

Usage

  • Embedded validation in applications:*** Initialize once with `initWrapper()`, then call `validate()` repeatedly for different models.
  • Web service validation:*** Register schemas at startup, validate on each request.
  • Standalone validation:*** Use the overload accepting explicit `TestSource` and `TestSuite` to bypass the static singleton.

Code Reference

Source Location

  • Repository: AKSW/RDFUnit
  • File: rdfunit-core/src/main/java/org/aksw/rdfunit/validate/wrappers/RDFUnitStaticValidator.java

Signature

public final class RDFUnitStaticValidator {

    // Register the test suite generator (call once)
    public static void initWrapper(@NonNull RDFUnitTestSuiteGenerator testSuiteGenerator);
    public static TestSuite getTestSuite();

    // Validate with defaults (shaclTestCaseResult, "custom" URI)
    public static TestExecution validate(final Model inputModel) throws Exception;

    // Validate with execution type
    public static TestExecution validate(final Model inputModel,
        final TestCaseExecutionType executionType) throws Exception;

    // Validate with custom URI
    public static TestExecution validate(final Model inputModel,
        final String inputURI) throws Exception;

    // Full control: model + type + URI
    public static TestExecution validate(final Model inputModel,
        final TestCaseExecutionType executionType, final String inputURI) throws Exception;

    // Full control with overview results holder
    public static TestExecution validate(final Model inputModel,
        final TestCaseExecutionType executionType, final String inputURI,
        DatasetOverviewResults overviewResults) throws Exception;

    // Standalone: provide own test suite
    public static TestExecution validate(final TestCaseExecutionType testCaseExecutionType,
        final Model model, final TestSuite testSuite);

    public static TestExecution validate(final TestCaseExecutionType testCaseExecutionType,
        final TestSource testSource, final TestSuite testSuite);

    public static TestExecution validate(final TestCaseExecutionType testCaseExecutionType,
        final TestSource testSource, final TestSuite testSuite,
        DatasetOverviewResults overviewResults);

    public static TestExecution validate(final TestCaseExecutionType testCaseExecutionType,
        final TestSource testSource, final TestSuite testSuite, final String agentID,
        DatasetOverviewResults overviewResults);
}

Import

import org.aksw.rdfunit.validate.wrappers.RDFUnitStaticValidator;

I/O Contract

Inputs

Name Type Required Description
inputModel Model Yes Jena model containing RDF data to validate
executionType TestCaseExecutionType No Result type (default: shaclTestCaseResult)
inputURI String No Dataset URI (default: "custom")
overviewResults DatasetOverviewResults No /// Optional holder for summary statistics
testSuiteGenerator RDFUnitTestSuiteGenerator Yes (init) Registered via initWrapper()

Outputs

Name Type Description
validate() returns TestExecution Contains all TestCaseResults and DatasetOverviewResults

Usage Examples

Validate a SKOS Model

import org.aksw.rdfunit.validate.wrappers.RDFUnitStaticValidator;
import org.aksw.rdfunit.validate.wrappers.RDFUnitTestSuiteGenerator;
import org.aksw.rdfunit.enums.TestCaseExecutionType;
import org.aksw.rdfunit.model.interfaces.results.TestExecution;
import org.apache.jena.rdf.model.Model;

// One-time initialization
RDFUnitStaticValidator.initWrapper(
    new RDFUnitTestSuiteGenerator.Builder()
        .addSchemaURI("skos", "http://www.w3.org/2004/02/skos/core#")
        .build()
);

// Validate a model
Model inputModel = ...;  // your RDF data
TestExecution result = RDFUnitStaticValidator.validate(
    inputModel, TestCaseExecutionType.shaclTestCaseResult);

// Check results
long failures = result.getDatasetOverviewResults().getFailedTests();
long errors = result.getDatasetOverviewResults().getIndividualErrors();
System.out.println("Failed tests: " + failures + ", Individual errors: " + errors);

Standalone Validation with Custom TestSuite

// No initWrapper needed; provide test suite directly
TestExecution result = RDFUnitStaticValidator.validate(
    TestCaseExecutionType.shaclLiteTestCaseResult,
    testSource,   // custom TestSource
    testSuite,    // custom TestSuite
    "http://my-app/validator"  // agent ID for provenance
);

Related Pages

Implements Principle

Requires Environment

Page Connections

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