Search in sources :

Example 11 with MergeConflict

use of com.b2international.snowowl.core.merge.MergeConflict 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 12 with MergeConflict

use of com.b2international.snowowl.core.merge.MergeConflict 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 13 with MergeConflict

use of com.b2international.snowowl.core.merge.MergeConflict in project snow-owl by b2ihealthcare.

the class SnomedMergeConflictTest method changedInSourceAndTargetMergeConflict.

@Test
public void changedInSourceAndTargetMergeConflict() {
    String descriptionId = createNewDescription(branchPath);
    IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    // Parent branch changes to CaseSignificance.CASE_INSENSITIVE
    changeCaseSignificance(branchPath, descriptionId, Concepts.ENTIRE_TERM_CASE_INSENSITIVE);
    // Child branch changes to CaseSignificance.ENTIRE_TERM_CASE_SENSITIVE
    changeCaseSignificance(a, descriptionId);
    Collection<MergeConflict> conflicts = merge(branchPath, a, "Rebased case significance change over case significance change").body("status", equalTo(Merge.Status.CONFLICTS.name())).extract().as(Merge.class).getConflicts();
    assertEquals(1, conflicts.size());
    ConflictingAttribute attribute = ConflictingAttribute.builder().property("caseSignificanceId").oldValue(Concepts.ONLY_INITIAL_CHARACTER_CASE_INSENSITIVE).sourceValue(Concepts.ENTIRE_TERM_CASE_INSENSITIVE).targetValue(Concepts.ENTIRE_TERM_CASE_SENSITIVE).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)

Aggregations

Merge (com.b2international.snowowl.core.merge.Merge)13 MergeConflict (com.b2international.snowowl.core.merge.MergeConflict)13 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)10 AbstractSnomedApiTest (com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)10 Test (org.junit.Test)10 ConflictingAttribute (com.b2international.snowowl.core.merge.ConflictingAttribute)7 ApiError (com.b2international.commons.exceptions.ApiError)3 BadRequestException (com.b2international.commons.exceptions.BadRequestException)2 ConflictException (com.b2international.commons.exceptions.ConflictException)2 ResourceURI (com.b2international.snowowl.core.ResourceURI)2 RepositoryContext (com.b2international.snowowl.core.domain.RepositoryContext)2 Request (com.b2international.snowowl.core.events.Request)2 User (com.b2international.snowowl.core.identity.User)2 RepositoryRequests (com.b2international.snowowl.core.repository.RepositoryRequests)2 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)2 Collection (java.util.Collection)2 List (java.util.List)2 ApiException (com.b2international.commons.exceptions.ApiException)1 NotFoundException (com.b2international.commons.exceptions.NotFoundException)1 com.b2international.index.revision (com.b2international.index.revision)1