+ "survey_name varchar(30), "
+ "CONSTRAINT PK_employee PRIMARY KEY (id), "
+ "CONSTRAINT FK_survey FOREIGN KEY (survey_id, survey_name) REFERENCES survey(id,name), "
+ "CONSTRAINT FK_superior FOREIGN KEY (superior_id) REFERENCES employee(id))");
KeyDataFactory keyDataFactory = new KeyDataFactory(new DefaultNamingStrategy(), "Q","","test", false);
DatabaseMetaData md = connection.getMetaData();
// EMPLOYEE
// primary key
Map<String, PrimaryKeyData> primaryKeys = keyDataFactory.getPrimaryKeys(md, null, null, "EMPLOYEE");
assertFalse(primaryKeys.isEmpty());
// inverse foreign keys
Map<String, InverseForeignKeyData> exportedKeys = keyDataFactory.getExportedKeys(md, null, null, "EMPLOYEE");
assertFalse(exportedKeys.isEmpty());
assertTrue(exportedKeys.containsKey("FK_SUPERIOR"));
// foreign keys
Map<String, ForeignKeyData> importedKeys = keyDataFactory.getImportedKeys(md, null, null, "EMPLOYEE");
assertFalse(importedKeys.isEmpty());
assertTrue(importedKeys.containsKey("FK_SUPERIOR"));
assertTrue(importedKeys.containsKey("FK_SURVEY"));
// SURVEY
// primary key
primaryKeys = keyDataFactory.getPrimaryKeys(md, null, null, "SURVEY");
assertFalse(primaryKeys.isEmpty());
// inverse foreign keys
exportedKeys = keyDataFactory.getExportedKeys(md, null, null, "SURVEY");
assertFalse(exportedKeys.isEmpty());
assertTrue(exportedKeys.containsKey("FK_SURVEY"));
// foreign keys
importedKeys = keyDataFactory.getImportedKeys(md, null, null, "SURVEY");
assertTrue(importedKeys.isEmpty());
}