Search in sources :

Example 26 with ValidationIssues

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

the class GenericValidationRuleTest method rule_mrcm_constraint_type.

@Test
public void rule_mrcm_constraint_type() throws Exception {
    final String ruleId = "rule_mrcm_constraint_type";
    indexRule(ruleId);
    // First MRCM rule
    final SnomedRefSetMemberIndexEntry mrcmDomainMember1 = member(Concepts.CONCEPT_MODEL_ATTRIBUTE, Concepts.REFSET_MRCM_DOMAIN_INTERNATIONAL).referenceSetType(SnomedRefSetType.MRCM_DOMAIN).domainConstraint(String.format("<<%s", Concepts.CONCEPT_MODEL_ATTRIBUTE)).build();
    final SnomedRefSetMemberIndexEntry mrcmAttributeDomainMember1 = member(Concepts.FINDING_SITE, Concepts.REFSET_MRCM_ATTRIBUTE_DOMAIN_INTERNATIONAL).referenceSetType(SnomedRefSetType.MRCM_ATTRIBUTE_DOMAIN).domainId(Concepts.CONCEPT_MODEL_ATTRIBUTE).build();
    // Second MRCM rule
    final SnomedRefSetMemberIndexEntry mrcmDomainMember2 = member(Concepts.PHYSICAL_OBJECT, Concepts.REFSET_MRCM_DOMAIN_INTERNATIONAL).referenceSetType(SnomedRefSetType.MRCM_DOMAIN).domainConstraint(String.format("<<%s", Concepts.PHYSICAL_OBJECT)).build();
    final SnomedRefSetMemberIndexEntry mrcmAttributeDomainMember2 = member(Concepts.HAS_ACTIVE_INGREDIENT, Concepts.REFSET_MRCM_ATTRIBUTE_DOMAIN_INTERNATIONAL).referenceSetType(SnomedRefSetType.MRCM_ATTRIBUTE_DOMAIN).domainId(Concepts.PHYSICAL_OBJECT).build();
    // Relationships
    final SnomedRelationshipIndexEntry relationship1 = relationship(Concepts.CONCEPT_MODEL_ATTRIBUTE, Concepts.IS_A, Concepts.CONCEPT_MODEL_ATTRIBUTE).relationshipGroup(1).build();
    final SnomedRelationshipIndexEntry relationship2 = relationship(Concepts.CONCEPT_MODEL_ATTRIBUTE, Concepts.FINDING_SITE, Concepts.PHYSICAL_OBJECT).relationshipGroup(1).build();
    final SnomedRelationshipIndexEntry relationship3 = relationship(Concepts.ROOT_CONCEPT, Concepts.TEXT_DEFINITION, Concepts.PHYSICAL_OBJECT).relationshipGroup(2).build();
    final SnomedRelationshipIndexEntry relationship4 = relationship(Concepts.PHYSICAL_OBJECT, Concepts.FINDING_SITE, Concepts.TEXT_DEFINITION).relationshipGroup(0).build();
    final SnomedRelationshipIndexEntry relationship5 = relationship(Concepts.PHYSICAL_OBJECT, Concepts.HAS_ACTIVE_INGREDIENT, Concepts.PHYSICAL_OBJECT).relationshipGroup(3).build();
    final SnomedRelationshipIndexEntry relationship6 = concreteValue(Concepts.PHYSICAL_OBJECT, Concepts.HAS_ACTIVE_INGREDIENT, new RelationshipValue(Integer.valueOf(5))).build();
    final SnomedRelationshipIndexEntry relationship7 = concreteValue(Concepts.PHYSICAL_OBJECT, Concepts.FINDING_SITE, new RelationshipValue(Integer.valueOf(15))).build();
    final SnomedRelationshipIndexEntry relationship8 = concreteValue(Concepts.CONCEPT_MODEL_ATTRIBUTE, Concepts.HAS_ACTIVE_INGREDIENT, new RelationshipValue(Integer.valueOf(20))).build();
    // OWL axioms
    SnomedRefSetMemberIndexEntry axiomMember1 = member(Concepts.CONCEPT_MODEL_ATTRIBUTE, Concepts.REFSET_OWL_AXIOM).referenceSetType(SnomedRefSetType.OWL_AXIOM).classAxiomRelationships(Lists.newArrayList(SnomedOWLRelationshipDocument.create(Concepts.FINDING_SITE, Concepts.CONCEPT_MODEL_ATTRIBUTE, 0))).owlExpression(String.format("ObjectSomeValuesFrom(:%s :%s)", Concepts.FINDING_SITE, Concepts.CONCEPT_MODEL_ATTRIBUTE)).build();
    SnomedRefSetMemberIndexEntry axiomMember2 = member(Concepts.PHYSICAL_OBJECT, Concepts.REFSET_OWL_AXIOM).referenceSetType(SnomedRefSetType.OWL_AXIOM).classAxiomRelationships(Lists.newArrayList(SnomedOWLRelationshipDocument.create(Concepts.FINDING_SITE, Concepts.PHYSICAL_OBJECT, 0))).owlExpression(String.format("ObjectSomeValuesFrom(:%s :%s)", Concepts.FINDING_SITE, Concepts.PHYSICAL_OBJECT)).build();
    SnomedRefSetMemberIndexEntry axiomMember3 = member(Concepts.CONCEPT_MODEL_ATTRIBUTE, Concepts.REFSET_OWL_AXIOM).referenceSetType(SnomedRefSetType.OWL_AXIOM).classAxiomRelationships(Lists.newArrayList(SnomedOWLRelationshipDocument.create(Concepts.PHYSICAL_OBJECT, Concepts.CONCEPT_MODEL_ATTRIBUTE, 0))).owlExpression(String.format("ObjectSomeValuesFrom(:%s :%s)", Concepts.PHYSICAL_OBJECT, Concepts.CONCEPT_MODEL_ATTRIBUTE)).build();
    indexRevision(MAIN, mrcmDomainMember1, mrcmAttributeDomainMember1, mrcmDomainMember2, mrcmAttributeDomainMember2, relationship1, relationship2, relationship3, relationship4, relationship5, relationship6, relationship7, relationship8, axiomMember1, axiomMember2, axiomMember3);
    ValidationIssues issues = validate(ruleId);
    Assertions.assertThat(issues.stream().map(ValidationIssue::getAffectedComponent).collect(Collectors.toSet())).contains(ComponentIdentifier.of(SnomedReferenceSetMember.TYPE, axiomMember2.getId()), ComponentIdentifier.of(SnomedReferenceSetMember.TYPE, axiomMember3.getId()), ComponentIdentifier.of(SnomedRelationship.TYPE, relationship3.getId()), ComponentIdentifier.of(SnomedRelationship.TYPE, relationship4.getId()), ComponentIdentifier.of(SnomedRelationship.TYPE, relationship7.getId()), ComponentIdentifier.of(SnomedRelationship.TYPE, relationship8.getId())).doesNotContain(ComponentIdentifier.of(SnomedReferenceSetMember.TYPE, axiomMember1.getId()), ComponentIdentifier.of(SnomedRelationship.TYPE, relationship1.getId()), ComponentIdentifier.of(SnomedRelationship.TYPE, relationship2.getId()), ComponentIdentifier.of(SnomedRelationship.TYPE, relationship5.getId()), ComponentIdentifier.of(SnomedRelationship.TYPE, relationship5.getId()), ComponentIdentifier.of(SnomedRelationship.TYPE, relationship6.getId()));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) ValidationIssue(com.b2international.snowowl.core.validation.issue.ValidationIssue) Test(org.junit.Test)

