Skip to content

Commit

Permalink
pre switch validation error checking to match new version of z-schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Afsin Ustundag committed Nov 12, 2014
1 parent 495e90c commit 47dec59
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 99 deletions.
29 changes: 4 additions & 25 deletions test/parser-c32/test-parser-c32.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,37 +60,16 @@ describe('Parser C32 Support Testing', function () {

expect(result).to.exist;

val = bb.validator.validateDocumentModel(result);

var err = bb.validator.getLastError();

//if validation failed print all validation errors and summary by category of error
if (!err.valid) {

var _ = require("underscore");

function count(numbers) {
return _.reduce(numbers, function (result, current) {
return result + 1;
}, 0);
}
var result = _.chain(err.errors)
.groupBy("code")
.map(function (value, key) {
return {
code: key,
count: count(_.pluck(value, "code"))
}
})
.value();
var valid = bb.validator.validateDocumentModel(result);

//if validation failed print all validation errors
if (!valid) {
console.log("Errors: \n", JSON.stringify(bb.validator.getLastError(), null, 4));
console.log("Errors summary: \n ", JSON.stringify(result, null, 4));
} else {
JSONToFile(result, "VA_CCD_Sample_File_Version_12_5_1.json");
}

expect(err.valid).to.equal(true);
expect(valid).to.be.true;

done();
});
Expand Down
29 changes: 4 additions & 25 deletions test/parser-ccd/test-parser-ccd.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,37 +62,16 @@ describe('Parser CDA R2 CCD Support Testing', function () {

expect(result).to.exist;

val = bb.validator.validateDocumentModel(result);

var err = bb.validator.getLastError();

//if validation failed print all validation errors and summary by category of error
if (!err.valid) {

var _ = require("underscore");

function count(numbers) {
return _.reduce(numbers, function (result, current) {
return result + 1;
}, 0);
}
var result = _.chain(err.errors)
.groupBy("code")
.map(function (value, key) {
return {
code: key,
count: count(_.pluck(value, "code"))
}
})
.value();
var valid = bb.validator.validateDocumentModel(result);

//if validation failed print all validation errors
if (!valid) {
console.log("Errors: \n", JSON.stringify(bb.validator.getLastError(), null, 4));
console.log("Errors summary: \n ", JSON.stringify(result, null, 4));
} else {
JSONToFile(result, "SampleCCDDocument.json");
}

expect(err.valid).to.equal(true);
expect(valid).to.be.true;

done();
});
Expand Down
29 changes: 4 additions & 25 deletions test/parser-ccda/test-parser-ccda.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,16 @@ describe('parser.js', function () {
var result = bb.parseString(xmlfile);
expect(result).to.exist;

val = bb.validator.validateDocumentModel(result);

var err = bb.validator.getLastError();

//if validation failed print all validation errors and summary by category of error
if (!err.valid) {

var _ = require("underscore");

function count(numbers) {
return _.reduce(numbers, function (result, current) {
return result + 1;
}, 0);
}
var result = _.chain(err.errors)
.groupBy("code")
.map(function (value, key) {
return {
code: key,
count: count(_.pluck(value, "code"))
}
})
.value();
var valid = bb.validator.validateDocumentModel(result);

//if validation failed print all validation errors
if (!valid) {
console.log("Errors: \n", JSON.stringify(bb.validator.getLastError(), null, 4));
console.log("Errors summary: \n ", JSON.stringify(result, null, 4));
} else {
JSONToFile(result, "CCD_1.xml.json");
}

expect(err.valid).to.equal(true);
expect(valid).to.be.true;

done();
});
Expand Down
27 changes: 3 additions & 24 deletions test/parser-cms/test-parser-cms.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,14 @@ describe('parser.js', function () {

//console.log(JSON.stringify(result.data.providers, null, 10));

val = bb.validator.validateDocumentModel(result);

var err = bb.validator.getLastError();
var valid = bb.validator.validateDocumentModel(result);

//if validation failed print all validation errors and summary by category of error
if (!err.valid) {

var _ = require("underscore");

function count(numbers) {
return _.reduce(numbers, function (result, current) {
return result + 1;
}, 0);
}
var result = _.chain(err.errors)
.groupBy("code")
.map(function (value, key) {
return {
code: key,
count: count(_.pluck(value, "code"))
}
})
.value();

if (!valid) {
console.log("Errors: \n", JSON.stringify(bb.validator.getLastError(), null, 4));
console.log("Errors summary: \n ", JSON.stringify(result, null, 4));
}

expect(err.valid).to.equal(true);
expect(valid).to.be.true;

done();
});
Expand Down

0 comments on commit 47dec59

Please sign in to comment.