Search in sources :

Example 1 with IBranchPath

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

the class SnomedMergeApiTest method rebaseUnsetEffectiveTimeOnSource.

@Test
public void rebaseUnsetEffectiveTimeOnSource() {
    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);
    version = version.plus(1, ChronoUnit.DAYS);
    // Parent increases the effective time by one day
    updateRefSetMemberEffectiveTime(branchPath, memberId, version);
    final Map<?, ?> childRequest = ImmutableMap.builder().put("active", false).put("commitComment", "Inactivated reference set member").build();
    // Child unsets it and inactivates the member
    updateRefSetComponent(a, SnomedComponentType.MEMBER, memberId, childRequest, false).statusCode(204);
    merge(branchPath, a, "Rebased update over effective time change").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(200).body("released", equalTo(true)).body("effectiveTime", equalTo(EffectiveTimes.format(version, DateFormats.SHORT))).body("active", equalTo(true));
    getComponent(a, SnomedComponentType.MEMBER, memberId).statusCode(200).body("released", equalTo(true)).body("effectiveTime", nullValue()).body("active", 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 2 with IBranchPath

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

the class SnomedMergeApiTest method mergeNewConceptToUnrelatedBranch.

// @Test
// public void noMergeNewConceptDiverged() {
// final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
// branching.createBranch(a).statusCode(201);
// 
// final String concept1Id = createNewConcept(a);
// final String concept2Id = createNewConcept(branchPath);
// 
// getComponent(branchPath, SnomedComponentType.CONCEPT, concept1Id).statusCode(404);
// getComponent(a, SnomedComponentType.CONCEPT, concept1Id).statusCode(200);
// 
// getComponent(branchPath, SnomedComponentType.CONCEPT, concept2Id).statusCode(200);
// getComponent(a, SnomedComponentType.CONCEPT, concept2Id).statusCode(404);
// 
// merge(a, branchPath, "Merged new concept from diverged branch").body("status", equalTo(Merge.Status.COMPLETED.name()));
// 
// getComponent(branchPath, SnomedComponentType.CONCEPT, concept1Id).statusCode(404);
// getComponent(a, SnomedComponentType.CONCEPT, concept1Id).statusCode(200);
// 
// getComponent(branchPath, SnomedComponentType.CONCEPT, concept2Id).statusCode(200);
// getComponent(a, SnomedComponentType.CONCEPT, concept2Id).statusCode(404);
// }
// @Test
// public void noMergeNewDescriptionDiverged() {
// IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
// branching.createBranch(a).statusCode(201);
// 
// String description1Id = createNewDescription(a);
// String description2Id = createNewDescription(branchPath);
// 
// getComponent(branchPath, SnomedComponentType.DESCRIPTION, description1Id).statusCode(404);
// getComponent(a, SnomedComponentType.DESCRIPTION, description1Id).statusCode(200);
// 
// getComponent(branchPath, SnomedComponentType.DESCRIPTION, description2Id).statusCode(200);
// getComponent(a, SnomedComponentType.DESCRIPTION, description2Id).statusCode(404);
// 
// merge(a, branchPath, "Merged new description from diverged branch").body("status", equalTo(Merge.Status.FAILED.name()));
// 
// getComponent(branchPath, SnomedComponentType.DESCRIPTION, description1Id).statusCode(404);
// getComponent(a, SnomedComponentType.DESCRIPTION, description1Id).statusCode(200);
// 
// getComponent(branchPath, SnomedComponentType.DESCRIPTION, description2Id).statusCode(200);
// getComponent(a, SnomedComponentType.DESCRIPTION, description2Id).statusCode(404);
// }
// @Test
// public void noMergeNewRelationshipDiverged() {
// IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
// branching.createBranch(a).statusCode(201);
// 
// String relationship1Id = createNewRelationship(a);
// String relationship2Id = createNewRelationship(branchPath);
// 
// getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationship1Id).statusCode(404);
// getComponent(a, SnomedComponentType.RELATIONSHIP, relationship1Id).statusCode(200);
// 
// getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationship2Id).statusCode(200);
// getComponent(a, SnomedComponentType.RELATIONSHIP, relationship2Id).statusCode(404);
// 
// merge(a, branchPath, "Merged new relationship from diverged branch").body("status", equalTo(Merge.Status.COMPLETED.name()));
// 
// getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationship1Id).statusCode(404);
// getComponent(a, SnomedComponentType.RELATIONSHIP, relationship1Id).statusCode(200);
// 
// getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationship2Id).statusCode(200);
// getComponent(a, SnomedComponentType.RELATIONSHIP, relationship2Id).statusCode(404);
// }
@Test
public void mergeNewConceptToUnrelatedBranch() {
    final IBranchPath v1 = BranchPathUtils.createPath(branchPath, "v1");
    branching.createBranch(v1).statusCode(201);
    // Concept 1 is created on the two branches' common ancestor
    final String concept1Id = createNewConcept(branchPath);
    final IBranchPath v2 = BranchPathUtils.createPath(branchPath, "v2");
    branching.createBranch(v2).statusCode(201);
    final IBranchPath a = BranchPathUtils.createPath(v1, "extension-old");
    branching.createBranch(a).statusCode(201);
    final IBranchPath b = BranchPathUtils.createPath(v2, "extension-new");
    branching.createBranch(b).statusCode(201);
    // Concept 2 is initially only visible on branch "extension-old"
    final String concept2Id = createNewConcept(a);
    getComponent(a, SnomedComponentType.CONCEPT, concept2Id).statusCode(200);
    getComponent(branchPath, SnomedComponentType.CONCEPT, concept1Id).statusCode(200);
    getComponent(a, SnomedComponentType.CONCEPT, concept1Id).statusCode(404);
    getComponent(b, SnomedComponentType.CONCEPT, concept1Id).statusCode(200);
    merge(a, b, "Merged new concept from unrelated branch").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(b, SnomedComponentType.CONCEPT, concept1Id).statusCode(200);
    getComponent(b, SnomedComponentType.CONCEPT, concept2Id).statusCode(200);
}
Also used : IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 3 with IBranchPath

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

the class SnomedMergeApiTest method rebaseMultipleChangesFromParent.

@Test
public void rebaseMultipleChangesFromParent() throws Exception {
    final String concept = createNewConcept(branchPath);
    final IBranchPath task = BranchPathUtils.createPath(branchPath, "task1");
    branching.createBranch(task).statusCode(201);
    String newParentDescription1 = createNewDescription(branchPath, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
    String newChildDescription1 = createNewDescription(task, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
    merge(branchPath, task, "Synchronize task").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(task, SnomedComponentType.CONCEPT, concept).statusCode(200);
    getComponent(task, SnomedComponentType.DESCRIPTION, newParentDescription1).statusCode(200);
    getComponent(task, SnomedComponentType.DESCRIPTION, newChildDescription1).statusCode(200);
    String newParentDescription2 = createNewDescription(branchPath, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
    String newChildDescription2 = createNewDescription(task, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
    merge(branchPath, task, "Synchronize task").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(task, SnomedComponentType.CONCEPT, concept).statusCode(200);
    getComponent(task, SnomedComponentType.DESCRIPTION, newParentDescription2).statusCode(200);
    getComponent(task, SnomedComponentType.DESCRIPTION, newChildDescription2).statusCode(200);
    String newParentDescription3 = createNewDescription(branchPath, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
    String newChildDescription3 = createNewDescription(task, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
    merge(branchPath, task, "Synchronize task").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(task, SnomedComponentType.CONCEPT, concept).statusCode(200);
    getComponent(task, SnomedComponentType.DESCRIPTION, newParentDescription3).statusCode(200);
    getComponent(task, SnomedComponentType.DESCRIPTION, newChildDescription3).statusCode(200);
    SnomedConcept finalConcept = getComponent(task, SnomedComponentType.CONCEPT, concept, "descriptions(),preferredDescriptions()").statusCode(200).extract().as(SnomedConcept.class);
    // 2 default + 6 newly added
    assertThat(finalConcept.getDescriptions()).hasSize(8);
    assertThat(finalConcept.getPreferredDescriptions()).hasSize(8);
}
Also used : SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 4 with IBranchPath

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

the class SnomedMergeApiTest method rebaseAndMergeChangedDescription.

@Test
public void rebaseAndMergeChangedDescription() {
    final String description1Id = createNewDescription(branchPath);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    final String description2Id = createNewDescription(branchPath);
    final Map<?, ?> requestBody = ImmutableMap.builder().put("caseSignificanceId", Concepts.ENTIRE_TERM_CASE_INSENSITIVE).put("moduleId", Concepts.MODULE_ROOT).put("commitComment", "Changed case significance and module on child").build();
    updateComponent(a, SnomedComponentType.DESCRIPTION, description1Id, requestBody);
    merge(branchPath, a, "Rebased description change over new description creation").body("status", equalTo(Merge.Status.COMPLETED.name()));
    // Description 2 is now visible on both parent and child
    getComponent(branchPath, SnomedComponentType.DESCRIPTION, description2Id).statusCode(200);
    getComponent(a, SnomedComponentType.DESCRIPTION, description2Id).statusCode(200);
    // Description 1 retains the changes on child, keeps the original values on parent
    getComponent(branchPath, SnomedComponentType.DESCRIPTION, description1Id).statusCode(200).body("caseSignificanceId", equalTo(Concepts.ONLY_INITIAL_CHARACTER_CASE_INSENSITIVE)).body("moduleId", equalTo(Concepts.MODULE_SCT_CORE));
    getComponent(a, SnomedComponentType.DESCRIPTION, description1Id).statusCode(200).body("caseSignificanceId", equalTo(Concepts.ENTIRE_TERM_CASE_INSENSITIVE)).body("moduleId", equalTo(Concepts.MODULE_ROOT));
    merge(a, branchPath, "Merged description change to parent").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(branchPath, SnomedComponentType.DESCRIPTION, description2Id).statusCode(200);
    getComponent(a, SnomedComponentType.DESCRIPTION, description2Id).statusCode(200);
    // Description 1 changes are visible everywhere
    getComponent(branchPath, SnomedComponentType.DESCRIPTION, description1Id).statusCode(200).body("caseSignificanceId", equalTo(Concepts.ENTIRE_TERM_CASE_INSENSITIVE)).body("moduleId", equalTo(Concepts.MODULE_ROOT));
    getComponent(a, SnomedComponentType.DESCRIPTION, description1Id).statusCode(200).body("caseSignificanceId", equalTo(Concepts.ENTIRE_TERM_CASE_INSENSITIVE)).body("moduleId", equalTo(Concepts.MODULE_ROOT));
}
Also used : IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 5 with IBranchPath

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

the class SnomedMergeApiTest method rebaseNewDescriptionDiverged.

@Test
public void rebaseNewDescriptionDiverged() {
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    final String description1Id = createNewDescription(branchPath);
    final String description2Id = createNewDescription(a);
    getComponent(branchPath, SnomedComponentType.DESCRIPTION, description1Id).statusCode(200);
    getComponent(a, SnomedComponentType.DESCRIPTION, description1Id).statusCode(404);
    getComponent(branchPath, SnomedComponentType.DESCRIPTION, description2Id).statusCode(404);
    getComponent(a, SnomedComponentType.DESCRIPTION, description2Id).statusCode(200);
    merge(branchPath, a, "Rebased new description").body("status", equalTo(Merge.Status.COMPLETED.name()));
    // Description 1 from the parent becomes visible on the child after rebasing
    getComponent(branchPath, SnomedComponentType.DESCRIPTION, description1Id).statusCode(200);
    getComponent(a, SnomedComponentType.DESCRIPTION, description1Id).statusCode(200);
    // Description 2 should still not be present on the parent, however
    getComponent(branchPath, SnomedComponentType.DESCRIPTION, description2Id).statusCode(404);
    getComponent(a, SnomedComponentType.DESCRIPTION, description2Id).statusCode(200);
}
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