Example 27 with ValidationIssues

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

the class GenericValidationRuleTest method rule115a.

@Test
public void rule115a() throws Exception {
    // Reference Sets should not contain retired concepts
    final String ruleId = "115a";
    indexRule(ruleId);
    SnomedConceptDocument r1 = concept(generateConceptId()).refSetType(SnomedRefSetType.SIMPLE).referencedComponentType(SnomedConcept.TYPE).parents(Long.parseLong(SnomedConstants.Concepts.REFSET_ROOT_CONCEPT)).build();
    SnomedConceptDocument badConcept = concept(generateConceptId()).active(false).activeMemberOf(ImmutableList.of(r1.getId())).build();
    SnomedConceptDocument goodConcept = concept(generateConceptId()).active(true).activeMemberOf(ImmutableList.of(r1.getId())).build();
    indexRevision(MAIN, r1, badConcept, goodConcept);
    ValidationIssues issues = validate(ruleId);
    assertAffectedComponents(issues, ComponentIdentifier.of(SnomedConcept.TYPE, badConcept.getId()));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) Test(org.junit.Test)

Example 28 with ValidationIssues

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

the class GenericValidationRuleTest method rule34.

@Test
public void rule34() throws Exception {
    // Relationships must be unique within a relationship group
    final String ruleId = "34";
    indexRule(ruleId);
    final SnomedRelationshipIndexEntry relationship1 = relationship(Concepts.FINDING_SITE, Concepts.IS_A, Concepts.MODULE_SCT_MODEL_COMPONENT).relationshipGroup(1).build();
    final SnomedRelationshipIndexEntry relationship2 = relationship(Concepts.FINDING_SITE, Concepts.IS_A, Concepts.MODULE_SCT_MODEL_COMPONENT).relationshipGroup(1).build();
    final SnomedRelationshipIndexEntry relationship3 = relationship(Concepts.FINDING_SITE, Concepts.IS_A, Concepts.MODULE_SCT_MODEL_COMPONENT).relationshipGroup(2).build();
    final SnomedRelationshipIndexEntry relationship4 = relationship(Concepts.FINDING_SITE, Concepts.IS_A, Concepts.MODULE_SCT_MODEL_COMPONENT).relationshipGroup(0).build();
    final SnomedRelationshipIndexEntry relationship5 = relationship(Concepts.FINDING_SITE, Concepts.IS_A, Concepts.MODULE_SCT_MODEL_COMPONENT).relationshipGroup(0).build();
    final SnomedRelationshipIndexEntry concreteValue1 = concreteValue(Concepts.FINDING_SITE, Concepts.IS_A, new RelationshipValue("Test value")).relationshipGroup(3).build();
    final SnomedRelationshipIndexEntry concreteValue2 = concreteValue(Concepts.FINDING_SITE, Concepts.IS_A, new RelationshipValue("Test value")).relationshipGroup(3).build();
    final SnomedRelationshipIndexEntry concreteValue3 = concreteValue(Concepts.FINDING_SITE, Concepts.IS_A, new RelationshipValue("Test value 2")).relationshipGroup(3).build();
    indexRevision(MAIN, relationship1, relationship2, relationship3, relationship4, relationship5, concreteValue1, concreteValue2, concreteValue3);
    ValidationIssues issues = validate(ruleId);
    assertAffectedComponents(issues, ComponentIdentifier.of(SnomedRelationship.TYPE, relationship1.getId()), ComponentIdentifier.of(SnomedRelationship.TYPE, relationship2.getId()), ComponentIdentifier.of(SnomedRelationship.TYPE, relationship4.getId()), ComponentIdentifier.of(SnomedRelationship.TYPE, relationship5.getId()), ComponentIdentifier.of(SnomedRelationship.TYPE, concreteValue1.getId()), ComponentIdentifier.of(SnomedRelationship.TYPE, concreteValue2.getId()));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) Test(org.junit.Test)

