use of com.orm.androrm.impl.Branch in project androrm by androrm.
the class FieldResulutionTest method testManyToManyFieldResolutionOnlyField.
public void testManyToManyFieldResolutionOnlyField() {
List<Branch> branches = new ArrayList<Branch>();
branches.add(mB1);
branches.add(mB2);
Filter filter = new Filter();
filter.in("mBranches", branches);
QuerySet<Supplier> suppliers = Supplier.objects(getContext()).filter(filter);
assertEquals(1, suppliers.count());
assertTrue(suppliers.contains(mS1));
branches.remove(0);
filter = new Filter();
filter.in("mBranches", branches);
suppliers = Supplier.objects(getContext()).filter(filter);
assertEquals(0, suppliers.count());
}
use of com.orm.androrm.impl.Branch in project androrm by androrm.
the class QuerySetTest method setUp.
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(Product.class);
models.add(Branch.class);
models.add(Supplier.class);
models.add(Brand.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
Brand b = new Brand();
b.setName("Copcal");
b.save(getContext());
// ID 1
Branch b1 = new Branch();
b1.setName("Cashbuild Pretoria");
b1.setBrand(b);
b1.save(getContext());
// ID 2
Branch b2 = new Branch();
b2.setName("Plumblink Pretoria");
b2.setBrand(b);
b2.save(getContext());
// ID 3
Branch b3 = new Branch();
b3.setName("The third Branch");
b3.setBrand(b);
b3.save(getContext());
}
use of com.orm.androrm.impl.Branch in project androrm by androrm.
the class ForeignKeyFieldTest method testDoCascade.
public void testDoCascade() {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ECLAIR_MR1) {
return;
}
Brand b = new Brand();
b.setName("Copcal");
b.save(getContext());
Branch br = new Branch();
br.setBrand(b);
br.setName("Pretoria");
br.save(getContext());
b.delete(getContext());
assertEquals(0, Branch.objects(getContext()).count());
}
Aggregations