Search in sources :

Example 11 with RevisionData

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

the class RevisionPurgeTest method purgeChildBranchDoesNotPurgeParentRevisions.

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

Example 12 with RevisionData

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

the class RevisionPurgeTest method purgeMainWithTwoRevisionsAndABranch.

@Test
@Ignore
public void purgeMainWithTwoRevisionsAndABranch() throws Exception {
    indexRevision(MAIN, new RevisionData(STORAGE_KEY1, "field1", "field2"));
    createBranch(MAIN, "a");
    indexRevision(MAIN, new RevisionData(STORAGE_KEY1, "field1Changed", "field2"));
    index().purge(MAIN, Purge.ALL);
    // both revisions should still remain, because the "MAIN/a" requires the first one
    final Iterable<RevisionData> revisions = searchRaw(Query.select(RevisionData.class).where(Expressions.exactMatch(Revision.Fields.ID, STORAGE_KEY1)).limit(Integer.MAX_VALUE).build());
    assertEquals(2, Iterables.size(revisions));
    final RevisionData actualOnMAIN = getRevision(MAIN, RevisionData.class, STORAGE_KEY1);
    assertDocEquals(new RevisionData(STORAGE_KEY1, "field1Changed", "field2"), actualOnMAIN);
    final RevisionData actualOnChild = getRevision("MAIN/a", RevisionData.class, STORAGE_KEY1);
    assertDocEquals(new RevisionData(STORAGE_KEY1, "field1", "field2"), actualOnChild);
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 13 with RevisionData

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

the class SingleDocumentRevisionIndexTest method updateRevision.

@Test
public void updateRevision() throws Exception {
    indexRevision();
    final RevisionData data = new RevisionData(STORAGE_KEY1, "field1Changed", "field2Changed");
    indexRevision(MAIN, data);
    assertEquals(data, getRevision(MAIN, RevisionData.class, STORAGE_KEY1));
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 14 with RevisionData

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

the class SingleDocumentRevisionIndexTest method updateRevisionShadowsRevisionOnParent.

@Test
public void updateRevisionShadowsRevisionOnParent() throws Exception {
    indexRevision();
    final String childBranch = createBranch(MAIN, "a");
    // put updated revision to child branch
    final RevisionData data = new RevisionData(STORAGE_KEY1, "field1Changed", "field2Changed");
    indexRevision(childBranch, data);
    // lookup by storageKey on child should return new revision
    assertEquals(data, getRevision(childBranch, RevisionData.class, STORAGE_KEY1));
    final RevisionData expectedRevisionOnMain = new RevisionData(STORAGE_KEY1, "field1", "field2");
    final RevisionData actualRevisionOnMain = getRevision(MAIN, RevisionData.class, STORAGE_KEY1);
    assertEquals(expectedRevisionOnMain, actualRevisionOnMain);
}
Also used : RevisionData(com.b2international.index.revision.RevisionFixtures.RevisionData) Test(org.junit.Test)

Example 15 with RevisionData

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

the class SingleDocumentRevisionIndexTest method divergedBranchContentShouldBeAccessibleBasedOnSegments.

@Test
public void divergedBranchContentShouldBeAccessibleBasedOnSegments() throws Exception {
    updateRevisionShadowsRevisionOnParent();
    // put new revision to MAIN
    final RevisionData data = new RevisionData(STORAGE_KEY1, "field1ChangedOnMain", "field2ChangedOnMain");
    indexRevision(MAIN, data);
    // lookup by storageKey on child should return new revision
    assertEquals(data, getRevision(MAIN, RevisionData.class, STORAGE_KEY1));
    // child branch still has his own updated revision
    final RevisionData expectedRevisionOnChild = new RevisionData(STORAGE_KEY1, "field1Changed", "field2Changed");
    final RevisionData actualRevisionOnChild = getRevision("MAIN/a", RevisionData.class, STORAGE_KEY1);
    assertEquals(expectedRevisionOnChild, actualRevisionOnChild);
}
Also used : 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