Search in sources :

Example 16 with ValidationIssues

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

the class GenericValidationRuleTest method rule328.

@Test
public void rule328() throws Exception {
    final String ruleId = "328";
    indexRule(ruleId);
    SnomedConceptDocument concept1 = concept(generateConceptId()).effectiveTime(effectiveTime).build();
    SnomedDescriptionIndexEntry description1 = description(generateDescriptionId(), Concepts.SYNONYM, "Good synonym!").moduleId(Concepts.MODULE_B2I_EXTENSION).conceptId(concept1.getId()).build();
    SnomedConceptDocument concept2 = concept(generateConceptId()).effectiveTime(effectiveTime).build();
    SnomedDescriptionIndexEntry description2 = description(generateDescriptionId(), Concepts.SYNONYM, "Bád synonym @").moduleId(Concepts.MODULE_SCT_CORE).conceptId(concept2.getId()).build();
    SnomedConceptDocument concept3 = concept(generateConceptId()).effectiveTime(effectiveTime).build();
    SnomedDescriptionIndexEntry description3 = description(generateDescriptionId(), Concepts.SYNONYM, "Bád synonym $").moduleId(Concepts.MODULE_B2I_EXTENSION).conceptId(concept3.getId()).build();
    indexRevision(MAIN, concept1, concept2, concept3, description1, description2, description3);
    ValidationIssues issues = validate(ruleId);
    assertAffectedComponents(issues, ComponentIdentifier.of(SnomedDescription.TYPE, description3.getId()));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) Test(org.junit.Test)

Example 17 with ValidationIssues

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

the class GenericValidationRuleTest method rule668.

@Test
public void rule668() throws Exception {
    final String ruleId = "668";
    indexRule(ruleId);
    SnomedConceptDocument activeSourceConcept = concept(generateConceptId()).active(true).build();
    SnomedConceptDocument inactiveSourceConcept = concept(generateConceptId()).active(false).build();
    SnomedConceptDocument inactiveTypeConcept = concept(generateConceptId()).active(false).build();
    SnomedConceptDocument activeTypeConcept = concept(generateConceptId()).active(true).build();
    SnomedConceptDocument inactiveDestinationConcept = concept(generateConceptId()).active(false).build();
    SnomedConceptDocument activeDestinationConcept = concept(generateConceptId()).active(true).build();
    SnomedRefSetMemberIndexEntry invalidSourceAxiomMember = member(inactiveSourceConcept.getId(), Concepts.REFSET_OWL_AXIOM).classAxiomRelationships(Lists.newArrayList(SnomedOWLRelationshipDocument.create(Concepts.IS_A, activeDestinationConcept.getId(), 0))).build();
    SnomedRefSetMemberIndexEntry validSourceAxiomMember = member(activeSourceConcept.getId(), Concepts.REFSET_OWL_AXIOM).classAxiomRelationships(Lists.newArrayList(SnomedOWLRelationshipDocument.create(Concepts.IS_A, activeDestinationConcept.getId(), 0))).build();
    SnomedRefSetMemberIndexEntry invalidDestinationAxiomMember = member(activeSourceConcept.getId(), Concepts.REFSET_OWL_AXIOM).classAxiomRelationships(Lists.newArrayList(SnomedOWLRelationshipDocument.create(Concepts.IS_A, inactiveDestinationConcept.getId(), 0))).build();
    SnomedRefSetMemberIndexEntry invalidDestinationGciAxiomMember = member(activeSourceConcept.getId(), Concepts.REFSET_OWL_AXIOM).gciAxiomRelationships(Lists.newArrayList(SnomedOWLRelationshipDocument.create(activeTypeConcept.getId(), inactiveDestinationConcept.getId(), 0))).build();
    SnomedRefSetMemberIndexEntry invalidTypeAxiomMember = member(activeSourceConcept.getId(), Concepts.REFSET_OWL_AXIOM).classAxiomRelationships(Lists.newArrayList(SnomedOWLRelationshipDocument.create(inactiveTypeConcept.getId(), activeDestinationConcept.getId(), 0))).build();
    SnomedRefSetMemberIndexEntry validGciAxiomMember = member(activeSourceConcept.getId(), Concepts.REFSET_OWL_AXIOM).gciAxiomRelationships(Lists.newArrayList(SnomedOWLRelationshipDocument.create(activeTypeConcept.getId(), activeDestinationConcept.getId(), 0))).build();
    indexRevision(MAIN, activeSourceConcept, inactiveSourceConcept, inactiveTypeConcept, activeTypeConcept, inactiveDestinationConcept, activeDestinationConcept, validSourceAxiomMember, invalidSourceAxiomMember, invalidDestinationAxiomMember, invalidDestinationGciAxiomMember, invalidTypeAxiomMember, validGciAxiomMember);
    ValidationIssues validationIssues = validate(ruleId);
    assertAffectedComponents(validationIssues, ComponentIdentifier.of(SnomedReferenceSetMember.TYPE, invalidSourceAxiomMember.getId()), ComponentIdentifier.of(SnomedReferenceSetMember.TYPE, invalidDestinationAxiomMember.getId()), ComponentIdentifier.of(SnomedReferenceSetMember.TYPE, invalidDestinationGciAxiomMember.getId()), ComponentIdentifier.of(SnomedReferenceSetMember.TYPE, invalidTypeAxiomMember.getId()));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) Test(org.junit.Test)

