Search in sources :

Example 6 with ValidationIssues

use of com.b2international.snowowl.core.validation.issue.ValidationIssues in project snow-owl by b2ihealthcare.

the class SnomedQueryValidationRuleEvaluatorTest method descriptionRuleEmptySemanticTag.

@Test
public void descriptionRuleEmptySemanticTag() throws Exception {
    final String description1 = RandomSnomedIdentiferGenerator.generateDescriptionId();
    final String description2 = RandomSnomedIdentiferGenerator.generateDescriptionId();
    indexRevision(MAIN, description(description1, Concepts.SYNONYM, "Minor heart attack").conceptId(generateConceptId()).build(), description(description2, Concepts.SYNONYM, "Clinical finding (finding)").conceptId(generateConceptId()).build());
    final Map<String, Object> ruleQuery = ImmutableMap.<String, Object>builder().put("componentType", "description").put("semanticTag", "").build();
    final String ruleId = createSnomedQueryRule(ruleQuery);
    final ValidationIssues issues = validate(ruleId);
    assertThat(issues.getTotal()).isEqualTo(1);
    assertThat(issues.getItems().get(0).getAffectedComponent()).isEqualTo(ComponentIdentifier.of(SnomedDescription.TYPE, description1));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) BaseValidationTest(com.b2international.snowowl.test.commons.validation.BaseValidationTest) Test(org.junit.Test)

Example 7 with ValidationIssues

use of com.b2international.snowowl.core.validation.issue.ValidationIssues in project snow-owl by b2ihealthcare.

the class GenericValidationRuleTest method rule55.

@Test
public void rule55() throws Exception {
    final String ruleId = "55";
    indexRule(ruleId);
    // wrong examples
    SnomedConceptDocument invalidDescriptionConcept = concept(generateConceptId()).build();
    SnomedDescriptionIndexEntry descWithInvalidHypenSpacing = description(generateDescriptionId(), Concepts.SYNONYM, "Hello -Cruel!").moduleId(Concepts.MODULE_B2I_EXTENSION).conceptId(invalidDescriptionConcept.getId()).build();
    SnomedConceptDocument invalidDescriptionConcept2 = concept(generateConceptId()).build();
    SnomedDescriptionIndexEntry descWithMultipleInvalidHypenSpacing = description(generateDescriptionId(), Concepts.SYNONYM, "Hello -Cruel- World!").moduleId(Concepts.MODULE_B2I_EXTENSION).conceptId(invalidDescriptionConcept2.getId()).build();
    SnomedConceptDocument invalidDescriptionConcept3 = concept(generateConceptId()).build();
    SnomedDescriptionIndexEntry descWithSymbolAndInvalidHypenSpacing = description(generateDescriptionId(), Concepts.SYNONYM, "Hello -? -a").moduleId(Concepts.MODULE_B2I_EXTENSION).conceptId(invalidDescriptionConcept3.getId()).build();
    // good examples
    SnomedConceptDocument validDescriptionConcept = concept(generateConceptId()).build();
    SnomedDescriptionIndexEntry descWithValidHypenSpacing = description(generateDescriptionId(), Concepts.SYNONYM, "Hello-Cruel!").moduleId(Concepts.MODULE_B2I_EXTENSION).conceptId(validDescriptionConcept.getId()).build();
    SnomedConceptDocument validDescriptionConcept2 = concept(generateConceptId()).build();
    SnomedDescriptionIndexEntry descWithSymbolNextToHypen = description(generateDescriptionId(), Concepts.SYNONYM, "Hello -?").moduleId(Concepts.MODULE_B2I_EXTENSION).conceptId(validDescriptionConcept2.getId()).build();
    indexRevision(Branch.MAIN_PATH, invalidDescriptionConcept, invalidDescriptionConcept2, invalidDescriptionConcept3, descWithInvalidHypenSpacing, descWithMultipleInvalidHypenSpacing, descWithSymbolAndInvalidHypenSpacing, descWithSymbolNextToHypen, descWithValidHypenSpacing, validDescriptionConcept, validDescriptionConcept2);
    ValidationIssues issues = validate(ruleId);
    assertAffectedComponents(issues, ComponentIdentifier.of(SnomedDescription.TYPE, descWithInvalidHypenSpacing.getId()), ComponentIdentifier.of(SnomedDescription.TYPE, descWithMultipleInvalidHypenSpacing.getId()), ComponentIdentifier.of(SnomedDescription.TYPE, descWithSymbolAndInvalidHypenSpacing.getId()));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) Test(org.junit.Test)

Example 8 with ValidationIssues

use of com.b2international.snowowl.core.validation.issue.ValidationIssues in project snow-owl by b2ihealthcare.

the class GenericValidationRuleTest method rule670.

