Search in sources :

Example 31 with Revision

use of org.apache.jackrabbit.oak.plugins.document.Revision in project jackrabbit-oak by apache.

the class UtilsTest method previousDoc.

@Test
public void previousDoc() throws Exception {
    Revision r = new Revision(System.currentTimeMillis(), 0, 0);
    assertTrue(Utils.isPreviousDocId(Utils.getPreviousIdFor("/", r, 0)));
    assertTrue(Utils.isPreviousDocId(Utils.getPreviousIdFor("/a/b/c/d/e/f/g/h/i/j/k/l/m", r, 3)));
    assertFalse(Utils.isPreviousDocId(Utils.getIdFromPath("/a/b")));
    assertFalse(Utils.isPreviousDocId("foo"));
    assertFalse(Utils.isPreviousDocId("0:"));
}
Also used : Revision(org.apache.jackrabbit.oak.plugins.document.Revision) Test(org.junit.Test)

Example 32 with Revision

use of org.apache.jackrabbit.oak.plugins.document.Revision in project jackrabbit-oak by apache.

the class UtilsTest method getMinTimestampForDiff.

@Test
public void getMinTimestampForDiff() {
    RevisionVector from = new RevisionVector(new Revision(17, 0, 1));
    RevisionVector to = new RevisionVector(new Revision(19, 0, 1));
    assertEquals(17, Utils.getMinTimestampForDiff(from, to, new RevisionVector()));
    assertEquals(17, Utils.getMinTimestampForDiff(to, from, new RevisionVector()));
    RevisionVector minRevs = new RevisionVector(new Revision(7, 0, 1), new Revision(4, 0, 2));
    assertEquals(17, Utils.getMinTimestampForDiff(from, to, minRevs));
    assertEquals(17, Utils.getMinTimestampForDiff(to, from, minRevs));
    to = to.update(new Revision(15, 0, 2));
    // must return min revision of clusterId 2
    assertEquals(4, Utils.getMinTimestampForDiff(from, to, minRevs));
    assertEquals(4, Utils.getMinTimestampForDiff(to, from, minRevs));
}
Also used : Revision(org.apache.jackrabbit.oak.plugins.document.Revision) RevisionVector(org.apache.jackrabbit.oak.plugins.document.RevisionVector) Test(org.junit.Test)

Aggregations

Revision (org.apache.jackrabbit.oak.plugins.document.Revision)32 Test (org.junit.Test)17 RevisionVector (org.apache.jackrabbit.oak.plugins.document.RevisionVector)13 BasicDBObject (com.mongodb.BasicDBObject)4 DBObject (com.mongodb.DBObject)4 NodeDocument (org.apache.jackrabbit.oak.plugins.document.NodeDocument)4 PathRev (org.apache.jackrabbit.oak.plugins.document.PathRev)4 UpdateOp (org.apache.jackrabbit.oak.plugins.document.UpdateOp)4 DBCollection (com.mongodb.DBCollection)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 StringValue (org.apache.jackrabbit.oak.plugins.document.util.StringValue)3 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)3 TreeMap (java.util.TreeMap)2 AbstractDocumentNodeState (org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState)2 AbstractMongoConnectionTest (org.apache.jackrabbit.oak.plugins.document.AbstractMongoConnectionTest)2 DocumentStoreException (org.apache.jackrabbit.oak.plugins.document.DocumentStoreException)2 Key (org.apache.jackrabbit.oak.plugins.document.UpdateOp.Key)2 Operation (org.apache.jackrabbit.oak.plugins.document.UpdateOp.Operation)2