Example 18 with ValidationIssues

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

the class GenericValidationRuleTest method rule45c.

@Test
public void rule45c() throws Exception {
    final String ruleId = "45c";
    indexRule(ruleId);
    // index invalid non-defining relationship to group 0
    final SnomedRelationshipIndexEntry nonDefiningRelationshipInGroup0 = relationship(Concepts.MORPHOLOGY, Concepts.CAUSATIVE_AGENT, Concepts.MODULE_SCT_MODEL_COMPONENT, Concepts.ADDITIONAL_RELATIONSHIP).relationshipGroup(0).build();
    // index valid defining relationship to group 0
    final SnomedRelationshipIndexEntry definingRelationshipInGroup0 = relationship(Concepts.MORPHOLOGY, Concepts.CAUSATIVE_AGENT, Concepts.MODULE_SCT_MODEL_COMPONENT, Concepts.STATED_RELATIONSHIP).relationshipGroup(0).build();
    // index valid non-defining relationship to group 2
    final SnomedRelationshipIndexEntry relationshipInGroup2 = relationship(Concepts.MORPHOLOGY, Concepts.CAUSATIVE_AGENT, Concepts.MODULE_SCT_MODEL_COMPONENT, Concepts.ADDITIONAL_RELATIONSHIP).relationshipGroup(2).build();
    indexRevision(MAIN, nonDefiningRelationshipInGroup0, definingRelationshipInGroup0, relationshipInGroup2);
    ValidationIssues issues = validate(ruleId);
    assertThat(issues.stream().map(ValidationIssue::getAffectedComponent).collect(Collectors.toSet())).contains(ComponentIdentifier.of(SnomedRelationship.TYPE, nonDefiningRelationshipInGroup0.getId())).doesNotContainAnyElementsOf(ImmutableList.of(ComponentIdentifier.of(SnomedRelationship.TYPE, definingRelationshipInGroup0.getId()), ComponentIdentifier.of(SnomedRelationship.TYPE, relationshipInGroup2.getId())));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) ValidationIssue(com.b2international.snowowl.core.validation.issue.ValidationIssue) Test(org.junit.Test)

Example 19 with ValidationIssues

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

the class GenericValidationRuleTest method rule532.

private void rule532(String ruleId, String descriptionType, String moduleId) throws Exception {
    indexRule(ruleId);
    SnomedDescriptionIndexEntry validDescription = description(generateDescriptionId(), descriptionType, "Not duplicate term").conceptId(generateConceptId()).build();
    SnomedDescriptionIndexEntry invalidDescription1 = description(generateDescriptionId(), descriptionType, "Duplicate description").conceptId(generateConceptId()).moduleId(moduleId).build();
    SnomedRefSetMemberIndexEntry inactivationIndicator1 = member(invalidDescription1.getId(), Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR).active(true).field(SnomedRf2Headers.FIELD_VALUE_ID, Concepts.PENDING_MOVE).build();
    SnomedDescriptionIndexEntry invalidDescription2 = description(generateDescriptionId(), descriptionType, "duplicate description").conceptId(generateConceptId()).moduleId(moduleId).build();
    SnomedDescriptionIndexEntry invalidIntDescription1 = description(generateDescriptionId(), descriptionType, "Duplicate description").conceptId(generateConceptId()).moduleId(Concepts.MODULE_SCT_CORE).build();
    SnomedDescriptionIndexEntry invalidIntDescription2 = description(generateDescriptionId(), descriptionType, "Duplicate of International description").conceptId(generateConceptId()).moduleId(Concepts.MODULE_SCT_CORE).build();
    SnomedDescriptionIndexEntry invalidIntDescription3 = description(generateDescriptionId(), descriptionType, "Duplicate of International description").conceptId(generateConceptId()).moduleId(Concepts.MODULE_SCT_CORE).build();
    SnomedDescriptionIndexEntry invalidDescription3 = description(generateDescriptionId(), descriptionType, "This is fine").conceptId(generateConceptId()).moduleId(moduleId).build();
    SnomedDescriptionIndexEntry invalidDescription4 = description(generateDescriptionId(), descriptionType, "this is fine").conceptId(generateConceptId()).moduleId(moduleId).build();
    SnomedDescriptionIndexEntry shouldNotCauseIssueDescription3 = description(generateDescriptionId(), descriptionType, "duplicate description").activeMemberOf(ImmutableList.of(Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR)).conceptId(generateConceptId()).build();
    index().prepareCommit(MAIN).stageNew(validDescription).stageNew(invalidDescription1).stageNew(inactivationIndicator1).stageNew(invalidDescription2).stageNew(invalidIntDescription1).stageNew(invalidIntDescription2).stageNew(invalidIntDescription3).stageNew(invalidDescription3).stageNew(invalidDescription4).stageNew(shouldNotCauseIssueDescription3).commit(currentTime(), UUID.randomUUID().toString(), "Indexing data for rule 532 test");
    ValidationIssues issues = validate(ruleId);
    assertAffectedComponents(issues, ComponentIdentifier.of(SnomedDescription.TYPE, invalidDescription1.getId()), ComponentIdentifier.of(SnomedDescription.TYPE, invalidIntDescription1.getId()), ComponentIdentifier.of(SnomedDescription.TYPE, invalidDescription2.getId()), ComponentIdentifier.of(SnomedDescription.TYPE, invalidDescription3.getId()), ComponentIdentifier.of(SnomedDescription.TYPE, invalidDescription4.getId()));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues)

