// Path: test/src/com/orm/androrm/impl/Product.java
// public class Product extends Model {
// 
// 	public static final QuerySet<Product> objects(Context context) {
// 		return objects(context, Product.class);
// 	}
// 	
// 	protected CharField mName;
// 	protected ManyToManyField<Product, Branch> mBranches;
// 	
// 	public Product() {
// 		super();
// 		
// 		mName = new CharField(50);
// 		mBranches = new ManyToManyField<Product, Branch>(Product.class, Branch.class);
// 	}
// 
// 	public void setName(String name) {
// 		mName.set(name);
// 	}
// 	
// 	public String getName() {
// 		return mName.get();
// 	}
// 	
// 	public void addBranch(Branch branch) {
// 		mBranches.add(branch);
// 	}
// 	
// 	public void addBranches(List<Branch> branches) {
// 		mBranches.addAll(branches);
// 	}
// 	
// 	public QuerySet<Branch> getBranches(Context context) {
// 		return mBranches.get(context, this);
// 	}
// 	
// 	public int branchCount(Context context) {
// 		return mBranches.get(context, this).count();
// 	}
// 	
// }
// 
// Path: test/src/com/orm/androrm/impl/migration/EmptyModel.java
// public class EmptyModel extends Model {
// 
// 	public static QuerySet<EmptyModel> objects(Context context) {
// 		return objects(context, EmptyModel.class);
// 	}
// 	
// 	protected ManyToManyField<EmptyModel, NewEmptyModel> mM2M;
// 	
// 	public EmptyModel() {
// 		super();
// 		
// 		mM2M = new ManyToManyField<EmptyModel, NewEmptyModel>(EmptyModel.class, NewEmptyModel.class);
// 	}
// 	
// }
// 
// Path: src/src/com/orm/androrm/migration/Migrator.java
// public class Migrator<T extends Model> {
// 
// 	private Class<T> mModel;
// 	private List<Migratable<T>> mMigrations;
// 	
// 	public Migrator(Class<T> model) {
// 		mModel = model;
// 		mMigrations = new ArrayList<Migratable<T>>();
// 	}
// 	
// 	public void addField(String name, DatabaseField<?> field) {
// 		AddFieldMigration<T> migration = new AddFieldMigration<T>(name, field);
// 		
// 		mMigrations.add(migration);
// 	}
// 	
// 	public <R extends Model> void addField(String name, ManyToManyField<T, R> field) {
// 		// Tables for M2M relations are created anyway. This stub is only here,
// 		// so that users aren't confused, if they try to add a M2M field. We let
// 		// them believe "they" did it :)
// 		return;
// 	}
// 	
// 	public void renameModel(String old, Class<? extends Model> updated) {
// 		RenameModelMigration<T> migration = new RenameModelMigration<T>(old);
// 		
// 		mMigrations.add(migration);
// 	}
// 	
// 	public void renameRelation(String old, Class<? extends Model> updated) {
// 		RenameRelationMigration<T> migration = new RenameRelationMigration<T>(old);
// 		
// 		mMigrations.add(migration);
// 	}
// 	
// 	public void migrate(Context context) {
// 		for(Migratable<T> migration : mMigrations) {
// 			if(migration.execute(context, mModel)) {
// 				Migration.create(mModel, migration).save(context);
// 			}
// 		}
// 	}
// 	
// }


import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.field.ForeignKeyField;
import com.orm.androrm.impl.Product;
import com.orm.androrm.impl.migration.EmptyModel;
import com.orm.androrm.migration.Migrator;
package com.orm.androrm.test.migration;



public class ForeignKeyMigrationTest extends AbstractMigrationTest {

	@Override
	public void setUp() {
		List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
		models.add(EmptyModel.class);
		
		DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
		adapter.setModels(models);
		
		super.setUp();
	}
	
