Search in sources :

Example 21 with ValidationIssues

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

the class GenericValidationRuleTest method rule80.

@Test
public void rule80() throws Exception {
    final String ruleId = "80";
    indexRule(ruleId);
    SnomedConceptDocument invalidConcept = concept(generateConceptId()).active(true).build();
    SnomedConceptDocument validConcept1 = concept(generateConceptId()).active(true).build();
    SnomedConceptDocument validConcept2 = concept(generateConceptId()).active(true).build();
    SnomedRelationshipIndexEntry relationshipOnValidConcept = relationship(validConcept1.getId(), Concepts.IS_A, invalidConcept.getId()).build();
    SnomedRefSetMemberIndexEntry owlAxiomMemberOnValidConcpet = member(validConcept2.getId(), Concepts.REFSET_OWL_AXIOM).classAxiomRelationships(Lists.newArrayList(SnomedOWLRelationshipDocument.create(Concepts.IS_A, validConcept1.getId(), 0))).referenceSetType(SnomedRefSetType.OWL_AXIOM).build();
    indexRevision(MAIN, invalidConcept, validConcept1, validConcept2, relationshipOnValidConcept, owlAxiomMemberOnValidConcpet);
    ValidationIssues issues = validate(ruleId);
    assertThat(issues.stream().map(ValidationIssue::getAffectedComponent).collect(Collectors.toSet())).contains(ComponentIdentifier.of(SnomedConcept.TYPE, invalidConcept.getId())).doesNotContainAnyElementsOf(ImmutableList.of(ComponentIdentifier.of(SnomedConcept.TYPE, validConcept1.getId()), ComponentIdentifier.of(SnomedConcept.TYPE, validConcept2.getId())));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) ValidationIssue(com.b2international.snowowl.core.validation.issue.ValidationIssue) Test(org.junit.Test)

Example 22 with ValidationIssues

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

the class GenericValidationRuleTest method rule115b.

@Test
public void rule115b() throws Exception {
    // Reference Sets should not contain retired descriptions
    final String ruleId = "115b";
    indexRule(ruleId);
    SnomedConceptDocument r1 = concept(generateConceptId()).refSetType(SnomedRefSetType.DESCRIPTION_TYPE).referencedComponentType(SnomedDescription.TYPE).parents(Long.parseLong(SnomedConstants.Concepts.REFSET_ROOT_CONCEPT)).build();
    SnomedDescriptionIndexEntry badDesc = description(generateDescriptionId(), Concepts.FULLY_SPECIFIED_NAME, "I've been bad, i deserve this").active(false).activeMemberOf(ImmutableList.of(r1.getId())).build();
    SnomedDescriptionIndexEntry goodDesc = description(generateDescriptionId(), Concepts.FULLY_SPECIFIED_NAME, "I've been good, i deserve this").active(true).activeMemberOf(ImmutableList.of(r1.getId())).build();
    indexRevision(MAIN, r1, badDesc, goodDesc);
    ValidationIssues issues = validate(ruleId);
    assertAffectedComponents(issues, ComponentIdentifier.of(SnomedDescription.TYPE, badDesc.getId()));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) Test(org.junit.Test)

Example 23 with ValidationIssues

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

the class GenericValidationRuleTest method rule_mrcm_constraint.