@Test
public void rule670() throws Exception {
    final String ruleId = "670";
    indexRule(ruleId);
    final SnomedRefSetMemberIndexEntry duplicateSimpleMember1 = member(Concepts.IS_A, Concepts.MODULE_ROOT).referenceSetType(SnomedRefSetType.ASSOCIATION).targetComponentId(Concepts.ATTRIBUTE_TYPE_ASSOCIATION_TARGET).build();
    final SnomedRefSetMemberIndexEntry duplicateSimpleMember2 = member(Concepts.IS_A, Concepts.MODULE_ROOT).referenceSetType(SnomedRefSetType.ASSOCIATION).targetComponentId(Concepts.ATTRIBUTE_TYPE_ASSOCIATION_TARGET).build();
    final SnomedRefSetMemberIndexEntry correctSimpleMember = member(Concepts.IS_A, Concepts.MODULE_SCT_CORE).referenceSetType(SnomedRefSetType.ASSOCIATION).targetComponentId(Concepts.ATTRIBUTE_TYPE_COMPONENT_TYPE).build();
    indexRevision(MAIN, duplicateSimpleMember1, duplicateSimpleMember2, correctSimpleMember);
    final ValidationIssues issues = validate(ruleId);
    assertAffectedComponents(issues, ComponentIdentifier.of(SnomedConcept.TYPE, Concepts.IS_A));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) Test(org.junit.Test)

Example 9 with ValidationIssues

use of com.b2international.snowowl.core.validation.issue.ValidationIssues in project snow-owl by b2ihealthcare.

the class GenericValidationRuleTest method rule38b.

@Test
public void rule38b() throws Exception {
    // Active concepts should have at least one active stated parent
    final String ruleId = "38b";
    indexRule(ruleId);
    final SnomedConceptDocument activeConceptWithStatedParent = concept(generateConceptId()).active(true).statedParents(Long.valueOf(Concepts.MODULE_SCT_MODEL_COMPONENT)).build();
    final SnomedConceptDocument activeConceptWithoutStatedParent = concept(generateConceptId()).active(true).build();
    final SnomedConceptDocument inactiveConceptWithoutStatedParent = concept(generateConceptId()).active(false).build();
    indexRevision(MAIN, activeConceptWithStatedParent, activeConceptWithoutStatedParent, inactiveConceptWithoutStatedParent);
    ValidationIssues issues = validate(ruleId);
    assertThat(issues.stream().map(ValidationIssue::getAffectedComponent).collect(Collectors.toSet())).contains(ComponentIdentifier.of(SnomedConcept.TYPE, activeConceptWithoutStatedParent.getId())).doesNotContainAnyElementsOf(ImmutableList.of(ComponentIdentifier.of(SnomedConcept.TYPE, activeConceptWithStatedParent.getId()), ComponentIdentifier.of(SnomedConcept.TYPE, inactiveConceptWithoutStatedParent.getId())));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) ValidationIssue(com.b2international.snowowl.core.validation.issue.ValidationIssue) Test(org.junit.Test)

Example 10 with ValidationIssues

use of com.b2international.snowowl.core.validation.issue.ValidationIssues in project snow-owl by b2ihealthcare.

the class GenericValidationRuleTest method rule664.

@Test
public void rule664() throws Exception {
    final String ruleId = "664";
    indexRule(ruleId);
    // index three concepts
    SnomedConceptDocument c1 = concept(generateConceptId()).build();
    SnomedDescriptionIndexEntry d1 = description(generateDescriptionId(), Concepts.FULLY_SPECIFIED_NAME, "Hello World!").conceptId(c1.getId()).build();
    SnomedConceptDocument c2 = concept(generateConceptId()).build();
    SnomedDescriptionIndexEntry d2 = description(generateDescriptionId(), Concepts.FULLY_SPECIFIED_NAME, "Hello World!").conceptId(c2.getId()).build();
    SnomedConceptDocument c3 = concept(generateConceptId()).build();
    SnomedDescriptionIndexEntry d3 = description(generateDescriptionId(), Concepts.FULLY_SPECIFIED_NAME, "Hello Cruel World!").conceptId(c3.getId()).build();
    indexRevision(MAIN, c1, d1, c2, d2, c3, d3);
    ValidationIssues issues = validate(ruleId);
    assertAffectedComponents(issues, ComponentIdentifier.of(SnomedDescription.TYPE, d1.getId()), ComponentIdentifier.of(SnomedDescription.TYPE, d2.getId()));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) Test(org.junit.Test)

Aggregations

ValidationIssues (com.b2international.snowowl.core.validation.issue.ValidationIssues)44 Test (org.junit.Test)43 ValidationIssue (com.b2international.snowowl.core.validation.issue.ValidationIssue)9 BaseRevisionIndexTest (com.b2international.index.revision.BaseRevisionIndexTest)5 BaseValidationTest (com.b2international.snowowl.test.commons.validation.BaseValidationTest)5 ComponentURI (com.b2international.snowowl.core.uri.ComponentURI)1 SnomedConceptDocument (com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument)1