use of com.orm.androrm.Model 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.Model in project androrm by androrm.
the class LocationFieldTest method setUp.
@Override
public void setUp() {
List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
models.add(BlankModel.class);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
}
use of com.orm.androrm.Model in project androrm by androrm.
the class FilterTest 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);
DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
adapter.setModels(models);
}
use of com.orm.androrm.Model in project androrm by androrm.
the class ModelTest method testSaveAutoincrementOverwrite.
public void testSaveAutoincrementOverwrite() {
Model m = new BlankModelNoAutoincrement();
// initial id has to be given
assertFalse(m.save(getContext()));
assertTrue(m.save(getContext(), 5));
assertEquals(5, m.getId());
// after id is set, regular save function works
assertTrue(m.save(getContext()));
}
use of com.orm.androrm.Model in project androrm by androrm.
the class TableDefinitionTest method testRelationalClasses.
public void testRelationalClasses() {
TableDefinition def = new TableDefinition("foo");
def.addRelationalClass(Product.class);
List<Class<? extends Model>> relations = def.getRelationalClasses();
assertEquals(1, relations.size());
assertTrue(relations.contains(Product.class));
}
Aggregations