use of com.b2international.index.revision.Revision in project snow-owl by b2ihealthcare.
the class ConceptChangeProcessorAxiomTest method activateIsa_InactivateOwlMember.
@Test
public void activateIsa_InactivateOwlMember() throws Exception {
final SnomedConceptDocument parentConcept = concept().build();
final SnomedConceptDocument concept = concept().statedParents(Long.parseLong(parentConcept.getId())).statedAncestors(IComponent.ROOT_IDL).activeMemberOf(Collections.singleton(Concepts.REFSET_OWL_AXIOM)).memberOf(Collections.singleton(Concepts.REFSET_OWL_AXIOM)).build();
SnomedRelationshipIndexEntry isaRelationship = SnomedRelationshipIndexEntry.builder(createStatedRelationship(concept.getId(), Concepts.IS_A, parentConcept.getId())).active(false).build();
SnomedRefSetMemberIndexEntry member = createOwlAxiom(concept.getId(), String.format("SubClassOf(:%s :%s)", concept.getId(), parentConcept.getId())).classAxiomRelationships(ImmutableList.of(SnomedOWLRelationshipDocument.create(Concepts.IS_A, parentConcept.getId(), 0))).build();
indexRevision(MAIN, concept, parentConcept, isaRelationship, member);
statedChangedConceptIds.add(Long.parseLong(concept.getId()));
statedChangedConceptIds.add(Long.parseLong(parentConcept.getId()));
stageChange(isaRelationship, SnomedRelationshipIndexEntry.builder(isaRelationship).active(true).build());
stageChange(member, SnomedRefSetMemberIndexEntry.builder(member).active(false).build());
final ConceptChangeProcessor processor = process();
assertEquals(1, processor.getChangedMappings().size());
final SnomedConceptDocument expected = docWithDefaults(concept).statedParents(Long.parseLong(parentConcept.getId())).statedAncestors(IComponent.ROOT_IDL).memberOf(Collections.singleton(Concepts.REFSET_OWL_AXIOM)).build();
final Revision actual = Iterables.getOnlyElement(processor.getChangedMappings().values()).getNewRevision();
assertDocEquals(expected, actual);
assertEquals(0, processor.getNewMappings().size());
assertEquals(0, processor.getDeletions().size());
}
use of com.b2international.index.revision.Revision in project snow-owl by b2ihealthcare.
the class ConceptChangeProcessorAxiomTest method updateAxiomParent.
@Test
public void updateAxiomParent() throws Exception {
SnomedConceptDocument parentConcept = concept().build();
SnomedConceptDocument concept = concept().statedParents(Long.parseLong(parentConcept.getId())).statedAncestors(IComponent.ROOT_IDL).activeMemberOf(Collections.singleton(Concepts.REFSET_OWL_AXIOM)).memberOf(Collections.singleton(Concepts.REFSET_OWL_AXIOM)).build();
SnomedConceptDocument parentConcept2 = concept().build();
SnomedRefSetMemberIndexEntry member = createOwlAxiom(concept.getId(), String.format("SubClassOf(:%s :%s)", concept.getId(), parentConcept.getId())).classAxiomRelationships(ImmutableList.of(SnomedOWLRelationshipDocument.create(Concepts.IS_A, parentConcept.getId(), 0))).build();
indexRevision(MAIN, concept, parentConcept, parentConcept2, member);
statedChangedConceptIds.add(Long.parseLong(concept.getId()));
statedChangedConceptIds.add(Long.parseLong(parentConcept.getId()));
statedChangedConceptIds.add(Long.parseLong(parentConcept2.getId()));
// update axiom
stageChange(member, SnomedRefSetMemberIndexEntry.builder(member).owlExpression(String.format("SubClassOf(:%s :%s)", concept.getId(), parentConcept2.getId())).build());
final ConceptChangeProcessor processor = process();
assertEquals(1, processor.getChangedMappings().size());
final SnomedConceptDocument expected = docWithDefaults(concept).statedParents(Long.parseLong(parentConcept2.getId())).statedAncestors(IComponent.ROOT_IDL).activeMemberOf(Collections.singleton(Concepts.REFSET_OWL_AXIOM)).memberOf(Collections.singleton(Concepts.REFSET_OWL_AXIOM)).build();
final Revision actual = Iterables.getOnlyElement(processor.getChangedMappings().values()).getNewRevision();
assertDocEquals(expected, actual);
assertEquals(0, processor.getNewMappings().size());
assertEquals(0, processor.getDeletions().size());
}
use of com.b2international.index.revision.Revision in project snow-owl by b2ihealthcare.
the class ConceptChangeProcessorAxiomTest method deleteSubClassOfAxiom_TwoTargets.
@Test
public void deleteSubClassOfAxiom_TwoTargets() throws Exception {
final SnomedConceptDocument parentConcept = concept().build();
final SnomedConceptDocument parentConcept2 = concept().build();
final SnomedConceptDocument concept = concept().statedParents(Long.parseLong(parentConcept.getId())).statedAncestors(IComponent.ROOT_IDL).build();
final SnomedRefSetMemberIndexEntry member = createOwlAxiom(concept.getId(), String.format("SubClassOf(:%s ObjectIntersectionOf(:%s :%s))", concept.getId(), parentConcept.getId(), parentConcept2.getId())).classAxiomRelationships(ImmutableList.of(SnomedOWLRelationshipDocument.create(Concepts.IS_A, parentConcept.getId(), 0))).build();
indexRevision(MAIN, concept, parentConcept, parentConcept2, member);
statedChangedConceptIds.add(Long.parseLong(concept.getId()));
statedChangedConceptIds.add(Long.parseLong(parentConcept.getId()));
stageRemove(member);
final ConceptChangeProcessor processor = process();
assertEquals(1, processor.getChangedMappings().size());
final SnomedConceptDocument expected = docWithDefaults(concept).statedParents(IComponent.ROOT_IDL).build();
final Revision actual = Iterables.getOnlyElement(processor.getChangedMappings().values()).getNewRevision();
assertDocEquals(expected, actual);
assertEquals(0, processor.getNewMappings().size());
assertEquals(0, processor.getDeletions().size());
}
use of com.b2international.index.revision.Revision in project snow-owl by b2ihealthcare.
the class ConceptChangeProcessorAxiomTest method newEmptyAxiom.
@Test
public void newEmptyAxiom() throws Exception {
SnomedConceptDocument concept = concept().build();
indexRevision(MAIN, concept);
SnomedRefSetMemberIndexEntry member = createOwlAxiom(concept.getId(), "").build();
stageNew(member);
final ConceptChangeProcessor processor = process();
assertEquals(1, processor.getChangedMappings().size());
final SnomedConceptDocument expected = docWithDefaults(concept).activeMemberOf(Collections.singleton(Concepts.REFSET_OWL_AXIOM)).memberOf(Collections.singleton(Concepts.REFSET_OWL_AXIOM)).build();
final Revision actual = Iterables.getOnlyElement(processor.getChangedMappings().values()).getNewRevision();
assertDocEquals(expected, actual);
assertEquals(0, processor.getNewMappings().size());
assertEquals(0, processor.getDeletions().size());
}
use of com.b2international.index.revision.Revision in project snow-owl by b2ihealthcare.
the class ConceptChangeProcessorAxiomTest method newSubClassOfAxiom.
@Test
public void newSubClassOfAxiom() throws Exception {
SnomedConceptDocument concept = concept().build();
SnomedConceptDocument parentConcept = concept().build();
indexRevision(MAIN, concept, parentConcept);
statedChangedConceptIds.add(Long.parseLong(concept.getId()));
statedChangedConceptIds.add(Long.parseLong(parentConcept.getId()));
SnomedRefSetMemberIndexEntry member = createOwlAxiom(concept.getId(), String.format("SubClassOf(:%s :%s)", concept.getId(), parentConcept.getId())).build();
stageNew(member);
final ConceptChangeProcessor processor = process();
assertEquals(1, processor.getChangedMappings().size());
final SnomedConceptDocument expected = docWithDefaults(concept).statedParents(Long.parseLong(parentConcept.getId())).statedAncestors(IComponent.ROOT_IDL).activeMemberOf(Collections.singleton(Concepts.REFSET_OWL_AXIOM)).memberOf(Collections.singleton(Concepts.REFSET_OWL_AXIOM)).build();
final Revision actual = Iterables.getOnlyElement(processor.getChangedMappings().values()).getNewRevision();
assertDocEquals(expected, actual);
assertEquals(0, processor.getNewMappings().size());
assertEquals(0, processor.getDeletions().size());
}
Aggregations