Implementation:AKSW RDFUnit ShaclResultStatement Evaluate
| Knowledge Sources | |
|---|---|
| Domains | Testing, JUnit, SHACL |
| Last Updated | 2026-10-16 00:00 GMT |
Overview
Concrete JUnit Statement that executes SHACL Lite validation against a test input model and asserts no violations from the input data.
Description
The ShaclResultStatement extends JUnit's `Statement` class to provide the actual assertion logic for JUnit-integrated RDFUnit validation. When `evaluate()` is called:
1. It delegates to `RdfUnitJunitStatusTestExecutor.runTest()` which executes the test case as a SHACL Lite (SELECT) query against the test input model. 2. It filters results: only violations where the failing node is actually part of the input model (as subject or object) are kept. This prevents false positives from schema-level annotations. 3. If any violations remain, it fails the assertion with a detailed message listing the failing nodes.
The `nodeIsPartOfInputModel()` check tests whether the failing resource appears as a subject (with any predicate/object) or as an object (with any subject/predicate) in the input model.
Usage
- JUnit test execution:*** Created internally by `RdfUnitJunitRunner.runChild()` for each test case. Not intended for direct use.
Code Reference
Source Location
- Repository: AKSW/RDFUnit
- File: rdfunit-junit/src/main/java/org/aksw/rdfunit/junit/ShaclResultStatement.java
Signature
class ShaclResultStatement extends Statement {
private final RdfUnitJunitStatusTestExecutor rdfUnitJunitStatusTestExecutor;
private final RdfUnitJunitTestCase testCase;
ShaclResultStatement(RdfUnitJunitStatusTestExecutor rdfUnitJunitStatusTestExecutor,
RdfUnitJunitTestCase testCase);
@Override
public void evaluate();
private boolean nodeIsPartOfInputModel(ShaclLiteTestCaseResult r);
}
Import
// Internal class, not directly importable. Used by RdfUnitJunitRunner.
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| rdfUnitJunitStatusTestExecutor | RdfUnitJunitStatusTestExecutor | Yes | Executes the SHACL Lite test |
| testCase | RdfUnitJunitTestCase | Yes /// Test case with input model and schema |
Outputs
| Name | Type | Description |
|---|---|---|
| evaluate() | void /// Asserts no violations; throws AssertionError on failure |
Usage Examples
Used by RdfUnitJunitRunner (internal)
// This is how RdfUnitJunitRunner uses it internally:
// (Not for direct use by application code)
@Override
protected void runChild(RdfUnitJunitTestCase child, RunNotifier notifier) {
if (isIgnored(child)) {
notifier.fireTestIgnored(describeChild(child));
} else {
this.runLeaf(
new ShaclResultStatement(rdfUnitJunitStatusTestExecutor, child),
describeChild(child),
notifier
);
}
}