Search in sources :

Example 11 with IBranchPath

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

the class SnomedMergeApiTest method rebaseReactivatedConcept.

@Test
public void rebaseReactivatedConcept() {
    final String concept1Id = createInactiveConcept(branchPath);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    reactivateConcept(a, concept1Id);
    // Create concept 2 on "branchPath" so that "a" can be rebased
    final String concept2Id = createNewConcept(branchPath);
    merge(branchPath, a, "Rebased reactivation on child branch").body("status", equalTo(Merge.Status.COMPLETED.name()));
    // Concept 1 should be active on "a", but still inactive on "branchPath"
    getComponent(branchPath, SnomedComponentType.CONCEPT, concept1Id, "descriptions()", "relationships()").statusCode(200).body("active", equalTo(false)).body("descriptions.items[0].active", equalTo(true)).body("descriptions.items[1].active", equalTo(true)).body("relationships.items[0].active", equalTo(false));
    getComponent(a, SnomedComponentType.CONCEPT, concept1Id, "descriptions()", "relationships()").statusCode(200).body("active", equalTo(true)).body("descriptions.items[0].active", equalTo(true)).body("descriptions.items[1].active", equalTo(true)).body("relationships.items[0].active", equalTo(true));
    // Concept 2 should be visible everywhere
    getComponent(branchPath, SnomedComponentType.CONCEPT, concept2Id).statusCode(200);
    getComponent(a, 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 12 with IBranchPath

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

the class SnomedMergeApiTest method rebaseAndMergeNewDescriptionBothDeleted.

@Test
public void rebaseAndMergeNewDescriptionBothDeleted() {
    final String description1Id = createNewDescription(branchPath);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    final String description2Id = createNewDescription(branchPath);
    deleteComponent(branchPath, SnomedComponentType.DESCRIPTION, description1Id, false).statusCode(204);
    deleteComponent(a, SnomedComponentType.DESCRIPTION, description1Id, false).statusCode(204);
    /* 
		 * The rebase sees that the same thing has already happened on the parent branch, and does not 
		 * add an empty commit to the new instance of the child; it will be in UP_TO_DATE state and can 
		 * not be promoted.
		 */
    merge(branchPath, a, "Rebased description dual deletion over description creation").body("status", equalTo(Merge.Status.COMPLETED.name()));
    merge(a, branchPath, "Merged description dual deletion").body("status", equalTo(Merge.Status.COMPLETED.name()));
    // Description 1 is now deleted on both branches
    getComponent(branchPath, SnomedComponentType.DESCRIPTION, description1Id).statusCode(404);
    getComponent(a, SnomedComponentType.DESCRIPTION, description1Id).statusCode(404);
    // Description 2 should be present, however
    getComponent(branchPath, SnomedComponentType.DESCRIPTION, description2Id).statusCode(200);
    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)

Example 13 with IBranchPath

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

the class SnomedMergeApiTest method mergeReactivatedConcept.

@Test
public void mergeReactivatedConcept() {
    final String conceptId = createInactiveConcept(branchPath);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    reactivateConcept(a, conceptId);
    merge(a, branchPath, "Merged reactivation from child branch").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, "descriptions()", "relationships()").statusCode(200).body("active", equalTo(true)).body("descriptions.items[0].active", equalTo(true)).body("descriptions.items[1].active", equalTo(true)).body("relationships.items[0].active", equalTo(true));
}
Also used : IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 14 with IBranchPath

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

the class SnomedMergeApiTest method rebaseChangedConceptOnBranchDeletedOnParent.

@Test
@Ignore("Currently always fails due to merge policy")
public void rebaseChangedConceptOnBranchDeletedOnParent() {
    final String conceptId = createNewConcept(branchPath);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    final Map<?, ?> requestBody = ImmutableMap.builder().put("definitionStatusId", Concepts.FULLY_DEFINED).put("commitComment", "Changed definition status on child").build();
    updateComponent(a, SnomedComponentType.CONCEPT, conceptId, requestBody).statusCode(204);
    deleteComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, false).statusCode(204);
    merge(branchPath, a, "Rebased concept change over deletion").body("status", equalTo(Merge.Status.COMPLETED.name()));
}
Also used : IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 15 with IBranchPath

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

the class SnomedMergeApiTest method rebaseConceptDeletionOverNewOutAndInboundRelationships.

@Test
public void rebaseConceptDeletionOverNewOutAndInboundRelationships() throws Exception {
    // new concept on test branch
    final String deletedConcept = createNewConcept(branchPath);
    // new child branch of test parent branch
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    // create a new relationship to newly created destination concept on parent branch
    final String newInboundRelationshipToDeletedConcept = createNewRelationship(branchPath, Concepts.ROOT_CONCEPT, Concepts.FINDING_SITE, deletedConcept, Concepts.INFERRED_RELATIONSHIP);
    final String newOutboundRelationshipFromDeletedConcept = createNewRelationship(branchPath, deletedConcept, Concepts.FINDING_SITE, Concepts.ROOT_CONCEPT, Concepts.INFERRED_RELATIONSHIP);
    // delete destination concept on child branch
    deleteComponent(a, SnomedComponentType.CONCEPT, deletedConcept, false);
    // rebase child branch with deletion over new relationship, this should succeed, but should also implicitly delete the relationship
    merge(branchPath, a, "Rebased concept deletion over new outbound and inbound relationships").body("status", equalTo(Merge.Status.CONFLICTS.name()));
    // relationships should be deleted along with the already deleted destination concept
    getComponent(a, SnomedComponentType.RELATIONSHIP, newOutboundRelationshipFromDeletedConcept).statusCode(404);
    getComponent(a, SnomedComponentType.RELATIONSHIP, newInboundRelationshipToDeletedConcept).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