use of com.b2international.index.revision.Revision in project snow-owl by b2ihealthcare.
the class TaxonomyPreCommitHookTest method indexStatedInferredChild.
@Test
public void indexStatedInferredChild() throws Exception {
// index the ROOT concept as existing concept
final long rootConceptId = Long.parseLong(Concepts.ROOT_CONCEPT);
statedChangedConceptIds.add(rootConceptId);
inferredChangedConceptIds.add(rootConceptId);
final SnomedConceptDocument concept = concept().build();
stageNew(concept);
final SnomedRelationshipIndexEntry statedRelationship = createStatedRelationship(concept.getId(), Concepts.IS_A, Concepts.ROOT_CONCEPT);
stageNew(statedRelationship);
final SnomedRelationshipIndexEntry inferredRelationship = createInferredRelationship(concept.getId(), Concepts.IS_A, Concepts.ROOT_CONCEPT);
stageNew(inferredRelationship);
final ConceptChangeProcessor processor = process();
final SnomedConceptDocument expected = docWithDefaults(concept).parents(PrimitiveSets.newLongSortedSet(rootConceptId)).ancestors(PrimitiveSets.newLongSortedSet(IComponent.ROOT_IDL)).statedParents(PrimitiveSets.newLongSortedSet(rootConceptId)).statedAncestors(PrimitiveSets.newLongSortedSet(IComponent.ROOT_IDL)).build();
final Revision actual = Iterables.getOnlyElement(processor.getNewMappings().values());
assertDocEquals(expected, actual);
assertEquals(0, processor.getChangedMappings().size());
assertEquals(0, processor.getDeletions().size());
}
use of com.b2international.index.revision.Revision in project snow-owl by b2ihealthcare.
the class TaxonomyPreCommitHookTest method updateStatedRelationshipDestination.
@Test
public void updateStatedRelationshipDestination() throws Exception {
final SnomedConceptDocument sourceConcept = concept().build();
final SnomedConceptDocument newDestinationConcept = concept(Concepts.NAMESPACE_ROOT).build();
final long concept1Id = Long.parseLong(sourceConcept.getId());
final long concept2Id = Long.parseLong(newDestinationConcept.getId());
// register IDs for stated changes
statedChangedConceptIds.add(ROOT_CONCEPTL);
statedChangedConceptIds.add(concept1Id);
statedChangedConceptIds.add(concept2Id);
// prepare index repository state
final SnomedRelationshipIndexEntry statedRelationship = createStatedRelationship(sourceConcept.getId(), Concepts.IS_A, Concepts.ROOT_CONCEPT);
initRevisions(statedRelationship, docWithDefaults(sourceConcept).statedParents(ROOT_CONCEPTL).build(), docWithDefaults(newDestinationConcept).build());
// change destination from ROOT to NEWDST
stageChange(statedRelationship, SnomedRelationshipIndexEntry.builder(statedRelationship).destinationId(newDestinationConcept.getId()).build());
final ConceptChangeProcessor processor = process();
final SnomedConceptDocument expected = docWithDefaults(sourceConcept).iconId(Concepts.NAMESPACE_ROOT).statedParents(PrimitiveSets.newLongSortedSet(concept2Id)).statedAncestors(PrimitiveSets.newLongSortedSet(IComponent.ROOT_IDL)).build();
assertEquals(1, processor.getChangedMappings().size());
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 TaxonomyPreCommitHookTest method addIsaRelationshipToExistingConcepts.
@Test
public void addIsaRelationshipToExistingConcepts() throws Exception {
// given a parent concept and child concept
final SnomedConceptDocument parent = concept().build();
final SnomedConceptDocument child = concept().build();
final long parentIdLong = Long.parseLong(parent.getId());
final long childIdLong = Long.parseLong(child.getId());
statedChangedConceptIds.add(parentIdLong);
statedChangedConceptIds.add(childIdLong);
// index the child and parent concept documents as current state
initRevisions(docWithDefaults(parent).build(), docWithDefaults(child).build());
// add a new stated relationship between the two
final SnomedRelationshipIndexEntry childToParentIsa = createStatedRelationship(child.getId(), Concepts.IS_A, parent.getId());
stageNew(childToParentIsa);
final ConceptChangeProcessor processor = process();
// the child document should be reindexed with new parent information
assertEquals(1, processor.getChangedMappings().size());
final SnomedConceptDocument expectedDoc = docWithDefaults(child).statedParents(PrimitiveSets.newLongSortedSet(parentIdLong)).statedAncestors(PrimitiveSets.newLongSortedSet(IComponent.ROOT_IDL)).build();
final Revision changedDoc = Iterables.getOnlyElement(processor.getChangedMappings().values()).getNewRevision();
assertDocEquals(expectedDoc, changedDoc);
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 TaxonomyPreCommitHookTest method indexStatedChild.
@Test
public void indexStatedChild() throws Exception {
// add the ROOT concept as existing concept in the stated tree
statedChangedConceptIds.add(ROOT_CONCEPTL);
final SnomedConceptDocument concept = concept().build();
stageNew(concept);
final SnomedRelationshipIndexEntry relationship = createStatedRelationship(concept.getId(), Concepts.IS_A, Concepts.ROOT_CONCEPT);
stageNew(relationship);
final ConceptChangeProcessor processor = process();
final SnomedConceptDocument expected = docWithDefaults(concept).statedParents(PrimitiveSets.newLongSortedSet(ROOT_CONCEPTL)).statedAncestors(PrimitiveSets.newLongSortedSet(IComponent.ROOT_IDL)).build();
final Revision actual = Iterables.getOnlyElement(processor.getNewMappings().values());
assertDocEquals(expected, actual);
assertEquals(0, processor.getChangedMappings().size());
assertEquals(0, processor.getDeletions().size());
}
use of com.b2international.index.revision.Revision in project snow-owl by b2ihealthcare.
the class TaxonomyPreCommitHookTest method newInferredIsaRelationshipDoesNotChangeStatedTaxonomy.
@Test
public void newInferredIsaRelationshipDoesNotChangeStatedTaxonomy() throws Exception {
// given a parent concept and child concept
final SnomedConceptDocument parent = concept().build();
final SnomedConceptDocument child = concept().build();
final SnomedRelationshipIndexEntry statedIsa = createStatedRelationship(child.getId(), Concepts.IS_A, parent.getId());
final long parentIdLong = Long.parseLong(parent.getId());
final long childIdLong = Long.parseLong(child.getId());
// index the child and parent concept documents as current state
initRevisions(docWithDefaults(parent).build(), docWithDefaults(child).statedParents(PrimitiveSets.newLongSortedSet(parentIdLong)).statedAncestors(PrimitiveSets.newLongSortedSet(IComponent.ROOT_IDL)).build(), statedIsa);
// add a new stated relationship between the two
inferredChangedConceptIds.add(parentIdLong);
inferredChangedConceptIds.add(childIdLong);
final SnomedRelationshipIndexEntry childToParentIsa = createInferredRelationship(child.getId(), Concepts.IS_A, parent.getId());
stageNew(childToParentIsa);
final ConceptChangeProcessor processor = process();
assertEquals(1, processor.getChangedMappings().size());
final SnomedConceptDocument expected = docWithDefaults(child).statedParents(PrimitiveSets.newLongSortedSet(parentIdLong)).statedAncestors(PrimitiveSets.newLongSortedSet(IComponent.ROOT_IDL)).parents(PrimitiveSets.newLongSortedSet(parentIdLong)).ancestors(PrimitiveSets.newLongSortedSet(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());
}
Aggregations