Search in sources :

Example 16 with Model

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;
}
Also used : Brand(com.orm.androrm.impl.Brand) Branch(com.orm.androrm.impl.Branch) ArrayList(java.util.ArrayList) Model(com.orm.androrm.Model) Product(com.orm.androrm.impl.Product) Supplier(com.orm.androrm.impl.Supplier) DatabaseAdapter(com.orm.androrm.DatabaseAdapter)

Example 17 with Model

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);
}
Also used : ArrayList(java.util.ArrayList) Model(com.orm.androrm.Model) BlankModel(com.orm.androrm.impl.BlankModel) DatabaseAdapter(com.orm.androrm.DatabaseAdapter)

Example 18 with Model

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);
}
Also used : ArrayList(java.util.ArrayList) Model(com.orm.androrm.Model) DatabaseAdapter(com.orm.androrm.DatabaseAdapter)

Example 19 with Model

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()));
}
Also used : BlankModelNoAutoincrement(com.orm.androrm.impl.BlankModelNoAutoincrement) Model(com.orm.androrm.Model) BlankModel(com.orm.androrm.impl.BlankModel)

Example 20 with Model

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));
}
Also used : Model(com.orm.androrm.Model) TableDefinition(com.orm.androrm.TableDefinition) Product(com.orm.androrm.impl.Product)

Aggregations

Model (com.orm.androrm.Model)26 DatabaseAdapter (com.orm.androrm.DatabaseAdapter)22 ArrayList (java.util.ArrayList)22 BlankModel (com.orm.androrm.impl.BlankModel)9 EmptyModel (com.orm.androrm.impl.migration.EmptyModel)5 BlankModelNoAutoincrement (com.orm.androrm.impl.BlankModelNoAutoincrement)3 Product (com.orm.androrm.impl.Product)3 Branch (com.orm.androrm.impl.Branch)2 Brand (com.orm.androrm.impl.Brand)2 TableDefinition (com.orm.androrm.TableDefinition)1 Supplier (com.orm.androrm.impl.Supplier)1 ModelWithMigration (com.orm.androrm.impl.migration.ModelWithMigration)1 NewEmptyModel (com.orm.androrm.impl.migration.NewEmptyModel)1 OneFieldModel (com.orm.androrm.impl.migration.OneFieldModel)1