Search in sources :

Example 11 with Supplier

use of com.orm.androrm.impl.Supplier 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());
}
Also used : Brand(com.orm.androrm.impl.Brand) Product(com.orm.androrm.impl.Product) Supplier(com.orm.androrm.impl.Supplier)

Example 12 with Supplier

use of com.orm.androrm.impl.Supplier 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()));
}
Also used : Brand(com.orm.androrm.impl.Brand) Product(com.orm.androrm.impl.Product) Supplier(com.orm.androrm.impl.Supplier)

Aggregations

Supplier (com.orm.androrm.impl.Supplier)12 Filter (com.orm.androrm.Filter)6 Brand (com.orm.androrm.impl.Brand)6 Product (com.orm.androrm.impl.Product)6 ArrayList (java.util.ArrayList)4 Branch (com.orm.androrm.impl.Branch)3 DatabaseAdapter (com.orm.androrm.DatabaseAdapter)1 Model (com.orm.androrm.Model)1