Example 20 with ValidationIssues

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

the class GenericValidationRuleTest method rule666.

@Test
public void rule666() throws Exception {
    final String ruleId = "666";
    indexRule(ruleId);
    // index concept with two FSNs in the same language refset
    String concept1Id = generateConceptId();
    SnomedDescriptionIndexEntry fsn1 = description(generateDescriptionId(), Concepts.FULLY_SPECIFIED_NAME, "Fully specified name 1 (tag)").conceptId(concept1Id).acceptability(Concepts.REFSET_LANGUAGE_TYPE_ES, Acceptability.PREFERRED).build();
    SnomedRefSetMemberIndexEntry fsn1Member = createLanguageRefsetMember(fsn1);
    SnomedDescriptionIndexEntry fsn2 = description(generateDescriptionId(), Concepts.FULLY_SPECIFIED_NAME, "Fully specified name 2 (tag)").conceptId(concept1Id).acceptability(Concepts.REFSET_LANGUAGE_TYPE_ES, Acceptability.PREFERRED).build();
    SnomedRefSetMemberIndexEntry fsn2Member = createLanguageRefsetMember(fsn2);
    SnomedConceptDocument c1 = concept(concept1Id).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(fsn1.getId(), fsn1.getTypeId(), fsn1.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_ES), new SnomedDescriptionFragment(fsn2.getId(), fsn2.getTypeId(), fsn2.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_ES))).build();
    // index concept with two PTs in the same language refset
    String concept2Id = generateConceptId();
    SnomedDescriptionIndexEntry pt1 = description(generateDescriptionId(), Concepts.SYNONYM, "Preferred term 1").acceptability(Concepts.REFSET_LANGUAGE_TYPE_ES, Acceptability.PREFERRED).conceptId(concept2Id).build();
    SnomedRefSetMemberIndexEntry pt1Member = createLanguageRefsetMember(pt1);
    SnomedDescriptionIndexEntry pt2 = description(generateDescriptionId(), Concepts.SYNONYM, "Preferred term 2").acceptability(Concepts.REFSET_LANGUAGE_TYPE_ES, Acceptability.PREFERRED).conceptId(concept2Id).build();
    SnomedRefSetMemberIndexEntry pt2Member = createLanguageRefsetMember(pt2);
    SnomedConceptDocument c2 = concept(concept2Id).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(pt1.getId(), pt1.getTypeId(), pt1.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_ES), new SnomedDescriptionFragment(pt2.getId(), pt2.getTypeId(), pt2.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_ES))).build();
    // index concept with only one PT and one FSN in a given language refset
    String concept3Id = generateConceptId();
    SnomedDescriptionIndexEntry fsn3 = description(generateDescriptionId(), Concepts.FULLY_SPECIFIED_NAME, "Fully specified name 3 (tag)").conceptId(concept3Id).acceptability(Concepts.REFSET_LANGUAGE_TYPE_ES, Acceptability.PREFERRED).build();
    SnomedRefSetMemberIndexEntry fsn3Member = createLanguageRefsetMember(fsn3);
    SnomedDescriptionIndexEntry pt3 = description(generateDescriptionId(), Concepts.SYNONYM, "Preferred term 3").acceptability(Concepts.REFSET_LANGUAGE_TYPE_ES, Acceptability.PREFERRED).conceptId(concept3Id).build();
    SnomedRefSetMemberIndexEntry pt3Member = createLanguageRefsetMember(pt3);
    SnomedConceptDocument c3 = concept(concept3Id).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(fsn3.getId(), fsn3.getTypeId(), fsn3.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_ES), new SnomedDescriptionFragment(pt3.getId(), pt3.getTypeId(), pt3.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_ES))).build();
    indexRevision(MAIN, fsn1, fsn2, c1, pt1, pt2, c2, fsn3, pt3, c3, fsn1Member, fsn2Member, fsn3Member, pt1Member, pt2Member, pt3Member);
    ValidationIssues issues = validate(ruleId);
    assertAffectedComponents(issues, ComponentIdentifier.of(SnomedConcept.TYPE, c1.getId()), ComponentIdentifier.of(SnomedConcept.TYPE, c2.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