Search in sources :

Example 6 with IBranchPath

use of com.b2international.snowowl.core.api.IBranchPath in project snow-owl by b2ihealthcare.

the class SnomedMergeApiTest method mergeNewDescriptionToUnrelatedBranch.

@Test
public void mergeNewDescriptionToUnrelatedBranch() {
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    final IBranchPath b = BranchPathUtils.createPath(branchPath, "b");
    branching.createBranch(b).statusCode(201);
    final String descriptionId = createNewDescription(a);
    getComponent(a, SnomedComponentType.DESCRIPTION, descriptionId).statusCode(200);
    getComponent(b, SnomedComponentType.DESCRIPTION, descriptionId).statusCode(404);
    merge(a, b, "Merged new description from unrelated branch").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(a, SnomedComponentType.DESCRIPTION, descriptionId).statusCode(200);
    getComponent(b, SnomedComponentType.DESCRIPTION, descriptionId).statusCode(200);
}
Also used : IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 7 with IBranchPath

use of com.b2international.snowowl.core.api.IBranchPath in project snow-owl by b2ihealthcare.

the class SnomedMergeApiTest method rebaseNewConceptStale.

@Test
public void rebaseNewConceptStale() {
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    final IBranchPath b = BranchPathUtils.createPath(a, "b");
    branching.createBranch(b).statusCode(201);
    final String concept1Id = createNewConcept(b);
    final String concept2Id = createNewConcept(a);
    final String concept3Id = createNewConcept(branchPath);
    merge(branchPath, a, "Rebased new concept on child over new concept on parent").body("status", equalTo(Merge.Status.COMPLETED.name()));
    // "a" now knows about concept 3
    getComponent(branchPath, SnomedComponentType.CONCEPT, concept3Id).statusCode(200);
    getComponent(a, SnomedComponentType.CONCEPT, concept3Id).statusCode(200);
    // "b" is now in STALE state, and doesn't know about either concept 2 or 3
    getComponent(b, SnomedComponentType.CONCEPT, concept3Id).statusCode(404);
    getComponent(b, SnomedComponentType.CONCEPT, concept2Id).statusCode(404);
    merge(a, b, "Rebased new concept on nested child over new concepts on child").body("status", equalTo(Merge.Status.COMPLETED.name()));
    // Now "b" should see all three concepts
    getComponent(b, SnomedComponentType.CONCEPT, concept3Id).statusCode(200);
    getComponent(b, SnomedComponentType.CONCEPT, concept2Id).statusCode(200);
    getComponent(b, SnomedComponentType.CONCEPT, concept1Id).statusCode(200);
}
Also used : IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 8 with IBranchPath

use of com.b2international.snowowl.core.api.IBranchPath in project snow-owl by b2ihealthcare.

the class SnomedMergeApiTest method rebaseAndMergeChangedOnParentDeletedOnBranch.

@Test
public void rebaseAndMergeChangedOnParentDeletedOnBranch() {
    final String conceptId = createNewConcept(branchPath);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    rebaseConceptDeletionOverChange(branchPath, a, conceptId);
    merge(a, branchPath, "Merged concept deletion").body("status", equalTo(Merge.Status.COMPLETED.name()));
    // Concept should now be deleted everywhere
    getComponent(branchPath, SnomedComponentType.CONCEPT, conceptId).statusCode(404);
    getComponent(a, SnomedComponentType.CONCEPT, conceptId).statusCode(404);
}
Also used : IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 9 with IBranchPath

use of com.b2international.snowowl.core.api.IBranchPath in project snow-owl by b2ihealthcare.

the class SnomedMergeApiTest method mergeThenRebaseOtherTask.