Example 29 with ValidationIssues

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

the class GenericValidationRuleTest method rule110.

@Test
public void rule110() throws Exception {
    // Subsets should not contain retired concepts
    final String ruleId = "110";
    indexRule(ruleId);
    // index relationship that doesn't belong to attribute
    SnomedRelationshipIndexEntry relationship1 = relationship(Concepts.FULLY_SPECIFIED_NAME, Concepts.SYNONYM, Concepts.MODULE_ROOT).build();
    // index relationship that belongs to attribute
    SnomedRelationshipIndexEntry relationship2 = relationship(Concepts.SYNONYM, Concepts.IS_A, Concepts.MODULE_ROOT).build();
    SnomedConceptDocument validConcept = concept(generateConceptId()).build();
    SnomedRefSetMemberIndexEntry owlAxiomMember1 = member(validConcept.getId(), Concepts.REFSET_OWL_AXIOM).referenceSetType(SnomedRefSetType.OWL_AXIOM).classAxiomRelationships(Lists.newArrayList(SnomedOWLRelationshipDocument.create(Concepts.IS_A, Concepts.PHYSICAL_OBJECT, 0))).build();
    SnomedConceptDocument concept = concept(generateConceptId()).build();
    SnomedRefSetMemberIndexEntry owlAxiomMember2 = member(concept.getId(), Concepts.REFSET_OWL_AXIOM).referenceSetType(SnomedRefSetType.OWL_AXIOM).classAxiomRelationships(Lists.newArrayList(SnomedOWLRelationshipDocument.create(Concepts.SYNONYM, Concepts.PHYSICAL_OBJECT, 0))).build();
    SnomedRefSetMemberIndexEntry owlAxiomMemberWithoutClassAxioms = member(concept.getId(), Concepts.REFSET_OWL_AXIOM).referenceSetType(SnomedRefSetType.OWL_AXIOM).classAxiomRelationships(Lists.newArrayList()).gciAxiomRelationships(Lists.newArrayList()).build();
    indexRevision(MAIN, relationship1, relationship2, validConcept, concept, owlAxiomMember1, owlAxiomMember2, owlAxiomMemberWithoutClassAxioms);
    ValidationIssues issues = validate(ruleId);
    assertAffectedComponents(issues, ComponentIdentifier.of(SnomedRelationship.TYPE, relationship1.getId()), ComponentIdentifier.of(SnomedReferenceSetMember.TYPE, owlAxiomMember2.getId()));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) Test(org.junit.Test)

