use of com.orm.androrm.TableDefinition in project androrm by androrm.
the class TableDefinitionTest method testTableName.
public void testTableName() {
TableDefinition def = new TableDefinition("foo");
assertEquals("foo", def.getTableName());
assertEquals("CREATE TABLE IF NOT EXISTS `foo` ();", def.toString());
}
use of com.orm.androrm.TableDefinition 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));
}
use of com.orm.androrm.TableDefinition in project androrm by androrm.
the class TableDefinitionTest method testAddSimpleField.
public void testAddSimpleField() {
TableDefinition def = new TableDefinition("foo");
IntegerField i = new IntegerField();
def.addField("pk", i);
assertEquals("CREATE TABLE IF NOT EXISTS `foo` (`pk` integer);", def.toString());
}
use of com.orm.androrm.TableDefinition in project androrm by androrm.
the class TableDefinitionTest method testForeignKeyNotCascading.
public void testForeignKeyNotCascading() {
TableDefinition def = new TableDefinition("foo");
ForeignKeyField<Product> fk = new ForeignKeyField<Product>(Product.class);
fk.doNotCascade();
def.addField("product", fk);
assertEquals("CREATE TABLE IF NOT EXISTS `foo` (" + "`product` integer," + "FOREIGN KEY (`product`) " + "REFERENCES `product` (`mId`) " + "ON DELETE SET NULL);", def.toString());
}
use of com.orm.androrm.TableDefinition in project androrm by androrm.
the class TableDefinitionTest method testForeignKeyField.
public void testForeignKeyField() {
TableDefinition def = new TableDefinition("foo");
ForeignKeyField<Product> fk = new ForeignKeyField<Product>(Product.class);
def.addField("product", fk);
assertEquals("CREATE TABLE IF NOT EXISTS `foo` (" + "`product` integer," + "FOREIGN KEY (`product`) " + "REFERENCES `product` (`mId`) " + "ON DELETE CASCADE);", def.toString());
}
Aggregations