use of com.orm.androrm.impl.Supplier in project androrm by androrm.
the class FieldResulutionTest method testManyToManyFieldResolutionLastField.
public void testManyToManyFieldResolutionLastField() {
List<Supplier> suppliers = new ArrayList<Supplier>();
suppliers.add(mS1);
Filter filter = new Filter();
filter.in("mBranches__mSuppliers", suppliers);
QuerySet<Product> products = Product.objects(getContext()).filter(filter);
assertEquals(1, products.count());
assertTrue(products.contains(mP1));
suppliers.clear();
filter = new Filter();
filter.in("mBranches__mSuppliers", suppliers);
products = Product.objects(getContext()).filter(filter);
assertEquals(0, products.count());
}
use of com.orm.androrm.impl.Supplier in project androrm by androrm.
the class FieldResulutionTest method testOneToManyResolutionLastField.
public void testOneToManyResolutionLastField() {
List<Branch> branches = new ArrayList<Branch>();
branches.add(mB1);
branches.add(mB2);
Filter filter = new Filter();
filter.in("mProducts__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("mProducts__mBranches", branches);
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 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.Supplier in project androrm by androrm.
the class ForeignKeyFieldTest method testDoNotCascade.
public void testDoNotCascade() {
Brand b = new Brand();
b.setName("Copcal");
b.save(getContext());
Supplier s = new Supplier();
s.setName("test_supplier");
s.setBrand(b);
s.save(getContext());
b.delete(getContext());
assertEquals(1, Supplier.objects(getContext()).count());
}
use of com.orm.androrm.impl.Supplier in project androrm by androrm.
the class ManyToManyFieldTest method testAddAllAndGet.
public void testAddAllAndGet() {
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.addProducts(Arrays.asList(new Product[] { p1, 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