use of com.orm.androrm.Filter in project androrm by androrm.
the class FilterTest method testInFilterModel.
public void testInFilterModel() {
Person p = new Person();
p.setName("tom");
p.save(getContext());
Car c = new Car();
c.addDriver(p);
c.setName("Toyota");
c.save(getContext());
List<Person> drivers = new ArrayList<Person>();
drivers.add(p);
Filter filter = new Filter();
filter.in("mDrivers", drivers);
QuerySet<Car> cars = Car.objects(getContext()).filter(filter);
assertEquals(1, cars.count());
}
use of com.orm.androrm.Filter in project androrm by androrm.
the class FilterTest method testNoSuchFieldException.
public void testNoSuchFieldException() {
Filter filter = new Filter();
filter.is("no_such_field", "value");
try {
Brand.objects(getContext()).filter(filter);
fail();
} catch (NoSuchFieldException e) {
}
}
use of com.orm.androrm.Filter in project androrm by androrm.
the class QuerySetTest method testContains.
public void testContains() {
Filter filter = new Filter();
filter.contains("mName", "Pretoria");
Branch contained = Branch.objects(getContext()).get(1);
Branch notContained = Branch.objects(getContext()).get(3);
QuerySet<Branch> result = Branch.objects(getContext()).filter(filter);
assertTrue(result.contains(contained));
assertFalse(result.contains(notContained));
}
use of com.orm.androrm.Filter in project androrm by androrm.
the class QuerySetTest method testFilter.
public void testFilter() {
Filter filter = new Filter();
filter.contains("mName", "Pretoria");
assertEquals(2, Branch.objects(getContext()).filter(filter).count());
}
use of com.orm.androrm.Filter in project androrm by androrm.
the class FieldResulutionTest method testOneToManyResolutionInBetween.
public void testOneToManyResolutionInBetween() {
Filter filter = new Filter();
filter.contains("mProducts__mBranches__mName", "cash");
QuerySet<Supplier> suppliers = Supplier.objects(getContext()).filter(filter);
assertEquals(1, suppliers.count());
assertTrue(suppliers.contains(mS1));
filter = new Filter();
filter.contains("mProducts__mBranches__mName", "plumb");
suppliers = Supplier.objects(getContext()).filter(filter);
assertEquals(0, suppliers.count());
}
Aggregations