Search in sources :

Example 1 with BranchCompareResult

use of com.b2international.snowowl.core.branch.compare.BranchCompareResult in project snow-owl by b2ihealthcare.

the class BranchCompareRequestTest method compareBranchWithDeletedComponents.

@Test
public void compareBranchWithDeletedComponents() throws Exception {
    final Set<ComponentIdentifier> componentIdsToDelete = prepareBranchWithNewChanges(branchPath);
    final String taskBranchPath = createBranch(branchPath, "taskBranch");
    final ComponentIdentifier concept = componentIdsToDelete.stream().filter(ci -> ci.getComponentType() == SnomedConcept.TYPE).findFirst().get();
    SnomedRequests.prepareDeleteConcept(concept.getComponentId()).build(taskBranchPath, RestExtensions.USER, "Delete concept on task branch").execute(bus).getSync();
    // compare task branch and its parent
    final BranchCompareResult compare = compare(branchPath, taskBranchPath);
    assertThat(compare.getNewComponents()).isEmpty();
    assertThat(compare.getChangedComponents()).isEmpty();
    assertThat(compare.getDeletedComponents()).containsAll(componentIdsToDelete);
    assertTrue("branchPath^ expression search should return the original concept state", SnomedRequests.prepareSearchConcept().one().filterById(concept.getComponentId()).build(taskBranchPath + RevisionIndex.BASE_REF_CHAR).execute(bus).getSync().first().isPresent());
    assertTrue("branchPath expression search should return nothing", SnomedRequests.prepareSearchConcept().one().filterById(concept.getComponentId()).build(taskBranchPath).execute(bus).getSync().first().isEmpty());
}
Also used : BranchCompareResult(com.b2international.snowowl.core.branch.compare.BranchCompareResult) ComponentIdentifier(com.b2international.snowowl.core.ComponentIdentifier) Test(org.junit.Test)

Example 2 with BranchCompareResult

use of com.b2international.snowowl.core.branch.compare.BranchCompareResult in project snow-owl by b2ihealthcare.

the class BranchCompareRequestTest method compareEmptyBranchWithBase.

@Test
public void compareEmptyBranchWithBase() throws Exception {
    final BranchCompareResult compareResult = compare(Branch.MAIN_PATH, branchPath);
    assertThat(compareResult.getCompareBranch()).isEqualTo(branchPath);
    assertThat(compareResult.getBaseBranch()).isEqualTo(Branch.MAIN_PATH);
    assertThat(compareResult.getNewComponents()).isEmpty();
    assertThat(compareResult.getChangedComponents()).isEmpty();
    assertThat(compareResult.getDeletedComponents()).isEmpty();
}
Also used : BranchCompareResult(com.b2international.snowowl.core.branch.compare.BranchCompareResult) Test(org.junit.Test)

Example 3 with BranchCompareResult

use of com.b2international.snowowl.core.branch.compare.BranchCompareResult in project snow-owl by b2ihealthcare.

the class BranchCompareRequestTest method compareBranchWithChangedComponents.

@Test
public void compareBranchWithChangedComponents() throws Exception {
    final IBranchPath branch = BranchPathUtils.createPath(branchPath);
    final String newConceptId = createNewConcept(branch);
    final SnomedConcept concept = getComponent(branch, SnomedComponentType.CONCEPT, newConceptId).extract().as(SnomedConcept.class);
    final String taskBranchPath = createBranch(branchPath, "taskBranch");
    SnomedRequests.prepareUpdateConcept(concept.getId()).setModuleId(Concepts.MODULE_SCT_MODEL_COMPONENT).build(taskBranchPath, RestExtensions.USER, "Change module ID").execute(bus).getSync();
    // compare task branch and its parent
    final BranchCompareResult compare = compare(branchPath, taskBranchPath);
    assertThat(compare.getNewComponents()).isEmpty();
    assertThat(compare.getChangedComponents()).contains(ComponentIdentifier.of(SnomedConcept.TYPE, newConceptId));
    assertThat(compare.getDeletedComponents()).isEmpty();
}
Also used : BranchCompareResult(com.b2international.snowowl.core.branch.compare.BranchCompareResult) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) IBranchPath(com.b2international.snowowl.core.api.IBranchPath) Test(org.junit.Test)

Example 4 with BranchCompareResult

use of com.b2international.snowowl.core.branch.compare.BranchCompareResult in project snow-owl by b2ihealthcare.

the class SnomedCompareRestRequestTest method testCompareOfSameBranch.

@Test
public void testCompareOfSameBranch() throws IOException {
    final BranchCompareResult compareResult = getCompareResult(branchPath.getPath(), parentBranch.getPath());
    assertThat(compareResult.getBaseBranch().equals(branchPath.toString()));
    assertThat(compareResult.getCompareBranch().equals(branchPath.toString()));
    assertThat(compareResult.getChangedComponents().isEmpty());
    assertThat(compareResult.getDeletedComponents().isEmpty());
    assertThat(compareResult.getNewComponents().isEmpty());
}
Also used : BranchCompareResult(com.b2international.snowowl.core.branch.compare.BranchCompareResult) Test(org.junit.Test)

Example 5 with BranchCompareResult

use of com.b2international.snowowl.core.branch.compare.BranchCompareResult in project snow-owl by b2ihealthcare.

the class SnomedCompareRestRequestTest method testCompareWithChangedComponents.

@Test
public void testCompareWithChangedComponents() throws IOException {
    final String newConceptId = createNewConcept(parentBranch);
    final SnomedConcept concept = getComponent(parentBranch, SnomedComponentType.CONCEPT, newConceptId).extract().as(SnomedConcept.class);
    final String parentBranchPath = parentBranch.toString();
    final String childBranchPath = createBranch(parentBranchPath, "SNOMEDCT-CHANGED");
    SnomedRequests.prepareUpdateConcept(concept.getId()).setModuleId(Concepts.MODULE_SCT_MODEL_COMPONENT).build(childBranchPath, RestExtensions.USER, "Change module ID").execute(bus).getSync();
    final BranchCompareResult compareResult = getCompareResult(parentBranchPath, childBranchPath);
    // compare child branch with it's parent
    assertThat(compareResult.getNewComponents()).isEmpty();
    assertThat(compareResult.getChangedComponents()).contains(ComponentIdentifier.of(SnomedConcept.TYPE, newConceptId));
    assertThat(compareResult.getDeletedComponents()).isEmpty();
}
Also used : BranchCompareResult(com.b2international.snowowl.core.branch.compare.BranchCompareResult) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) Test(org.junit.Test)

Aggregations

BranchCompareResult (com.b2international.snowowl.core.branch.compare.BranchCompareResult)12 Test (org.junit.Test)12 ComponentIdentifier (com.b2international.snowowl.core.ComponentIdentifier)6 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)2 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)1