Search in sources :

Example 51 with IBranchPath

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

the class SnomedMergeConflictTest method noMergeNewDescriptionToUnrelatedBranch.

@Test
public void noMergeNewDescriptionToUnrelatedBranch() {
    String conceptId = createNewConcept(branchPath);
    IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    /*
		 * XXX: Creating a new description on the concept itself would result in a DELETED_WHILE_CHANGED conflict;
		 * by referring to it as the type, the deletion will generate a CAUSES_MISSING_REFERENCE conflict instead.
		 */
    createNewDescription(a, Concepts.ROOT_CONCEPT, conceptId);
    IBranchPath b = BranchPathUtils.createPath(branchPath, "b");
    branching.createBranch(b).statusCode(201);
    deleteComponent(b, SnomedComponentType.CONCEPT, conceptId, false).statusCode(204);
    Collection<MergeConflict> conflicts = merge(a, b, "Merged new description to unrelated branch").body("status", equalTo(Merge.Status.CONFLICTS.name())).extract().as(Merge.class).getConflicts();
    assertEquals(1, conflicts.size());
    MergeConflict conflict = Iterables.getOnlyElement(conflicts);
    assertEquals(conceptId, conflict.getComponentId());
    assertEquals("concept", conflict.getComponentType());
    assertEquals(ConflictType.CAUSES_MISSING_REFERENCE, conflict.getType());
    assertEquals(0, conflict.getConflictingAttributes().size());
}
Also used : MergeConflict(com.b2international.snowowl.core.merge.MergeConflict) Merge(com.b2international.snowowl.core.merge.Merge) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 52 with IBranchPath

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

the class SnomedMergeConflictTest method rebaseResolvableAxiomMemberConflict.

@Test
public void rebaseResolvableAxiomMemberConflict() throws Exception {
    final String concept = createNewConcept(branchPath, Concepts.ROOT_CONCEPT);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    String axiomOnParent = createNewRefSetMember(branchPath, concept, Concepts.REFSET_OWL_AXIOM, Map.of(SnomedRf2Headers.FIELD_OWL_EXPRESSION, String.format("SubClassOf(:%s :%s)", concept, Concepts.TOPLEVEL_METADATA)));
    String axiomOnChild = createNewRefSetMember(a, concept, Concepts.REFSET_OWL_AXIOM, Map.of(SnomedRf2Headers.FIELD_OWL_EXPRESSION, String.format("SubClassOf(:%s :%s)", concept, Concepts.TOPLEVEL_METADATA)));
    merge(branchPath, a, "Rebase branch A").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(a, SnomedComponentType.MEMBER, axiomOnChild).statusCode(200);
    getComponent(a, SnomedComponentType.MEMBER, axiomOnParent).statusCode(200);
    SnomedConcept conceptOnChild = getComponent(a, SnomedComponentType.CONCEPT, concept).statusCode(200).extract().as(SnomedConcept.class);
    assertThat(conceptOnChild.getStatedParentIdsAsString()).containsOnly(Concepts.ROOT_CONCEPT, Concepts.TOPLEVEL_METADATA);
    assertThat(conceptOnChild.getParentIdsAsString()).containsOnly(IComponent.ROOT_ID);
    assertThat(conceptOnChild.getStatedAncestorIdsAsString()).containsOnly(IComponent.ROOT_ID, Concepts.ROOT_CONCEPT);
    assertThat(conceptOnChild.getAncestorIdsAsString()).isEmpty();
}
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 53 with IBranchPath

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

the class SnomedMergeConflictTest method rebaseResolvableModuleAndTermChange.

