use of org.apache.cayenne.dbsync.merge.token.MergerToken in project cayenne by apache.
the class DataMapMergerTest method testChangeColumnTypeSimple.
@Test
public void testChangeColumnTypeSimple() throws Exception {
DataMap existing = dataMap().with(dbEntity("table1").attributes(dbAttr("attr01").typeInt())).build();
DataMap db = dataMap().with(dbEntity("table1").attributes(dbAttr("attr01").typeVarchar(30))).build();
List<MergerToken> tokens = dbMerger().createMergeTokens(existing, db);
assertEquals(1, tokens.size());
DbEntity entity = existing.getDbEntity("table1");
DbEntity entityDb = db.getDbEntity("table1");
assertTrue(tokens.get(0) instanceof SetColumnTypeToDb);
assertEquals(factory().createSetColumnTypeToDb(entity, entityDb.getAttribute("attr01"), entity.getAttribute("attr01")).getTokenValue(), tokens.get(0).getTokenValue());
}
use of org.apache.cayenne.dbsync.merge.token.MergerToken in project cayenne by apache.
the class DataMapMergerTest method testRemoveTable.
@Test
public void testRemoveTable() throws Exception {
DataMap existing = dataMap().build();
DataMap db = dataMap().with(dbEntity("table1").attributes(dbAttr("attr01").typeInt())).build();
List<MergerToken> tokens = dbMerger().createMergeTokens(existing, db);
assertEquals(1, tokens.size());
assertEquals(factory().createDropTableToDb(db.getDbEntity("table1")).getTokenValue(), tokens.get(0).getTokenValue());
}
use of org.apache.cayenne.dbsync.merge.token.MergerToken in project cayenne by apache.
the class DataMapMergerTest method testDropPrimaryKey.
@Test
public void testDropPrimaryKey() throws Exception {
DataMap existing = dataMap().with(dbEntity("table1").attributes(dbAttr("attr01").typeInt())).build();
DataMap db = dataMap().with(dbEntity("table1").attributes(dbAttr("attr01").typeInt().primaryKey())).build();
List<MergerToken> tokens = dbMerger().createMergeTokens(existing, db);
assertEquals(1, tokens.size());
}
use of org.apache.cayenne.dbsync.merge.token.MergerToken in project cayenne by apache.
the class DataMapMergerTest method testChangeGeneratedStatus.
@Test
public void testChangeGeneratedStatus() {
DataMap existing = dataMap().with(dbEntity("table1").attributes(dbAttr("attr01").typeVarchar(10))).build();
DataMap db = dataMap().with(dbEntity("table1").attributes(dbAttr("attr01").typeInt().generated())).build();
List<MergerToken> tokens = dbMerger().createMergeTokens(existing, db);
assertEquals(2, tokens.size());
}
use of org.apache.cayenne.dbsync.merge.token.MergerToken in project cayenne by apache.
the class DataMapMergerTest method testRemoveColumn.
@Test
public void testRemoveColumn() throws Exception {
DataMap existing = dataMap().with(dbEntity("table1").attributes(dbAttr("attr01").typeInt())).build();
DataMap db = dataMap().with(dbEntity("table1").attributes(dbAttr("attr01").typeInt(), dbAttr("attr02").typeInt())).build();
List<MergerToken> tokens = dbMerger().createMergeTokens(existing, db);
assertEquals(1, tokens.size());
DbEntity entity = db.getDbEntity("table1");
assertEquals(factory().createDropColumnToModel(entity, entity.getAttribute("attr02")).getTokenValue(), tokens.get(0).getTokenValue());
}
Aggregations