	public void testForeignKeyAdd() {
		assertFalse(mHelper.hasField(EmptyModel.class, "mProduct"));
		
// Path: test/src/com/orm/androrm/impl/Product.java
// public class Product extends Model {
// 
// 	public static final QuerySet<Product> objects(Context context) {
// 		return objects(context, Product.class);
// 	}
// 	
// 	protected CharField mName;
// 	protected ManyToManyField<Product, Branch> mBranches;
// 	
// 	public Product() {
// 		super();
// 		
// 		mName = new CharField(50);
// 		mBranches = new ManyToManyField<Product, Branch>(Product.class, Branch.class);
// 	}
// 
// 	public void setName(String name) {
// 		mName.set(name);
// 	}
// 	
// 	public String getName() {
// 		return mName.get();
// 	}
// 	
// 	public void addBranch(Branch branch) {
// 		mBranches.add(branch);
// 	}
// 	
// 	public void addBranches(List<Branch> branches) {
// 		mBranches.addAll(branches);
// 	}
// 	
// 	public QuerySet<Branch> getBranches(Context context) {
// 		return mBranches.get(context, this);
// 	}
// 	
// 	public int branchCount(Context context) {
// 		return mBranches.get(context, this).count();
// 	}
// 	
// }
// 
// Path: test/src/com/orm/androrm/impl/migration/EmptyModel.java
// public class EmptyModel extends Model {
// 
// 	public static QuerySet<EmptyModel> objects(Context context) {
// 		return objects(context, EmptyModel.class);
// 	}
// 	
// 	protected ManyToManyField<EmptyModel, NewEmptyModel> mM2M;
// 	
// 	public EmptyModel() {
// 		super();
// 		
// 		mM2M = new ManyToManyField<EmptyModel, NewEmptyModel>(EmptyModel.class, NewEmptyModel.class);
// 	}
// 	
// }
// 
// Path: src/src/com/orm/androrm/migration/Migrator.java
// public class Migrator<T extends Model> {
// 
// 	private Class<T> mModel;
// 	private List<Migratable<T>> mMigrations;
// 	
// 	public Migrator(Class<T> model) {
// 		mModel = model;
// 		mMigrations = new ArrayList<Migratable<T>>();
// 	}
// 	
// 	public void addField(String name, DatabaseField<?> field) {
// 		AddFieldMigration<T> migration = new AddFieldMigration<T>(name, field);
// 		
// 		mMigrations.add(migration);
// 	}
// 	
// 	public <R extends Model> void addField(String name, ManyToManyField<T, R> field) {
// 		// Tables for M2M relations are created anyway. This stub is only here,
// 		// so that users aren't confused, if they try to add a M2M field. We let
// 		// them believe "they" did it :)
// 		return;
// 	}
// 	
// 	public void renameModel(String old, Class<? extends Model> updated) {
// 		RenameModelMigration<T> migration = new RenameModelMigration<T>(old);
// 		
// 		mMigrations.add(migration);
// 	}
// 	
// 	public void renameRelation(String old, Class<? extends Model> updated) {
// 		RenameRelationMigration<T> migration = new RenameRelationMigration<T>(old);
// 		
// 		mMigrations.add(migration);
// 	}
// 	
// 	public void migrate(Context context) {
// 		for(Migratable<T> migration : mMigrations) {
// 			if(migration.execute(context, mModel)) {
// 				Migration.create(mModel, migration).save(context);
// 			}
// 		}
// 	}
// 	
// }


// Path: test/src/com/orm/androrm/test/migration/ForeignKeyMigrationTest.java
import java.util.ArrayList;
import java.util.List;
import com.orm.androrm.DatabaseAdapter;
import com.orm.androrm.Model;
import com.orm.androrm.field.ForeignKeyField;
import com.orm.androrm.impl.Product;
import com.orm.androrm.impl.migration.EmptyModel;
import com.orm.androrm.migration.Migrator;

package com.orm.androrm.test.migration;



public class ForeignKeyMigrationTest extends AbstractMigrationTest {

	@Override
	public void setUp() {
		List<Class<? extends Model>> models = new ArrayList<Class<? extends Model>>();
		models.add(EmptyModel.class);
		
		DatabaseAdapter adapter = DatabaseAdapter.getInstance(getContext());
		adapter.setModels(models);
		
		super.setUp();
	}
	
	public void testForeignKeyAdd() {
		assertFalse(mHelper.hasField(EmptyModel.class, "mProduct"));
		
		Migrator<EmptyModel> migrator = new Migrator<EmptyModel>(EmptyModel.class);