use of com.orm.androrm.impl.Product in project androrm by androrm.
the class ManyToManyFieldTest method testReset.
public void testReset() {
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());
assertEquals(2, s.getProducts(getContext()).count());
s.delete(getContext());
assertEquals(0, s.getProducts(getContext()).count());
}
use of com.orm.androrm.impl.Product in project androrm by androrm.
the class ManyToManyFieldTest method testCount.
public void testCount() {
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 }));
assertEquals(0, s.productCount(getContext()));
s.save(getContext());
s = Supplier.objects(getContext()).get(s.getId());
assertEquals(2, s.productCount(getContext()));
}
Aggregations