DbImportAction action = i.getInstance(DbImportAction.class);
DbImportParameters parameters = new DbImportParameters();
parameters.setMeaningfulPkTables("a*");
DbLoader loader1 = action.createLoader(parameters, mock(DbAdapter.class), mock(Connection.class),
mock(DbLoaderDelegate.class));
// DbLoader is so ugly and hard to test..
Field dbEntityList = DbLoader.class.getDeclaredField("dbEntityList");
dbEntityList.setAccessible(true);
List<DbEntity> entities = (List<DbEntity>) dbEntityList.get(loader1);
DataMap map = new DataMap();
DbEntity e1 = new DbEntity("e1");
DbAttribute pk = new DbAttribute("pk", Types.INTEGER, e1);
pk.setPrimaryKey(true);
e1.addAttribute(pk);
DbAttribute nonPk = new DbAttribute("nonPk", Types.INTEGER, e1);
e1.addAttribute(nonPk);
map.addDbEntity(e1);
entities.add(e1);
DbEntity a1 = new DbEntity("a1");
DbAttribute apk = new DbAttribute("pk", Types.INTEGER, a1);
apk.setPrimaryKey(true);
a1.addAttribute(apk);
DbAttribute anonPk = new DbAttribute("nonPk", Types.INTEGER, a1);
a1.addAttribute(anonPk);
map.addDbEntity(a1);
entities.add(a1);
loader1.loadObjEntities(map);
ObjEntity oe1 = map.getObjEntity("E1");
assertEquals(1, oe1.getAttributes().size());
assertNotNull(oe1.getAttribute("nonPk"));