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);
}
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);
}
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);
}
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);
}
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);
}