Skip to content

Commit

Permalink
test: Add support for vocabularyValidationConfigurationsErrorCount
Browse files Browse the repository at this point in the history
  • Loading branch information
drbgfc committed Sep 6, 2019
1 parent f0b920b commit 21e5f9e
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public void globalCodeValidatorResultsVocabularyValidationConfigurationsCountTes
CCD_R21, new VocabularyCCDAValidator(getVocabularyValidationService()),
"ccdaReferenceValidatorConfigTest");

final int expectedConfigCount = 5;
final int expectedConfigCount = 9;
final int configCount = results.getResultsMetaData().getVocabularyValidationConfigurationsCount();
println("vocabularyValidationConfigurationsCount: " + configCount);
Assert.assertTrue("VocabularyValidationConfigurationsCount should be more than 0", configCount > 0);
Expand All @@ -412,6 +412,42 @@ public void globalCodeValidatorResultsVocabularyValidationConfigurationsCountPro
+ " as per the content of " + "requiredNodeValidatorMissingElementConfig",
configCount == expectedConfigCount);
}

@Test
public void globalCodeValidatorResultsVocabularyValidationConfigurationsErrorCountTest() {
setupInitParameters(true);
injectDependencies();

ValidationResultsDto results = runReferenceCCDAValidationServiceAndReturnResults(CCDATypes.NON_SPECIFIC_CCDAR2,
CCD_R21, new VocabularyCCDAValidator(getVocabularyValidationService()),
"ccdaReferenceValidatorConfigTest");

final int expectedConfigCount = 7;
final int configCount = results.getResultsMetaData().getVocabularyValidationConfigurationsErrorCount();
println("vocabularyValidationConfigurationsErrorCount: " + configCount);
Assert.assertTrue("VocabularyValidationConfigurationsErrorCount should be more than 0", configCount > 0);
Assert.assertTrue(
"VocabularyValidationConfigurationsErrorCount should equal to " + expectedConfigCount
+ " as per the content of " + "requiredNodeValidatorMissingElementConfig",
configCount == expectedConfigCount);
}

@Test
public void globalCodeValidatorResultsVocabularyValidationConfigurationsErrorCountProgrammaticTest() {
createGenericExpressionForProgrammaticConfigAndInjectDependencies();

ValidationResultsDto results = runReferenceCCDAValidationServiceAndReturnResults(CCDATypes.NON_SPECIFIC_CCDAR2,
CCD_R21, new VocabularyCCDAValidator(getVocabularyValidationService()));

final int expectedConfigCount = 1;
final int configCount = results.getResultsMetaData().getVocabularyValidationConfigurationsErrorCount();
println("vocabularyValidationConfigurationsErrorCount: " + configCount);
Assert.assertTrue("VocabularyValidationConfigurationsErrorCount should be more than 0", configCount > 0);
Assert.assertTrue(
"VocabularyValidationConfigurationsErrorCount should equal to " + expectedConfigCount
+ " as per the content of " + "requiredNodeValidatorMissingElementConfig",
configCount == expectedConfigCount);
}

@Ignore // Does not work with maven install due to some glitch but works
// otherwise
Expand Down
40 changes: 40 additions & 0 deletions src/test/resources/ccdaReferenceValidatorConfigTest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,45 @@
</validator>
</expression>
-->

<!-- dynamically converts to SHALL so we need to add this to our count of errors -->
<expression xpathExpression="//v3:section[not(@nullFlavor)]/v3:templateId[@root='2.16.840.1.113883.10.20.22.2.4.1' and @extension='2015-08-01']/ancestor::v3:section[1]/v3:code">
<validator>
<name>NodeCodeSystemMatchesConfiguredCodeSystemValidator</name>
<nodeType>codeSystem</nodeType>
<allowedValuesetOids>2.16.840.1.113883.6.1</allowedValuesetOids>
</validator>
</expression>

<!-- dynamically converts to SHALL so we need to add this to our count of errors -->
<expression xpathExpression="//v3:section[not(@nullFlavor)]/v3:templateId[@root='2.16.840.1.113883.10.20.22.2.4.1' and @extension='2015-08-01']/ancestor::v3:section[1]/v3:code">
<validator>
<name>NodeCodeSystemMatchesConfiguredCodeSystemValidator</name>
<nodeType>codeSystem</nodeType>
<allowedValuesetOids>2.16.840.1.113883.6.1</allowedValuesetOids>
</validator>
</expression>

<expression xpathExpression="//v3:informant/v3:relatedEntity/v3:relatedPerson/v3:name">
<validator>
<name>RequiredNodeValidator</name>
<validationResultSeverityLevels>
<codeSeverityLevel>SHOULD</codeSeverityLevel>
</validationResultSeverityLevels>
<requiredNodeName>v3:prefix</requiredNodeName>
<validationMessage>informant/relatedEntity/relatedPerson/name SHOULD contain a prefix element (not a real rule - just a test)</validationMessage>
</validator>
</expression>

<expression xpathExpression="//v3:informant/v3:relatedEntity/v3:relatedPerson/v3:name">
<validator>
<name>RequiredNodeValidator</name>
<validationResultSeverityLevels>
<codeSeverityLevel>MAY</codeSeverityLevel>
</validationResultSeverityLevels>
<requiredNodeName>v3:prefix</requiredNodeName>
<validationMessage>informant/relatedEntity/relatedPerson/name MAY contain a prefix element (not a real rule - just a test)</validationMessage>
</validator>
</expression>

</configurations>

0 comments on commit 21e5f9e

Please sign in to comment.