@Test
public void rebaseResolvableModuleAndTermChange() throws Exception {
    final String conceptA = createNewConcept(branchPath);
    final String descriptionB = createNewDescription(branchPath, conceptA, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    Map<?, ?> descriptionBUpdateRequest = ImmutableMap.builder().put("term", "Description B New Term").put("commitComment", "Change description B").build();
    updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionB, descriptionBUpdateRequest).statusCode(204);
    Map<?, ?> conceptUpdateRequest = ImmutableMap.builder().put("moduleId", Concepts.MODULE_SCT_MODEL_COMPONENT).put("commitComment", "Change description B").build();
    updateComponent(a, SnomedComponentType.CONCEPT, conceptA, conceptUpdateRequest).statusCode(204);
    merge(branchPath, a, "Rebase branch A").body("status", equalTo(Merge.Status.COMPLETED.name()));
    // checking duplicate revisions and properties after sync
    // on parent branch
    getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionB).statusCode(200).body("term", equalTo("Description B New Term"));
    getComponent(branchPath, SnomedComponentType.CONCEPT, conceptA).statusCode(200).body("moduleId", equalTo(Concepts.MODULE_SCT_CORE));
    // on task branch
    getComponent(a, SnomedComponentType.DESCRIPTION, descriptionB).statusCode(200).body("term", equalTo("Description B New Term"));
    getComponent(a, SnomedComponentType.CONCEPT, conceptA).statusCode(200).body("moduleId", equalTo(Concepts.MODULE_SCT_MODEL_COMPONENT));
}
Also used : IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 54 with IBranchPath

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

the class SnomedMergeConflictTest method addedInSourceAndTargetMergeConflict.

@Test
public void addedInSourceAndTargetMergeConflict() {
    IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    String descriptionId = createNewDescription(branchPath);
    Map<?, ?> requestBody = ImmutableMap.builder().put("id", descriptionId).put("conceptId", Concepts.ROOT_CONCEPT).put("moduleId", Concepts.MODULE_SCT_CORE).put("typeId", Concepts.SYNONYM).put("term", "Synonym of root concept").put("languageCode", "en").put("acceptability", SnomedApiTestConstants.UK_ACCEPTABLE_MAP).put("caseSignificanceId", Concepts.ENTIRE_TERM_CASE_INSENSITIVE).put("commitComment", "Created new synonym with duplicate SCTID").build();
    createComponent(a, SnomedComponentType.DESCRIPTION, requestBody).statusCode(201);
    Collection<MergeConflict> conflicts = merge(branchPath, a, "Rebased new description over new description with same SCTID").body("status", equalTo(Merge.Status.CONFLICTS.name())).extract().as(Merge.class).getConflicts();
    assertEquals(1, conflicts.size());
    ConflictingAttribute attribute = ConflictingAttribute.builder().property("id").build();
    MergeConflict conflict = Iterables.getOnlyElement(conflicts);
    assertEquals(descriptionId, conflict.getComponentId());
    assertEquals("description", conflict.getComponentType());
    assertEquals(ConflictType.CONFLICTING_CHANGE, conflict.getType());
    assertEquals(attribute.toDisplayName(), Iterables.getOnlyElement(conflict.getConflictingAttributes()).toDisplayName());
}
Also used : MergeConflict(com.b2international.snowowl.core.merge.MergeConflict) ConflictingAttribute(com.b2international.snowowl.core.merge.ConflictingAttribute) Merge(com.b2international.snowowl.core.merge.Merge) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 55 with IBranchPath

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

the class SnomedMergeConflictTest method deleteReferencedComponentOnTargetMergeConflict.

@Test
public void deleteReferencedComponentOnTargetMergeConflict() {
    String conceptId = createNewConcept(branchPath);
    IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    createNewRefSetMember(branchPath, conceptId);
    deleteComponent(a, SnomedComponentType.CONCEPT, conceptId, false).statusCode(204);
    Collection<MergeConflict> conflicts = merge(branchPath, a, "Rebased deleted referenced component over new reference set member").body("status", equalTo(Merge.Status.CONFLICTS.name())).extract().as(Merge.class).getConflicts();
    assertEquals(1, conflicts.size());
    MergeConflict conflict = Iterables.getOnlyElement(conflicts);
    assertEquals(conceptId, conflict.getComponentId());
    assertEquals("concept", conflict.getComponentType());
    assertEquals(ConflictType.CAUSES_MISSING_REFERENCE, conflict.getType());
}
Also used : MergeConflict(com.b2international.snowowl.core.merge.MergeConflict) Merge(com.b2international.snowowl.core.merge.Merge) 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