Search in sources :

Example 1 with CompiledCursor

use of com.google.apphosting.datastore.DatastoreV3Pb.CompiledCursor in project appengine-java-standard by GoogleCloudPlatform.

the class CursorTest method testReverseCursorPostfix.

@SuppressWarnings("deprecation")
@Test
public void testReverseCursorPostfix() {
    IndexPostfix postfixPosition = new IndexPostfix().setKey(new Reference()).setBefore(true);
    Cursor pfCursor = toCursor(new CompiledCursor().setPostfixPosition(postfixPosition));
    // reverse() is a no-op.
    Cursor pfReverse = pfCursor.reverse();
    assertThat(pfReverse).isEqualTo(pfCursor);
    assertThat(pfCursor).isEqualTo(pfReverse.reverse());
}
Also used : IndexPostfix(com.google.storage.onestore.v3.OnestoreEntity.IndexPostfix) Reference(com.google.storage.onestore.v3.OnestoreEntity.Reference) CompiledCursor(com.google.apphosting.datastore.DatastoreV3Pb.CompiledCursor) CompiledCursor(com.google.apphosting.datastore.DatastoreV3Pb.CompiledCursor) Test(org.junit.Test)

Example 2 with CompiledCursor

use of com.google.apphosting.datastore.DatastoreV3Pb.CompiledCursor in project appengine-java-standard by GoogleCloudPlatform.

the class CursorTest method testReverseCursorAbsolutePosition.

@SuppressWarnings("deprecation")
@Test
public void testReverseCursorAbsolutePosition() {
    IndexPosition absolutePosition = new IndexPosition().setKey("Goodnight moon").setBefore(true);
    Cursor absCursor = toCursor(new CompiledCursor().setAbsolutePosition(absolutePosition));
    // reverse() is a no-op.
    Cursor absReverse = absCursor.reverse();
    assertThat(absCursor).isEqualTo(absReverse);
    assertThat(absCursor).isEqualTo(absReverse.reverse());
}
Also used : IndexPosition(com.google.storage.onestore.v3.OnestoreEntity.IndexPosition) CompiledCursor(com.google.apphosting.datastore.DatastoreV3Pb.CompiledCursor) CompiledCursor(com.google.apphosting.datastore.DatastoreV3Pb.CompiledCursor) Test(org.junit.Test)

Example 3 with CompiledCursor

use of com.google.apphosting.datastore.DatastoreV3Pb.CompiledCursor in project appengine-java-standard by GoogleCloudPlatform.

the class CursorTest method toPb.

private static CompiledCursor toPb(Cursor cursor) {
    CompiledCursor pb = new CompiledCursor();
    assertThat(pb.parseFrom(cursor.toByteString())).isTrue();
    return pb;
}
Also used : CompiledCursor(com.google.apphosting.datastore.DatastoreV3Pb.CompiledCursor)

Example 4 with CompiledCursor

use of com.google.apphosting.datastore.DatastoreV3Pb.CompiledCursor in project appengine-java-standard by GoogleCloudPlatform.

the class CursorTest method testCursorLifeCycle.

@Test
public void testCursorLifeCycle() {
    Cursor reconstituted = Cursor.fromWebSafeString(cursor.toWebSafeString());
    assertThat(reconstituted).isEqualTo(cursor);
    Query query = new Query();
    query.setOffset(3);
    query.setCompiledCursor(toPb(reconstituted));
    assertThat(query.getCompiledCursor()).isEqualTo(compiledCursor);
    assertThat(query.getOffset()).isEqualTo(3);
}
Also used : Query(com.google.apphosting.datastore.DatastoreV3Pb.Query) CompiledCursor(com.google.apphosting.datastore.DatastoreV3Pb.CompiledCursor) Test(org.junit.Test)

Example 5 with CompiledCursor

use of com.google.apphosting.datastore.DatastoreV3Pb.CompiledCursor in project appengine-java-standard by GoogleCloudPlatform.

the class CursorTest method setUp.

@Before
public void setUp() throws Exception {
    compiledCursor = new CompiledCursor();
    CompiledCursor.Position position = compiledCursor.getMutablePosition();
    position.setStartKey("Hello World");
    position.setStartInclusive(true);
    cursor = toCursor(compiledCursor);
}
Also used : CompiledCursor(com.google.apphosting.datastore.DatastoreV3Pb.CompiledCursor) Before(org.junit.Before)

Aggregations

CompiledCursor (com.google.apphosting.datastore.DatastoreV3Pb.CompiledCursor)6 Test (org.junit.Test)4 Query (com.google.apphosting.datastore.DatastoreV3Pb.Query)2 IndexPosition (com.google.storage.onestore.v3.OnestoreEntity.IndexPosition)1 IndexPostfix (com.google.storage.onestore.v3.OnestoreEntity.IndexPostfix)1 Reference (com.google.storage.onestore.v3.OnestoreEntity.Reference)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Before (org.junit.Before)1