@Test
public void rule_mrcm_constraint() throws Exception {
    final String ruleId = "rule_mrcm_constraint";
    indexRule(ruleId);
    // Create 1st MRCM rule
    final SnomedRefSetMemberIndexEntry mrcmRangeMember1 = member(Concepts.FINDING_SITE, Concepts.REFSET_MRCM_ATTRIBUTE_RANGE_INTERNATIONAL).referenceSetType(SnomedRefSetType.MRCM_ATTRIBUTE_RANGE).typeId(SnomedRefSetType.MRCM_ATTRIBUTE_RANGE.getName()).rangeConstraint(String.format("<<%s", Concepts.PHYSICAL_OBJECT)).contentTypeId(PRECOORDINATED_CONTENT).build();
    // Create 2nd MRCM rule (6b6e3ed0-383e-4950-b7e8-ae11277663b9)
    final SnomedRefSetMemberIndexEntry mrcmRangeMember2 = member(ASSOCIATED_PROCEDURE, Concepts.REFSET_MRCM_ATTRIBUTE_RANGE_INTERNATIONAL).referenceSetType(SnomedRefSetType.MRCM_ATTRIBUTE_RANGE).typeId(SnomedRefSetType.MRCM_ATTRIBUTE_RANGE.getName()).rangeConstraint("<< 71388002 |Procedure (procedure)|").contentTypeId(PRECOORDINATED_CONTENT).build();
    // Create 3rd MRCM rule (ae16bb19-1389-403c-888d-ea81c9c13d4f)
    final SnomedRefSetMemberIndexEntry mrcmRangeMember3 = member(ASSOCIATED_PROCEDURE, Concepts.REFSET_MRCM_ATTRIBUTE_RANGE_INTERNATIONAL).referenceSetType(SnomedRefSetType.MRCM_ATTRIBUTE_RANGE).typeId(SnomedRefSetType.MRCM_ATTRIBUTE_RANGE.getName()).rangeConstraint("<< 363787002 |Observable entity (observable entity)| OR << 71388002 |Procedure (procedure)|").contentTypeId(POSTCOORDINATED_CONTENT).build();
    // Create concrete value MRCM rule
    final SnomedRefSetMemberIndexEntry mrcmRangeMember4 = member(Concepts.PHYSICAL_OBJECT, Concepts.REFSET_MRCM_ATTRIBUTE_RANGE_INTERNATIONAL).referenceSetType(SnomedRefSetType.MRCM_ATTRIBUTE_RANGE).typeId(SnomedRefSetType.MRCM_ATTRIBUTE_RANGE.getName()).rangeConstraint("int(>#0)").contentTypeId(POSTCOORDINATED_CONTENT).build();
    final SnomedRelationshipIndexEntry relationship1 = relationship(Concepts.CONCEPT_MODEL_ATTRIBUTE, Concepts.FINDING_SITE, 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.FINDING_SITE, Concepts.PHYSICAL_OBJECT).relationshipGroup(2).build();
    final SnomedRelationshipIndexEntry relationship4 = relationship(Concepts.ROOT_CONCEPT, ASSOCIATED_PROCEDURE, OBSERVABLE_ENTITY).relationshipGroup(2).build();
    final SnomedRelationshipIndexEntry relationship5 = relationship(Concepts.ROOT_CONCEPT, ASSOCIATED_PROCEDURE, PROCEDURE).relationshipGroup(2).build();
    SnomedRefSetMemberIndexEntry axiomMember1 = member(Concepts.CONCEPT_MODEL_ATTRIBUTE, Concepts.REFSET_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)).referenceSetType(SnomedRefSetType.OWL_AXIOM).build();
    SnomedRefSetMemberIndexEntry axiomMember2 = member(Concepts.CONCEPT_MODEL_ATTRIBUTE, Concepts.REFSET_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)).referenceSetType(SnomedRefSetType.OWL_AXIOM).build();
    SnomedRefSetMemberIndexEntry axiomMember3 = member(Concepts.ROOT_CONCEPT, Concepts.REFSET_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)).referenceSetType(SnomedRefSetType.OWL_AXIOM).build();
    indexRevision(MAIN, mrcmRangeMember1, mrcmRangeMember2, mrcmRangeMember3, mrcmRangeMember4, relationship1, relationship2, relationship3, relationship4, relationship5, axiomMember1, axiomMember2, axiomMember3);
    ValidationIssues issues = validate(ruleId);
    assertAffectedComponents(issues, ComponentIdentifier.of(SnomedRelationship.TYPE, relationship1.getId()), ComponentIdentifier.of(SnomedRelationship.TYPE, relationship4.getId()), ComponentIdentifier.of(SnomedReferenceSetMember.TYPE, axiomMember1.getId()), ComponentIdentifier.of(SnomedReferenceSetMember.TYPE, axiomMember3.getId()));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) Test(org.junit.Test)

Example 24 with ValidationIssues

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

the class GenericValidationRuleTest method rule669.

