Search in sources :

Example 56 with IBranchPath

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

the class SnomedMergeConflictTest method deleteReferencedComponentOnSourceMergeConflict.

@Test
public void deleteReferencedComponentOnSourceMergeConflict() {
    String conceptId = createNewConcept(branchPath);
    IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    deleteComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, false).statusCode(204);
    String memberId = createNewRefSetMember(a, conceptId);
    Collection<MergeConflict> conflicts = merge(branchPath, a, "Rebased new reference set member over deleted referenced component").body("status", equalTo(Merge.Status.CONFLICTS.name())).extract().as(Merge.class).getConflicts();
    assertEquals(1, conflicts.size());
    ConflictingAttribute attribute = ConflictingAttribute.builder().property("container").sourceValue(conceptId).build();
    MergeConflict conflict = Iterables.getOnlyElement(conflicts);
    assertEquals(memberId, conflict.getComponentId());
    assertEquals("member", conflict.getComponentType());
    assertEquals(ConflictType.HAS_MISSING_REFERENCE, 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 57 with IBranchPath

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

the class SnomedMergeConflictTest method changedInSourceAndTargetMultipleConflict.

@Test
public void changedInSourceAndTargetMultipleConflict() {
    String descriptionId = createNewDescription(branchPath);
    IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    Map<?, ?> changesOnParent = ImmutableMap.builder().put("caseSignificanceId", Concepts.ENTIRE_TERM_CASE_INSENSITIVE).put("moduleId", Concepts.MODULE_ROOT).put("commitComment", "Changed case significance and module on parent").build();
    Map<?, ?> changesOnBranch = ImmutableMap.builder().put("caseSignificanceId", Concepts.ENTIRE_TERM_CASE_SENSITIVE).put("moduleId", Concepts.MODULE_SCT_MODEL_COMPONENT).put("commitComment", "Changed case significance and module on branch").build();
    updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, changesOnParent).statusCode(204);
    updateComponent(a, SnomedComponentType.DESCRIPTION, descriptionId, changesOnBranch).statusCode(204);
    Collection<MergeConflict> conflicts = merge(branchPath, a, "Rebased description changes over conflicting description changes").body("status", equalTo(Merge.Status.CONFLICTS.name())).extract().as(Merge.class).getConflicts();
    assertEquals(1, conflicts.size());
    MergeConflict conflict = Iterables.getOnlyElement(conflicts);
    assertEquals(descriptionId, conflict.getComponentId());
    assertEquals("description", conflict.getComponentType());
    assertEquals(ConflictType.CONFLICTING_CHANGE, conflict.getType());
    Map<String, ConflictingAttribute> expectedAttributes = newHashMap();
    expectedAttributes.put("caseSignificanceId", ConflictingAttribute.builder().property("caseSignificanceId").oldValue(Concepts.ONLY_INITIAL_CHARACTER_CASE_INSENSITIVE).sourceValue(Concepts.ENTIRE_TERM_CASE_INSENSITIVE).targetValue(Concepts.ENTIRE_TERM_CASE_SENSITIVE).build());
    expectedAttributes.put("moduleId", ConflictingAttribute.builder().property("moduleId").oldValue(Concepts.MODULE_SCT_CORE).sourceValue(Concepts.MODULE_ROOT).targetValue(Concepts.MODULE_SCT_MODEL_COMPONENT).build());
    for (ConflictingAttribute attribute : conflict.getConflictingAttributes()) {
        ConflictingAttribute expected = expectedAttributes.remove(attribute.getProperty());
        assertNotNull(expected);
        assertEquals(expected.toDisplayName(), attribute.toDisplayName());
    }
    assertEquals(ImmutableList.of(), ImmutableList.copyOf(expectedAttributes.values()));
}
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 58 with IBranchPath

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

the class SnomedMergeConflictTest method rebaseResolvableNonIsaRelationshipConflict.

@Test
public void rebaseResolvableNonIsaRelationshipConflict() throws Exception {
    final String concept = createNewConcept(branchPath, Concepts.ROOT_CONCEPT);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    String relationshipOnChild = createNewRelationship(a, concept, Concepts.FINDING_SITE, Concepts.TOPLEVEL_METADATA);
    String relationshipOnParent = createNewRelationship(branchPath, concept, Concepts.FINDING_SITE, Concepts.TOPLEVEL_METADATA);
    merge(branchPath, a, "Rebase branch A").body("status", equalTo(Merge.Status.COMPLETED.name()));
    getComponent(a, SnomedComponentType.RELATIONSHIP, relationshipOnChild).statusCode(200);
    getComponent(a, SnomedComponentType.RELATIONSHIP, relationshipOnParent).statusCode(200);
    getComponent(a, SnomedComponentType.CONCEPT, concept).statusCode(200).extract().as(SnomedConcept.class);
}
Also used : IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 59 with IBranchPath

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

the class SnomedMergeConflictTest method rebaseResolvableDescriptionConflictOnTwoDifferentDescriptions.

@Test
public void rebaseResolvableDescriptionConflictOnTwoDifferentDescriptions() throws Exception {
    final String concept = createNewConcept(branchPath);
    final String syn = createNewDescription(branchPath, concept, Concepts.SYNONYM, SnomedApiTestConstants.UK_PREFERRED_MAP);
    final String fsn = createNewDescription(branchPath, concept, Concepts.FULLY_SPECIFIED_NAME, SnomedApiTestConstants.UK_PREFERRED_MAP);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    Map<?, ?> synUpdateRequest = ImmutableMap.builder().put("term", "Updated").put("commitComment", "Change " + syn).build();
    updateComponent(a, SnomedComponentType.DESCRIPTION, syn, synUpdateRequest).statusCode(204);
    Map<?, ?> fsnUpdateRequest = ImmutableMap.builder().put("term", "Updated").put("commitComment", "Change " + fsn).build();
    updateComponent(branchPath, SnomedComponentType.DESCRIPTION, fsn, fsnUpdateRequest).statusCode(204);
    merge(branchPath, a, "Rebase branch A").body("status", equalTo(Merge.Status.COMPLETED.name()));
    // checking duplicate revisions after sync
    getComponent(a, SnomedComponentType.DESCRIPTION, syn).statusCode(200);
    getComponent(a, SnomedComponentType.DESCRIPTION, fsn).statusCode(200);
    getComponent(a, SnomedComponentType.CONCEPT, concept).statusCode(200);
}
Also used : IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 60 with IBranchPath

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

the class SnomedMergeConflictTest method rebaseConceptModuleConflictShouldReportConflict.

@Test
public void rebaseConceptModuleConflictShouldReportConflict() throws Exception {
    final String concept = createNewConcept(branchPath);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    final Map<?, ?> moduleUpdateOnParent = Map.of("moduleId", Concepts.MODULE_ROOT, "commitComment", "Update module");
    updateComponent(branchPath, SnomedComponentType.CONCEPT, concept, moduleUpdateOnParent);
    final Map<?, ?> moduleUpdateOnChild = Map.of("moduleId", Concepts.MODULE_SCT_MODEL_COMPONENT, "commitComment", "Update module");
    updateComponent(a, SnomedComponentType.CONCEPT, concept, moduleUpdateOnChild);
    merge(branchPath, a, "Rebase branch A").body("status", equalTo(Merge.Status.CONFLICTS.name()));
}
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