Skip to content

Commit

Permalink
updated test
Browse files Browse the repository at this point in the history
  • Loading branch information
bjdmeest committed Feb 25, 2019
1 parent 8995bf6 commit a9c71d6
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 0 deletions.
Binary file modified dist/n3unit.pvm
Binary file not shown.
72 changes: 72 additions & 0 deletions reports/validatrr-rdfcv-earl.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,46 @@
earl:test <urn:x-rdfcv-test:/A41>
] .

[ a earl:Assertion ;
earl:assertedBy <http://ben.de-meester.org/#me> ;
earl:result [ a earl:TestResult ;
earl:mode earl:automatic ;
earl:outcome earl:passed
] ;
earl:subject <http://example.com/Validatrr> ;
earl:test <urn:x-rdfcv-test:/A42>
] .

[ a earl:Assertion ;
earl:assertedBy <http://ben.de-meester.org/#me> ;
earl:result [ a earl:TestResult ;
earl:mode earl:automatic ;
earl:outcome earl:passed
] ;
earl:subject <http://example.com/Validatrr> ;
earl:test <urn:x-rdfcv-test:/A43>
] .

[ a earl:Assertion ;
earl:assertedBy <http://ben.de-meester.org/#me> ;
earl:result [ a earl:TestResult ;
earl:mode earl:automatic ;
earl:outcome earl:passed
] ;
earl:subject <http://example.com/Validatrr> ;
earl:test <urn:x-rdfcv-test:/A44>
] .

[ a earl:Assertion ;
earl:assertedBy <http://ben.de-meester.org/#me> ;
earl:result [ a earl:TestResult ;
earl:mode earl:automatic ;
earl:outcome earl:passed
] ;
earl:subject <http://example.com/Validatrr> ;
earl:test <urn:x-rdfcv-test:/A45>
] .

[ a earl:Assertion ;
earl:assertedBy <http://ben.de-meester.org/#me> ;
earl:result [ a earl:TestResult ;
Expand Down Expand Up @@ -417,3 +457,35 @@
earl:subject <http://example.com/Validatrr> ;
earl:test <urn:x-rdfcv-test:/A70>
] .

[ a earl:Assertion ;
earl:assertedBy <http://ben.de-meester.org/#me> ;
earl:result [ a earl:TestResult ;
earl:mode earl:automatic ;
earl:outcome earl:passed
] ;
earl:subject <http://example.com/Validatrr> ;
earl:test <urn:x-rdfcv-test:/A78>
] .

[ a earl:Assertion ;
earl:assertedBy <http://ben.de-meester.org/#me> ;
earl:result [ a earl:TestResult ;
earl:mode earl:automatic ;
earl:outcome earl:passed
] ;
earl:subject <http://example.com/Validatrr> ;
earl:test <urn:x-rdfcv-test:/A80>
] .

[ a earl:Assertion ;
earl:assertedBy <http://ben.de-meester.org/#me> ;
earl:result [ a earl:TestResult ;
earl:mode earl:automatic ;
earl:outcome earl:passed
] ;
earl:subject <http://example.com/Validatrr> ;
earl:test <urn:x-rdfcv-test:/A81>
] .


113 changes: 113 additions & 0 deletions test/ConstraintTypesTestSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/* global describe, run */

const fs = require('fs'),
path = require('path'),
async = require('async'),
TestHelper = require('../lib/TestHelper'),
Validator = require('../lib/Validator');

describe('all rules', function () {
const basePath = path.resolve(__dirname, '../resources/rules');
const bugFiles = [];
fs.readdir(basePath, function (err, files) {
async.forEachLimit(files, 4, function (file, done) {
fs.stat(path.resolve(basePath, file), function (err, stat) {
if (err) {
return done(err);
}
if (stat.isDirectory()) {
const rulePath = path.resolve(basePath, file);
try {
fs.statSync(path.resolve(rulePath, 'constraint.ttl'));
const validator = createValidator(path.resolve(rulePath, 'constraint.ttl'));
bugFiles.push({
name: file,
file: path.resolve(rulePath, 'data.ttl'),
output: path.resolve(basePath, '../../tests/owl-rdfunit/output_wrong_1.ttl'),
validator
});
} catch (e) {
// nothing
}
}
done();
});
}, function (err) {
if (err) {
throw err;
}
describe('rule test cases', function () {
TestHelper.walkFiles(bugFiles, function (inputFile, out) {
console.log(out);
// fs.writeFileSync(inputFile.replace(/input-(\d+).ttl$/, 'out-$1.ttl'), out, 'utf8');
});
});
run();
});
});
});

describe.only('A42', function () {
validate('A42_Optional_Properties', 'correct');
});

describe.only('A43', function () {
validate('A43_Repeatable_Properties', 'wrong_1');
});

describe.only('A44', function () {
validate('A44_Conditional_Properties', 'wrong_1');
});

describe.only('A45', function () {
validate('A45_Recommended_Properties', 'wrong_1');
});

describe.only('A78', function () {
validate('A78_Conjunction', 'wrong_1');
});

describe.only('A79', function () {
validate('A79_Disjunction', 'wrong_1');
});

describe.only('A80', function () {
validate('A80_Negation', 'wrong_1');
});

describe.only('A81', function () {
validate('A81_Default_Values', 'correct');
});


function validate(name, output) {
const basePath = path.resolve(__dirname, '../resources/rules');
const rulePath = path.resolve(basePath, name);
const validator = createValidator(path.resolve(rulePath, 'constraint.ttl'));
const bugFiles = [];
bugFiles.push({
name: name,
file: path.resolve(rulePath, 'data.ttl'),
output: path.resolve(basePath, `../../tests/owl-rdfunit/output_${output}.ttl`),
validator
});
TestHelper.walkFiles(bugFiles, function (inputFile, out) {
console.log(out);
// fs.writeFileSync(inputFile.replace(/input-(\d+).ttl$/, 'out-$1.ttl'), out, 'utf8');
});
}

function createValidator(constraintPath) {
let basePath = path.resolve(__dirname, '..');

let distPath = path.resolve(basePath, 'dist', 'n3unit.pvm');
let queryPath = path.resolve(basePath, 'resources', 'rules', 'query_count.n3');
const logCodes = path.resolve(__dirname, '../resources/rml/logCodes.ttl'); // TODO configurable

let validationOpts = {
queryPath,
extraFiles: [distPath, constraintPath, logCodes]
};

return new Validator(validationOpts);
}

0 comments on commit a9c71d6

Please sign in to comment.