@Test
public void mergeThenRebaseOtherTask() throws Exception {
    final String conceptA = createNewConcept(branchPath);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    final IBranchPath b = BranchPathUtils.createPath(branchPath, "b");
    branching.createBranch(a).statusCode(201);
    branching.createBranch(b).statusCode(201);
    Map<?, ?> inactivationRequest = ImmutableMap.builder().put("active", false).put("inactivationProperties", new InactivationProperties(Concepts.DUPLICATE, List.of(new AssociationTarget(Concepts.REFSET_SAME_AS_ASSOCIATION, Concepts.FULLY_SPECIFIED_NAME)))).put("commitComment", "Inactivated concept").build();
    updateComponent(a, SnomedComponentType.CONCEPT, conceptA, inactivationRequest).statusCode(204);
    final String conceptB = createNewConcept(b);
    merge(a, branchPath, "Merge branch A").body("status", equalTo(Merge.Status.COMPLETED.name()));
    SnomedConcept conceptAOnParent = getComponent(branchPath, SnomedComponentType.CONCEPT, conceptA, "members(),relationships()").statusCode(200).extract().as(SnomedConcept.class);
    assertThat(conceptAOnParent.getRelationships()).hasSize(1);
    assertThat(conceptAOnParent.getMembers()).hasSize(2);
    merge(branchPath, b, "Rebase branch B").body("status", equalTo(Merge.Status.COMPLETED.name()));
    SnomedConcept conceptAOnBranchB = getComponent(b, SnomedComponentType.CONCEPT, conceptA, "members(),relationships()").statusCode(200).extract().as(SnomedConcept.class);
    assertThat(conceptAOnBranchB.getRelationships()).hasSize(1);
    assertThat(conceptAOnBranchB.getMembers()).hasSize(2);
    getComponent(b, SnomedComponentType.CONCEPT, conceptB, "relationships()").statusCode(200).extract().as(SnomedConcept.class);
}
Also used : InactivationProperties(com.b2international.snowowl.snomed.core.domain.InactivationProperties) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) AssociationTarget(com.b2international.snowowl.snomed.core.domain.AssociationTarget) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 10 with IBranchPath

use of com.b2international.snowowl.core.api.IBranchPath in project snow-owl by b2ihealthcare.

the class SnomedMergeApiTest method rebaseStaleBranchWithDeleteOnChangedContent.

@Test
public void rebaseStaleBranchWithDeleteOnChangedContent() throws Exception {
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    final String relationshipId = createNewRelationship(a);
    final String descriptionId = createNewDescription(a);
    final IBranchPath b = BranchPathUtils.createPath(a, "b");
    branching.createBranch(b).statusCode(201);
    // Make changes on branch "a"
    changeCaseSignificance(a, descriptionId);
    changeRelationshipGroup(a, relationshipId);
    // Delete description on branch "b"
    deleteComponent(b, SnomedComponentType.DESCRIPTION, descriptionId, false).statusCode(204);
    getComponent(b, SnomedComponentType.DESCRIPTION, descriptionId).statusCode(404);
    // Make change on "branchPath" so "a" can be rebased
    createNewRelationship(branchPath);
    merge(branchPath, a, "Rebased changed components over new relationship").body("status", equalTo(Merge.Status.COMPLETED.name()));
    // "b" should be STALE at this point, try to rebase it, it should pass and the description should be deleted
    merge(a, b, "Rebased description deletion over changed components").body("status", equalTo(Merge.Status.COMPLETED.name()));
    // Verify that the relationship has the modified values, and the description stayed deleted
    getComponent(b, SnomedComponentType.DESCRIPTION, descriptionId).statusCode(404);
    getComponent(b, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200).body("relationshipGroup", equalTo(99));
}
Also used : IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Aggregations

IBranchPath (com.b2international.snowowl.core.api.IBranchPath)79 Test (org.junit.Test)73 AbstractSnomedApiTest (com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)70 Merge (com.b2international.snowowl.core.merge.Merge)10 MergeConflict (com.b2international.snowowl.core.merge.MergeConflict)10 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)8 ConflictingAttribute (com.b2international.snowowl.core.merge.ConflictingAttribute)6 LocalDate (java.time.LocalDate)5 Pair (com.b2international.commons.Pair)4 File (java.io.File)4 Ignore (org.junit.Ignore)2 BackwardListIterator (com.b2international.commons.collections.BackwardListIterator)1 Json (com.b2international.commons.json.Json)1 BaseRevisionBranching (com.b2international.index.revision.BaseRevisionBranching)1 RevisionBranch (com.b2international.index.revision.RevisionBranch)1 ComponentIdentifier (com.b2international.snowowl.core.ComponentIdentifier)1 Repository (com.b2international.snowowl.core.Repository)1 RepositoryManager (com.b2international.snowowl.core.RepositoryManager)1 ResourceURI (com.b2international.snowowl.core.ResourceURI)1 BranchCompareResult (com.b2international.snowowl.core.branch.compare.BranchCompareResult)1