Search in sources :

Example 41 with RevisionData

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

the class RevisionCompareTest method compareBranchWithChangedComponent_Reverse.

@Test
public void compareBranchWithChangedComponent_Reverse() throws Exception {
    RevisionData rev1 = new RevisionData(STORAGE_KEY1, "field1", "field2");
    indexRevision(MAIN, rev1);
    final String branch = createBranch(MAIN, "a");
    RevisionData rev2 = new RevisionData(STORAGE_KEY1, "field1Changed", "field2");
    indexChange(branch, rev1, rev2);
    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 42 with RevisionData

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

the class RevisionCompareTest method compareBranchWithChangedThenDeleted.

@Test
public void compareBranchWithChangedThenDeleted() throws Exception {
    final RevisionData rev = new RevisionData(STORAGE_KEY1, "field1", "field2");
    indexRevision(MAIN, rev);
    final String branch = createBranch(MAIN, "a");
    RevisionData changed = new RevisionData(STORAGE_KEY1, "field1", "field2Changed");
    indexChange(branch, rev, changed);
    deleteRevision(branch, RevisionData.class, STORAGE_KEY1);
    final RevisionCompare compare = index().compare(MAIN, branch);
    assertThat(compare.getDetails()).hasSize(1);
    assertThat(compare.getTotalAdded()).isEqualTo(0);
    assertThat(compare.getTotalChanged()).isEqualTo(0);
    assertThat(compare.getTotalRemoved()).isEqualTo(1);
}
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 43 with RevisionData

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

the class RevisionCompareTest method compareBranchWithNewThenDeleted.

@Test
public void compareBranchWithNewThenDeleted() throws Exception {
    final String branch = createBranch(MAIN, "a");
    indexRevision(branch, new RevisionData(STORAGE_KEY1, "field1", "field2"));
    deleteRevision(branch, RevisionData.class, STORAGE_KEY1);
    final RevisionCompare compare = index().compare(MAIN, branch);
    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 44 with RevisionData

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

the class RevisionPurgeTest method purgeLatestPurgesOnlyMostRecentSegment.

@Test
@Ignore
public void purgeLatestPurgesOnlyMostRecentSegment() throws Exception {
    indexRevision(MAIN, new RevisionData(STORAGE_KEY1, "field1", "field2"));
    indexRevision(MAIN, new RevisionData(STORAGE_KEY1, "field1Changed", "field2"));
    createBranch(MAIN, "a");
    indexRevision(MAIN, new RevisionData(STORAGE_KEY1, "field1Changed", "field2Changed"));
    index().purge(MAIN, Purge.LATEST);
    final Iterable<RevisionData> revisions = searchRaw(Query.select(RevisionData.class).where(Expressions.exactMatch(Revision.Fields.ID, STORAGE_KEY1)).limit(Integer.MAX_VALUE).build());
    assertEquals(3, Iterables.size(revisions));
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 45 with RevisionData

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

the class RevisionPurgeTest method purgeHistoryPurgesHistoricalSegments.

@Test
@Ignore
public void purgeHistoryPurgesHistoricalSegments() throws Exception {
    indexRevision(MAIN, new RevisionData(STORAGE_KEY1, "field1", "field2"));
    indexRevision(MAIN, new RevisionData(STORAGE_KEY1, "field1Changed", "field2"));
    createBranch(MAIN, "a");
    indexRevision(MAIN, new RevisionData(STORAGE_KEY1, "field1Changed", "field2Changed"));
    indexRevision(MAIN, new RevisionData(STORAGE_KEY1, "field1Latest", "field2Latest"));
    index().purge(MAIN, Purge.HISTORY);
    final Iterable<RevisionData> revisions = searchRaw(Query.select(RevisionData.class).where(Expressions.exactMatch(Revision.Fields.ID, STORAGE_KEY1)).limit(Integer.MAX_VALUE).build());
    assertEquals(3, Iterables.size(revisions));
    int revisionsInSegment0 = 0;
    int revisionsInSegment2 = 0;
    // for (Data rev : revisions) {
    // if (rev.getSegmentId() == 0) {
    // revisionsInSegment0++;
    // } else if (rev.getSegmentId() == 2) {
    // revisionsInSegment2++;
    // } else {
    // throw new AssertionFailedError("Unexpected segment ID: " + rev.getSegmentId());
    // }
    // }
    assertEquals(1, revisionsInSegment0);
    assertEquals(2, revisionsInSegment2);
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Ignore(org.junit.Ignore) 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