Search in sources :

Example 6 with Select

use of com.activeandroid.query.Select in project ActiveAndroid by pardom.

the class CountTest method testCountEmptyResult.

/**
     * Should return the same count as there are entries in the result set if the where-clause
     * matches zero entries.
     */
public void testCountEmptyResult() {
    cleanTable();
    populateTable();
    From from = new Select().from(MockModel.class).where("intField = ?", 3);
    final List<MockModel> list = from.execute();
    final int count = from.count();
    assertEquals(0, count);
    assertEquals(list.size(), count);
}
Also used : MockModel(com.activeandroid.test.MockModel) Select(com.activeandroid.query.Select) From(com.activeandroid.query.From)

Example 7 with Select

use of com.activeandroid.query.Select in project ActiveAndroid by pardom.

the class ExistsTest method testCountGroupBy.

/**
     * Should not change the result if group by is used.
     */
public void testCountGroupBy() {
    cleanTable();
    populateTable();
    From from = new Select().from(MockModel.class).groupBy("intField").having("intField = 1");
    final List<MockModel> list = from.execute();
    final boolean exists = from.exists();
    assertTrue(exists);
    assertTrue(list.size() > 0);
}
Also used : MockModel(com.activeandroid.test.MockModel) Select(com.activeandroid.query.Select) From(com.activeandroid.query.From)

Example 8 with Select

use of com.activeandroid.query.Select in project ActiveAndroid by pardom.

the class ExistsTest method testCountGroupByEmpty.

/**
     * Should not exist if group by eliminates all rows.
     */
public void testCountGroupByEmpty() {
    cleanTable();
    populateTable();
    From from = new Select().from(MockModel.class).groupBy("intField").having("intField = 3");
    final List<MockModel> list = from.execute();
    final boolean exists = from.exists();
    assertFalse(exists);
    assertFalse(list.size() > 0);
}
Also used : MockModel(com.activeandroid.test.MockModel) Select(com.activeandroid.query.Select) From(com.activeandroid.query.From)

Example 9 with Select

use of com.activeandroid.query.Select in project ActiveAndroid by pardom.

the class ExistsTest method testExistsWhereClause.

/**
     * Should return {@code true} since the where-clause matches rows and thus the result set isn't
     * empty.
     */
public void testExistsWhereClause() {
    cleanTable();
    populateTable();
    From from = new Select().from(MockModel.class).where("intField = ?", 1);
    final List<MockModel> list = from.execute();
    final boolean exists = from.exists();
    assertTrue(exists);
    assertTrue(list.size() > 0);
}
Also used : MockModel(com.activeandroid.test.MockModel) Select(com.activeandroid.query.Select) From(com.activeandroid.query.From)

Example 10 with Select

use of com.activeandroid.query.Select in project ActiveAndroid by pardom.

the class ExistsTest method testExistsTable.

/**
     * Should return {@code true} since the result set/table isn't empty.
     */
public void testExistsTable() {
    cleanTable();
    populateTable();
    From from = new Select().from(MockModel.class);
    final List<MockModel> list = from.execute();
    final boolean exists = from.exists();
    assertTrue(exists);
    assertTrue(list.size() > 0);
}
Also used : MockModel(com.activeandroid.test.MockModel) Select(com.activeandroid.query.Select) From(com.activeandroid.query.From)

Aggregations

Select (com.activeandroid.query.Select)24 From (com.activeandroid.query.From)11 MockModel (com.activeandroid.test.MockModel)11 ArrayList (java.util.ArrayList)3 Update (com.activeandroid.query.Update)2 Message (android.os.Message)1 Feed (cn.edu.cqupt.nmid.headline.support.repository.headline.bean.Feed)1 Delete (com.activeandroid.query.Delete)1 TypeSerializer (com.activeandroid.serializer.TypeSerializer)1 File (java.io.File)1 Field (java.lang.reflect.Field)1 Date (java.util.Date)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1