use of com.orm.androrm.impl.Supplier 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());
}
use of com.orm.androrm.impl.Supplier in project androrm by androrm.
the class FieldResulutionTest 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());
mB = b;
// ID 1
Branch b1 = new Branch();
b1.setName("Cashbuild Pretoria");
b1.setBrand(b);
b1.save(getContext());
mB1 = b1;
// ID 2
Branch b2 = new Branch();
b2.setName("Plumblink Pretoria");
b2.setBrand(b);
b2.save(getContext());
mB2 = b2;
// ID 3
Branch b3 = new Branch();
b3.setName("The third Branch");
b3.setBrand(b);
b3.save(getContext());
mB3 = b3;
// ID 1
Product p1 = new Product();
p1.setName("ofen");
p1.addBranch(b1);
p1.addBranch(b3);
p1.save(getContext());
mP1 = p1;
Supplier s1 = new Supplier();
s1.setName("ACME");
s1.setBrand(b);
s1.addProduct(p1);
s1.addBranch(b1);
s1.save(getContext());
mS1 = s1;
}
use of com.orm.androrm.impl.Supplier in project androrm by androrm.
the class FieldResulutionTest method testForeignKeyResolutionInBetween.
public void testForeignKeyResolutionInBetween() {
Filter filter = new Filter();
filter.contains("mBranches__mBrand__mName", "cal");
QuerySet<Supplier> suppliers = Supplier.objects(getContext()).filter(filter);
assertEquals(1, suppliers.count());
assertTrue(suppliers.contains(mS1));
filter = new Filter();
filter.is("mBranches__mBrand__mName", "false");
suppliers = Supplier.objects(getContext()).filter(filter);
assertEquals(0, suppliers.count());
}
use of com.orm.androrm.impl.Supplier in project androrm by androrm.
the class FieldResulutionTest method testForeignKeyResolutionLastField.
public void testForeignKeyResolutionLastField() {
Filter filter = new Filter();
filter.is("mBranches__mBrand", mB);
QuerySet<Supplier> suppliers = Supplier.objects(getContext()).filter(filter);
assertEquals(1, suppliers.count());
assertTrue(suppliers.contains(mS1));
}
use of com.orm.androrm.impl.Supplier in project androrm by androrm.
the class ManyToManyFieldTest method testAddAndGet.
public void testAddAndGet() {
Product p1 = new Product();
p1.setName("test1");
p1.save(getContext());
Product p2 = new Product();
p2.setName("test2");
p2.save(getContext());
Brand b = new Brand();
b.setName("Copcal");
b.save(getContext());
Supplier s = new Supplier();
s.setName("ACME");
s.setBrand(b);
s.addProduct(p1);
s.addProduct(p2);
s.save(getContext());
s = Supplier.objects(getContext()).get(s.getId());
QuerySet<Product> products = s.getProducts(getContext());
assertEquals(2, products.count());
assertTrue(products.contains(p1));
assertTrue(products.contains(p2));
}
Aggregations