Search in sources :

Example 61 with IBranchPath

use of com.b2international.snowowl.core.api.IBranchPath 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)

Example 62 with IBranchPath

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

the class SnomedMergeConflictTest method rebaseResolvableIsaRelationshipConflictSameDestination.

@Test
public void rebaseResolvableIsaRelationshipConflictSameDestination() 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.TOPLEVEL_METADATA);
    String relationshipOnChild = createNewRelationship(a, concept, Concepts.IS_A, 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);
    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 63 with IBranchPath

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

the class SnomedConceptApiTest method deleteConceptOnNestedBranch.

@Test
public void deleteConceptOnNestedBranch() {
    String parentId = ROOT_CONCEPT;
    for (int i = 0; i < 10; i++) {
        parentId = createNewConcept(branchPath, parentId);
    }
    IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    IBranchPath b = BranchPathUtils.createPath(a, "b");
    branching.createBranchRecursively(b);
    // New component on nested branch resets the container's version to 1 again
    createNewConcept(b, parentId);
    // Deleting the last concept in the chain
    deleteComponent(branchPath, SnomedComponentType.CONCEPT, parentId, false).statusCode(204);
    getComponent(branchPath, SnomedComponentType.CONCEPT, parentId).statusCode(404);
    // Should still exist on the nested branch, and be possible to remove
    deleteComponent(b, SnomedComponentType.CONCEPT, parentId, false).statusCode(204);
    getComponent(b, SnomedComponentType.CONCEPT, parentId).statusCode(404);
}
Also used : IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test)

Example 64 with IBranchPath

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

the class SnomedExtensionCreationTest method createExtensionVersion02.

@Test
public void createExtensionVersion02() {
    IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    String conceptId = createNewConcept(a);
    getComponent(branchPath, SnomedComponentType.CONCEPT, conceptId).statusCode(404);
    String codeSystemId = "SNOMEDCT-CV2";
    createCodeSystem(a, codeSystemId).statusCode(201);
    getComponent(a, SnomedComponentType.CONCEPT, conceptId).statusCode(200).body("released", equalTo(false));
    String versionId = "v1";
    LocalDate effectiveTime = LocalDate.now();
    createVersion(codeSystemId, versionId, effectiveTime).statusCode(201);
    Version version = getVersion(codeSystemId, versionId);
    assertThat(version.getEffectiveTime()).isEqualTo(effectiveTime);
    getComponent(branchPath, SnomedComponentType.CONCEPT, conceptId).statusCode(404);
    getComponent(a, SnomedComponentType.CONCEPT, conceptId).statusCode(200).body("released", equalTo(true)).body("effectiveTime", equalTo(effectiveTime.format(DateTimeFormatter.BASIC_ISO_DATE)));
}
Also used : CodeSystemVersionRestRequests.createVersion(com.b2international.snowowl.test.commons.codesystem.CodeSystemVersionRestRequests.createVersion) CodeSystemVersionRestRequests.getVersion(com.b2international.snowowl.test.commons.codesystem.CodeSystemVersionRestRequests.getVersion) Version(com.b2international.snowowl.core.version.Version) LocalDate(java.time.LocalDate) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 65 with IBranchPath

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

the class SnomedMergeApiTest method rebaseNewRelationshipDiverged.

@Test
public void rebaseNewRelationshipDiverged() {
    final IBranchPath a = BranchPathUtils.createPath(branchPath, "a");
    branching.createBranch(a).statusCode(201);
    final String relationship1Id = createNewRelationship(branchPath);
    final String relationship2Id = createNewRelationship(a);
    getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationship1Id).statusCode(200);
    getComponent(a, SnomedComponentType.RELATIONSHIP, relationship1Id).statusCode(404);
    getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationship2Id).statusCode(404);
    getComponent(a, SnomedComponentType.RELATIONSHIP, relationship2Id).statusCode(200);
    merge(branchPath, a, "Rebased new relationship").body("status", equalTo(Merge.Status.COMPLETED.name()));
    // Relationship 1 from the parent becomes visible on the child after rebasing
    getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationship1Id).statusCode(200);
    getComponent(a, SnomedComponentType.RELATIONSHIP, relationship1Id).statusCode(200);
    // Relationship 2 should still not be present on the parent, however
    getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationship2Id).statusCode(404);
    getComponent(a, SnomedComponentType.RELATIONSHIP, relationship2Id).statusCode(200);
}
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