Search in sources :

Example 66 with IBranchPath

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

the class SnomedMergeApiTest method rebaseStaleBranchWithChangesOnDeletedContent.

@Test
public void rebaseStaleBranchWithChangesOnDeletedContent() 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);
    deleteComponent(a, SnomedComponentType.RELATIONSHIP, relationshipId, false).statusCode(204);
    deleteComponent(a, SnomedComponentType.DESCRIPTION, descriptionId, false).statusCode(204);
    changeCaseSignificance(b, descriptionId);
    changeRelationshipGroup(b, relationshipId);
    // Make change on "branchPath" so "a" can be rebased
    createNewRelationship(branchPath);
    merge(branchPath, a, "Rebased component deletion 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 components should be deleted
    merge(a, b, "Rebased component updates over deletion").body("status", equalTo(Merge.Status.COMPLETED.name()));
    // Verify that the two deleted components are really deleted
    getComponent(b, SnomedComponentType.DESCRIPTION, descriptionId).statusCode(404);
    getComponent(b, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(404);
}
Also used : IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 67 with IBranchPath

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

the class SnomedMergeApiTest method rebaseStaleBranchWithChangesOnNewContent.

@Test
public void rebaseStaleBranchWithChangesOnNewContent() 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);
    changeCaseSignificance(b, descriptionId);
    changeRelationshipGroup(b, relationshipId);
    // Make change on "branchPath" so "a" can be rebased
    createNewRelationship(branchPath);
    merge(branchPath, a, "Rebased new components over new relationship").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(a, SnomedComponentType.DESCRIPTION, descriptionId).statusCode(200).body("caseSignificanceId", equalTo(Concepts.ONLY_INITIAL_CHARACTER_CASE_INSENSITIVE));
    getComponent(a, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200).body("relationshipGroup", equalTo(0));
    // "b" should be STALE at this point, try to rebase it, it should pass and the components should still exist with changed content
    merge(a, b, "Rebased changed components over new components").body("status", equalTo(Merge.Status.COMPLETED.name()));
    // Verify that the two components have the modified values
    getComponent(b, SnomedComponentType.DESCRIPTION, descriptionId).statusCode(200).body("caseSignificanceId", equalTo(Concepts.ENTIRE_TERM_CASE_SENSITIVE));
    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)

Example 68 with IBranchPath

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

the class SnomedMergeApiTest method mergeNewRelationshipToUnrelatedBranch.

@Test
public void mergeNewRelationshipToUnrelatedBranch() {
    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 relationshipId = createNewRelationship(a);
    getComponent(a, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200);
    getComponent(b, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(404);
    merge(a, b, "Merged new relationship from unrelated branch").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(a, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200);
    getComponent(b, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200);
}
Also used : IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 69 with IBranchPath

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

the class SnomedMergeApiTest method rebaseUnsetEffectiveTimeOnTarget.

@Test
public void rebaseUnsetEffectiveTimeOnTarget() {
    final String memberId = createNewRefSetMember(branchPath);
    LocalDate version = getNextAvailableEffectiveDate(SnomedContentRule.SNOMEDCT_ID);
    updateRefSetMemberEffectiveTime(branchPath, memberId, version);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    final Map<?, ?> parentRequest = ImmutableMap.builder().put("active", false).put("commitComment", "Inactivated reference set member").build();
    // Parent unsets the effective time and inactivates the member
    updateRefSetComponent(branchPath, SnomedComponentType.MEMBER, memberId, parentRequest, false).statusCode(204);
    version = version.plus(1, ChronoUnit.DAYS);
    // Child increases the effective time by one day
    updateRefSetMemberEffectiveTime(a, memberId, version);
    merge(branchPath, a, "Rebased effective time change over update").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(200).body("released", equalTo(true)).body("effectiveTime", nullValue()).body("active", equalTo(false));
    getComponent(a, SnomedComponentType.MEMBER, memberId).statusCode(200).body("released", equalTo(true)).body("effectiveTime", // Parent wins because of the effective time unset
    nullValue()).body("active", // Child didn't update the status, so inactivation on the parent is in effect
    equalTo(false));
}
Also used : LocalDate(java.time.LocalDate) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 70 with IBranchPath

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

the class SnomedMergeApiTest method rebaseChangedConceptOnParentDeletedOnBranch.

@Test
public void rebaseChangedConceptOnParentDeletedOnBranch() {
    final String conceptId = createNewConcept(branchPath);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    rebaseConceptDeletionOverChange(branchPath, a, conceptId);
    // Concept should still be present on parent, and deleted on child
    getComponent(branchPath, SnomedComponentType.CONCEPT, conceptId).statusCode(200).body("definitionStatusId", equalTo(Concepts.FULLY_DEFINED));
    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)

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