Java Code Examples for com.yahoo.squidb.data.SquidCursor#moveToPosition()

The following examples show how to use com.yahoo.squidb.data.SquidCursor#moveToPosition() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FtsQueryTest.java    From squidb with Apache License 2.0 6 votes vote down vote up
private void testQueryResults(Criterion criterion, TestVirtualModel... expectedResults) {
    Query query = Query.select(TestVirtualModel.PROPERTIES).where(criterion);
    SquidCursor<TestVirtualModel> cursor = database.query(TestVirtualModel.class, query);
    try {
        int expectedCount = expectedResults == null ? 0 : expectedResults.length;
        assertEquals(expectedCount, cursor.getCount());
        if (expectedCount == 0) {
            return;
        }

        for (int i = 0; i < expectedCount; i++) {
            cursor.moveToPosition(i);
            assertEquals(expectedResults[i], new TestVirtualModel(cursor));
        }
    } finally {
        cursor.close();
    }
}
 
Example 2
Source File: SqlFunctionsTest.java    From squidb with Apache License 2.0 5 votes vote down vote up
private void assertExpectedValues(Query query, Property<?> property, Object... expectedValues) {
    final int expectedCount = expectedValues == null ? 0 : expectedValues.length;
    SquidCursor<?> cursor = database.query(null, query);
    try {
        assertEquals(expectedCount, cursor.getCount());
        for (int i = 0; i < expectedCount; i++) {
            cursor.moveToPosition(i);
            assertEquals(expectedValues[i], cursor.get(property));
        }
    } finally {
        cursor.close();
    }
}
 
Example 3
Source File: QueryTest.java    From squidb with Apache License 2.0 5 votes vote down vote up
public void testOrderByArray() {
    Long[] order = new Long[]{5L, 1L, 4L};
    SquidCursor<Employee> cursor = database.query(Employee.class,
            Query.select(Employee.ID).limit(order.length).orderBy(Employee.ID.byArray(order)));
    try {
        assertEquals(order.length, cursor.getCount());
        for (int i = 0; i < order.length; i++) {
            cursor.moveToPosition(i);
            assertEquals(order[i], cursor.get(Employee.ID));
        }
    } finally {
        cursor.close();
    }
}