@Test
public void rule669() throws Exception {
    final String ruleId = "669";
    indexRule(ruleId);
    final long publishedEffectiveTime = Instant.now().toEpochMilli();
    final SnomedRefSetMemberIndexEntry duplicateSimpleMember1 = member(Concepts.IS_A, Concepts.MODULE_ROOT).referenceSetType(SnomedRefSetType.SIMPLE).effectiveTime(publishedEffectiveTime).build();
    final SnomedRefSetMemberIndexEntry duplicateSimpleMember2 = member(Concepts.IS_A, Concepts.MODULE_ROOT).referenceSetType(SnomedRefSetType.SIMPLE).build();
    final SnomedRefSetMemberIndexEntry correctSimpleMember = member(Concepts.IS_A, Concepts.MODULE_SCT_CORE).referenceSetType(SnomedRefSetType.SIMPLE).build();
    final SnomedRefSetMemberIndexEntry duplicateLanguageMember1 = member(Concepts.REFSET_ROOT_CONCEPT, Concepts.REFSET_LANGUAGE_TYPE_UK).referenceSetType(SnomedRefSetType.LANGUAGE).effectiveTime(publishedEffectiveTime).build();
    final SnomedRefSetMemberIndexEntry duplicateLanguageMember2 = member(Concepts.REFSET_ROOT_CONCEPT, Concepts.REFSET_LANGUAGE_TYPE_UK).referenceSetType(SnomedRefSetType.LANGUAGE).build();
    final SnomedRefSetMemberIndexEntry correctLanguageMember = member(Concepts.REFSET_ROOT_CONCEPT, Concepts.REFSET_LANGUAGE_TYPE_US).referenceSetType(SnomedRefSetType.LANGUAGE).build();
    final SnomedRefSetMemberIndexEntry duplicateAttributeMember1 = member(Concepts.ATTRIBUTE_TYPE_CONCEPT_TYPE_COMPONENT, Concepts.REFSET_ATTRIBUTE_VALUE_TYPE).referenceSetType(SnomedRefSetType.ATTRIBUTE_VALUE).effectiveTime(publishedEffectiveTime).build();
    final SnomedRefSetMemberIndexEntry duplicateAttributeMember2 = member(Concepts.ATTRIBUTE_TYPE_CONCEPT_TYPE_COMPONENT, Concepts.REFSET_ATTRIBUTE_VALUE_TYPE).referenceSetType(SnomedRefSetType.ATTRIBUTE_VALUE).build();
    final SnomedRefSetMemberIndexEntry correctAttributeMember = member(Concepts.ATTRIBUTE_TYPE_CONCEPT_TYPE_COMPONENT, Concepts.MODULE_SCT_CORE).referenceSetType(SnomedRefSetType.ATTRIBUTE_VALUE).build();
    final SnomedRefSetMemberIndexEntry duplicateAttributeMemberWithModule1 = member(Concepts.ATTRIBUTE, Concepts.REFSET_ATTRIBUTE_VALUE_TYPE).moduleId(Concepts.MODULE_SCT_CORE).referenceSetType(SnomedRefSetType.ATTRIBUTE_VALUE).build();
    final SnomedRefSetMemberIndexEntry duplicateAttributeMemberWithModule2 = member(Concepts.ATTRIBUTE, Concepts.REFSET_ATTRIBUTE_VALUE_TYPE).moduleId(Concepts.MODULE_SCT_CORE).referenceSetType(SnomedRefSetType.ATTRIBUTE_VALUE).build();
    final SnomedRefSetMemberIndexEntry correctAttributeMemberWithModule = member(Concepts.ATTRIBUTE, Concepts.REFSET_ATTRIBUTE_VALUE_TYPE).moduleId(Concepts.UK_CLINICAL_EXTENSION_MODULE).referenceSetType(SnomedRefSetType.ATTRIBUTE_VALUE).build();
    indexRevision(MAIN, duplicateSimpleMember1, duplicateSimpleMember2, correctSimpleMember, duplicateLanguageMember1, duplicateLanguageMember2, correctLanguageMember, duplicateAttributeMember1, duplicateAttributeMember2, correctAttributeMember, duplicateAttributeMemberWithModule1, duplicateAttributeMemberWithModule2, correctAttributeMemberWithModule);
    final ValidationIssues issues = validate(ruleId);
    assertAffectedComponents(issues, ComponentIdentifier.of(SnomedConcept.TYPE, Concepts.IS_A), ComponentIdentifier.of(SnomedConcept.TYPE, Concepts.REFSET_ROOT_CONCEPT), ComponentIdentifier.of(SnomedConcept.TYPE, Concepts.ATTRIBUTE_TYPE_CONCEPT_TYPE_COMPONENT), ComponentIdentifier.of(SnomedConcept.TYPE, Concepts.ATTRIBUTE));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) Test(org.junit.Test)

Example 25 with ValidationIssues

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

the class GenericValidationRuleTest method rule45b.

@Test
public void rule45b() throws Exception {
    final String ruleId = "45b";
    indexRule(ruleId);
    // index invalid non-defining relationship to group 1
    final SnomedRelationshipIndexEntry relationship = relationship(Concepts.MORPHOLOGY, Concepts.CAUSATIVE_AGENT, Concepts.MODULE_SCT_MODEL_COMPONENT, Concepts.ADDITIONAL_RELATIONSHIP).relationshipGroup(1).build();
    indexRevision(MAIN, relationship);
    ValidationIssues issues = validate(ruleId);
    assertAffectedComponents(issues, ComponentIdentifier.of(SnomedRelationship.TYPE, relationship.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