Search in sources :

Example 21 with RevisionData

use of com.b2international.index.revision.RevisionFixtures.RevisionData in project snow-owl by b2ihealthcare.

the class RevisionBranchMergeTest method movedPropertyChange_AppliedOnBothSides.

@Test
public void movedPropertyChange_AppliedOnBothSides() throws Exception {
    // index the document fixture on MAIN
    indexRevision(MAIN, NEW_DATA);
    final String oldParent = createBranch(MAIN, "oldParent");
    final String oldBranch = createBranch(oldParent, "move");
    // index change in doc in another field
    RevisionData updatedOnOnBranch = NEW_DATA.toBuilder().terms(List.of("term")).build();
    indexChange(oldBranch, NEW_DATA, updatedOnOnBranch);
    // index a change on MAIN after creating the old branches and old change
    indexChange(MAIN, NEW_DATA, NEW_DATA.toBuilder().derivedField("change").build());
    // create new parent and target move branch
    final String newParent = createBranch(MAIN, "newParent");
    final String newBranch = createBranch(newParent, "move");
    // initial sync produces empty commit but an actual change in the doc
    branching().prepareMerge(oldBranch, newBranch).squash(false).merge();
    RevisionData afterFirstSync = getRevision(newBranch, RevisionData.class, STORAGE_KEY1);
    assertEquals("change", afterFirstSync.getDerivedField());
    assertEquals(List.of("term"), afterFirstSync.getTerms());
    // represent the same change as the one made on newParent
    indexChange(oldBranch, updatedOnOnBranch, updatedOnOnBranch.toBuilder().derivedField("change").build());
    // second sync
    branching().prepareMerge(oldBranch, newBranch).squash(false).merge();
    // single revision exists with the desired values
    RevisionData actual = getRevision(newBranch, RevisionData.class, STORAGE_KEY1);
    assertEquals("change", actual.getDerivedField());
    assertEquals(List.of("term"), afterFirstSync.getTerms());
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 22 with RevisionData

use of com.b2international.index.revision.RevisionFixtures.RevisionData in project snow-owl by b2ihealthcare.

the class RevisionBranchMergeTest method mergeChildBranchThenDeleteShouldNotAffectSearches.

@Test
public void mergeChildBranchThenDeleteShouldNotAffectSearches() throws Exception {
    final String branchA = createBranch(MAIN, "a");
    indexRevision(branchA, NEW_DATA);
    branching().prepareMerge(branchA, MAIN).merge();
    branching().delete(branchA);
    RevisionData rev = getRevision(MAIN, RevisionData.class, NEW_DATA.getId());
    assertNotNull(rev);
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 23 with RevisionData

use of com.b2international.index.revision.RevisionFixtures.RevisionData in project snow-owl by b2ihealthcare.

the class RevisionCompareTest method compareBranchWithNewComponent_BaseWithNewComponent_Reverse.

@Test
public void compareBranchWithNewComponent_BaseWithNewComponent_Reverse() throws Exception {
    indexRevision(MAIN, new RevisionData(STORAGE_KEY1, "field1", "field2"));
    final String branch = createBranch(MAIN, "a");
    indexRevision(branch, new RevisionData(STORAGE_KEY2, "field1", "field2"));
    final RevisionCompare compare = index().compare(branch, MAIN);
    assertThat(compare.getDetails()).isEmpty();
}
Also used : ComponentRevisionData(com.b2international.index.revision.RevisionFixtures.ComponentRevisionData) ContainerRevisionData(com.b2international.index.revision.RevisionFixtures.ContainerRevisionData) RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 24 with RevisionData

use of com.b2international.index.revision.RevisionFixtures.RevisionData in project snow-owl by b2ihealthcare.

the class RevisionCompareTest method compareBranchWithDeletedComponent_Reverse.

@Test
public void compareBranchWithDeletedComponent_Reverse() throws Exception {
    indexRevision(MAIN, new RevisionData(STORAGE_KEY1, "field1", "field2"));
    final String branch = createBranch(MAIN, "a");
    deleteRevision(branch, RevisionData.class, STORAGE_KEY1);
    final RevisionCompare compare = index().compare(branch, MAIN);
    assertThat(compare.getDetails()).isEmpty();
}
Also used : ComponentRevisionData(com.b2international.index.revision.RevisionFixtures.ComponentRevisionData) ContainerRevisionData(com.b2international.index.revision.RevisionFixtures.ContainerRevisionData) RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 25 with RevisionData

use of com.b2international.index.revision.RevisionFixtures.RevisionData in project snow-owl by b2ihealthcare.

the class RevisionCompareTest method compareChangeOnMainSinceBranchBasePoint_Reverse.

@Test
public void compareChangeOnMainSinceBranchBasePoint_Reverse() throws Exception {
    final RevisionData rev1 = new RevisionData(STORAGE_KEY1, "field1", "field2");
    indexRevision(MAIN, rev1);
    final String branch = createBranch(MAIN, "a");
    indexRevision(branch, new RevisionData(STORAGE_KEY2, "field1", "field2"));
    final RevisionData rev2 = new RevisionData(STORAGE_KEY1, "field1Changed", "field2");
    indexChange(MAIN, rev1, rev2);
    final RevisionCompare compare = index().compare(branch, MAIN);
    assertThat(compare.getDetails()).containsOnly(RevisionCompareDetail.componentChange(Operation.CHANGE, rev2.getContainerId(), rev2.getObjectId()), RevisionCompareDetail.propertyChange(Operation.CHANGE, rev2.getObjectId(), "field1", "field1", "field1Changed"));
}
Also used : ComponentRevisionData(com.b2international.index.revision.RevisionFixtures.ComponentRevisionData) ContainerRevisionData(com.b2international.index.revision.RevisionFixtures.ContainerRevisionData) RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Aggregations

RevisionData (com.b2international.index.revision.RevisionFixtures.RevisionData)52 Test (org.junit.Test)52 ComponentRevisionData (com.b2international.index.revision.RevisionFixtures.ComponentRevisionData)13 ContainerRevisionData (com.b2international.index.revision.RevisionFixtures.ContainerRevisionData)13 Ignore (org.junit.Ignore)6 Expression (com.b2international.index.query.Expression)2 ImmutableList (com.google.common.collect.ImmutableList)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 TimeUnit (java.util.concurrent.TimeUnit)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertTrue (org.junit.Assert.assertTrue)2