Example 30 with ValidationIssues

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

the class GenericValidationRuleTest method rule667.

@Test
public void rule667() throws Exception {
    final String ruleId = "667";
    indexRule(ruleId);
    // Populate the Description Type Refset
    final String newDescriptionTypeId = generateConceptId();
    final SnomedRefSetMemberIndexEntry descriptionFormatEntry1 = member(newDescriptionTypeId, Concepts.REFSET_DESCRIPTION_TYPE).field(SnomedRf2Headers.FIELD_DESCRIPTION_LENGTH, 50).build();
    final SnomedRefSetMemberIndexEntry descriptionFormatEntry2 = member(Concepts.SYNONYM, Concepts.REFSET_DESCRIPTION_TYPE).field(SnomedRf2Headers.FIELD_DESCRIPTION_LENGTH, 255).build();
    final SnomedRefSetMemberIndexEntry descriptionFormatEntry3 = member(Concepts.FULLY_SPECIFIED_NAME, Concepts.REFSET_DESCRIPTION_TYPE).field(SnomedRf2Headers.FIELD_DESCRIPTION_LENGTH, 255).build();
    final SnomedRefSetMemberIndexEntry descriptionFormatEntry4 = member(Concepts.TEXT_DEFINITION, Concepts.REFSET_DESCRIPTION_TYPE).field(SnomedRf2Headers.FIELD_DESCRIPTION_LENGTH, 4096).build();
    // Create descriptions shorter and longer than the limit for each description type
    final SnomedDescriptionIndexEntry correctSynonym = description(generateDescriptionId(), Concepts.SYNONYM, "correct synonym length").build();
    final SnomedDescriptionIndexEntry incorrectSynonym = description(generateDescriptionId(), Concepts.SYNONYM, generateTermOfLength(256)).build();
    final SnomedDescriptionIndexEntry correctFsn = description(generateDescriptionId(), Concepts.FULLY_SPECIFIED_NAME, "correct FSN length(this is an fsn)").build();
    final SnomedDescriptionIndexEntry incorrectFsn = description(generateDescriptionId(), Concepts.FULLY_SPECIFIED_NAME, generateTermOfLength(256)).build();
    final SnomedDescriptionIndexEntry correctTextDefinition = description(generateDescriptionId(), Concepts.TEXT_DEFINITION, "Correct text definition length").build();
    final SnomedDescriptionIndexEntry incorrectTextDefinition = description(generateDescriptionId(), Concepts.TEXT_DEFINITION, generateTermOfLength(4097)).build();
    final SnomedDescriptionIndexEntry newCorrectDescriptionTypedDesc = description(generateConceptId(), newDescriptionTypeId, "correct new description type length").build();
    final SnomedDescriptionIndexEntry newIncorrectDescriptionTypedDesc = description(generateConceptId(), newDescriptionTypeId, generateTermOfLength(51)).build();
    indexRevision(MAIN, correctSynonym, incorrectSynonym, correctFsn, incorrectFsn, correctTextDefinition, incorrectTextDefinition, descriptionFormatEntry1, descriptionFormatEntry2, descriptionFormatEntry3, descriptionFormatEntry4, newCorrectDescriptionTypedDesc, newIncorrectDescriptionTypedDesc);
    final ValidationIssues issues = validate(ruleId);
    assertAffectedComponents(issues, ComponentIdentifier.of(SnomedDescription.TYPE, incorrectSynonym.getId()), ComponentIdentifier.of(SnomedDescription.TYPE, incorrectFsn.getId()), ComponentIdentifier.of(SnomedDescription.TYPE, incorrectTextDefinition.getId()), ComponentIdentifier.of(SnomedDescription.TYPE, newIncorrectDescriptionTypedDesc.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