Search in sources :

Example 16 with IBranchPath

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

the class SnomedMergeApiTest method rebaseNewConceptDiverged.

@Test
public void rebaseNewConceptDiverged() {
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    final String concept1Id = createNewConcept(branchPath);
    final String concept2Id = createNewConcept(a);
    getComponent(branchPath, SnomedComponentType.CONCEPT, concept1Id).statusCode(200);
    getComponent(a, SnomedComponentType.CONCEPT, concept1Id).statusCode(404);
    getComponent(branchPath, SnomedComponentType.CONCEPT, concept2Id).statusCode(404);
    getComponent(a, SnomedComponentType.CONCEPT, concept2Id).statusCode(200);
    merge(branchPath, a, "Rebased new concept").body("status", equalTo(Merge.Status.COMPLETED.name()));
    // Concept 1 from the parent becomes visible on the child after rebasing
    getComponent(branchPath, SnomedComponentType.CONCEPT, concept1Id).statusCode(200);
    getComponent(a, SnomedComponentType.CONCEPT, concept1Id).statusCode(200);
    // Concept 2 should still not be present on the parent, however
    getComponent(branchPath, SnomedComponentType.CONCEPT, concept2Id).statusCode(404);
    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 17 with IBranchPath

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

the class SnomedMergeConflictTest method rebaseResolvableDescriptionConflictOnTheSameDescription.

@Test
public void rebaseResolvableDescriptionConflictOnTheSameDescription() 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(a, SnomedComponentType.DESCRIPTION, descriptionB, descriptionBUpdateRequest).statusCode(204);
    updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionB, descriptionBUpdateRequest).statusCode(204);
    merge(branchPath, a, "Rebase branch A").body("status", equalTo(Merge.Status.COMPLETED.name()));
    // checking duplicate revisions after sync
    getComponent(a, SnomedComponentType.DESCRIPTION, descriptionB).statusCode(200);
    getComponent(a, SnomedComponentType.CONCEPT, conceptA).statusCode(200);
}
Also used : IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 18 with IBranchPath

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

the class SnomedMergeConflictTest method changedInSourceDetachedInTargetMergeConflict.

@Test
public void changedInSourceDetachedInTargetMergeConflict() {
    String memberId = createNewRefSetMember(branchPath);
    IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    LocalDate nextEffectiveTime = getNextAvailableEffectiveDate(SnomedContentRule.SNOMEDCT_ID);
    String nextEffectiveTimeAsString = EffectiveTimes.format(nextEffectiveTime, DateFormats.SHORT);
    Map<?, ?> effectiveTimeUpdateRequest = ImmutableMap.builder().put("effectiveTime", nextEffectiveTimeAsString).put("commitComment", "Updated effective time on reference set member").build();
    updateRefSetComponent(branchPath, SnomedComponentType.MEMBER, memberId, effectiveTimeUpdateRequest, true).statusCode(204);
    deleteComponent(a, SnomedComponentType.MEMBER, memberId, false).statusCode(204);
    Collection<MergeConflict> conflicts = merge(branchPath, a, "Rebased reference set member deletion over effective time update").body("status", equalTo(Merge.Status.CONFLICTS.name())).extract().as(Merge.class).getConflicts();
    assertEquals(1, conflicts.size());
    MergeConflict conflict = Iterables.getOnlyElement(conflicts);
    assertEquals(memberId, conflict.getComponentId());
    assertEquals("member", conflict.getComponentType());
    assertEquals(ConflictType.DELETED_WHILE_CHANGED, conflict.getType());
    Map<String, ConflictingAttribute> expectedAttributes = newHashMap();
    expectedAttributes.put("effectiveTime", ConflictingAttribute.builder().property("effectiveTime").sourceValue(nextEffectiveTimeAsString).build());
    expectedAttributes.put("released", ConflictingAttribute.builder().property("released").oldValue("false").sourceValue("true").build());
    for (ConflictingAttribute attribute : conflict.getConflictingAttributes()) {
        ConflictingAttribute expected = expectedAttributes.remove(attribute.getProperty());
        assertNotNull(expected);
        assertEquals(expected.toDisplayName(), attribute.toDisplayName());
    }
    assertThat(expectedAttributes).isEmpty();
}
Also used : MergeConflict(com.b2international.snowowl.core.merge.MergeConflict) ConflictingAttribute(com.b2international.snowowl.core.merge.ConflictingAttribute) Merge(com.b2international.snowowl.core.merge.Merge) LocalDate(java.time.LocalDate) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 19 with IBranchPath

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

the class SnomedMergeConflictTest method rebaseResolvableIsaRelationshipConflictTwoDifferentDestinations.

@Test
public void rebaseResolvableIsaRelationshipConflictTwoDifferentDestinations() throws Exception {
    final String concept = createNewConcept(branchPath, Concepts.ROOT_CONCEPT);
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    String relationshipOnParent = createNewRelationship(branchPath, concept, Concepts.IS_A, Concepts.CONCEPT_MODEL_DATA_ATTRIBUTE);
    String relationshipOnChild = createNewRelationship(a, concept, Concepts.IS_A, Concepts.CONCEPT_MODEL_OBJECT_ATTRIBUTE);
    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);
    SnomedConcept conceptOnChild = getComponent(a, SnomedComponentType.CONCEPT, concept).statusCode(200).extract().as(SnomedConcept.class);
    assertThat(conceptOnChild.getStatedParentIdsAsString()).containsOnly(Concepts.ROOT_CONCEPT, Concepts.CONCEPT_MODEL_DATA_ATTRIBUTE, Concepts.CONCEPT_MODEL_OBJECT_ATTRIBUTE);
    assertThat(conceptOnChild.getParentIdsAsString()).containsOnly(IComponent.ROOT_ID);
    assertThat(conceptOnChild.getStatedAncestorIdsAsString()).containsOnly(IComponent.ROOT_ID, Concepts.ROOT_CONCEPT, Concepts.LINKAGE, Concepts.ATTRIBUTE, Concepts.CONCEPT_MODEL_ATTRIBUTE, Concepts.TOPLEVEL_METADATA);
    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 20 with IBranchPath

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

the class SnomedMergeConflictTest method addedInTargetDetachedInSourceMergeConflict.

@Test
public void addedInTargetDetachedInSourceMergeConflict() {
    String conceptId = createNewConcept(branchPath);
    IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    deleteComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, false).statusCode(204);
    String relationshipId = createNewRelationship(a, Concepts.ROOT_CONCEPT, Concepts.PART_OF, conceptId);
    Collection<MergeConflict> conflicts = merge(branchPath, a, "Rebased new relationship over deleted concept").body("status", equalTo(Merge.Status.CONFLICTS.name())).extract().as(Merge.class).getConflicts();
    assertEquals(1, conflicts.size());
    ConflictingAttribute attribute = ConflictingAttribute.builder().property("destinationId").sourceValue(conceptId).build();
    MergeConflict conflict = Iterables.getOnlyElement(conflicts);
    assertEquals(relationshipId, conflict.getComponentId());
    assertEquals("relationship", 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)

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