Search in sources :

Example 6 with From

use of com.activeandroid.query.From 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)

Example 7 with From

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

the class ExistsTest method testExistsEmptyResult.

/**
     * Should return {@code false} since the where-clause matches zero rows and thus the result set
     * is empty.
     */
public void testExistsEmptyResult() {
    cleanTable();
    populateTable();
    From from = new Select().from(MockModel.class).where("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 8 with From

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

the class FromTest method testWhereOrChaining.

public void testWhereOrChaining() {
    From expected = from().where("a = ? OR b = ?", 1, 2);
    From actual = from().where("a = ?", 1).or("b = ?", 2);
    assertSqlEquals(expected, actual);
}
Also used : From(com.activeandroid.query.From)

Example 9 with From

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

the class ExistsTest method testCountOrderBy.

/**
     * Should not change the result if order by is used.
     */
public void testCountOrderBy() {
    cleanTable();
    populateTable();
    From from = new Select().from(MockModel.class).where("intField = ?", 1).orderBy("intField ASC");
    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 From

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

the class FromTest method testWhereChaining.

public void testWhereChaining() {
    From expected = from().where("a = ? AND b = ?", 1, 2);
    From actual = from().where("a = ?", 1, 2).where("b = ?", 1, 2);
    assertSqlEquals(expected, actual);
}
Also used : From(com.activeandroid.query.From)

Aggregations

From (com.activeandroid.query.From)18 Select (com.activeandroid.query.Select)11 MockModel (com.activeandroid.test.MockModel)11