@Test
public void testMetaModel() throws Exception {
// Test correct source code generation for the meta model
Schema schema = TAuthor().getSchema();
if (schema != null) {
int sequences = 0;
if (cSequences() != null) {
sequences++;
// DB2 has an additional sequence for the T_TRIGGERS table
if (getDialect() == DB2 ||
getDialect() == H2) {
sequences++;
}
// CUBRID generates sequences for AUTO_INCREMENT columns
else if (getDialect() == CUBRID) {
sequences += 3;
}
// Oracle has additional sequences for [#961]
else if (getDialect() == ORACLE) {
sequences += 5;
}
}
assertEquals(sequences, schema.getSequences().size());
for (Table<?> table : schema.getTables()) {
assertEquals(table, schema.getTable(table.getName()));
}
for (UDT<?> udt : schema.getUDTs()) {
assertEquals(udt, schema.getUDT(udt.getName()));
}
for (Sequence<?> sequence : schema.getSequences()) {
assertEquals(sequence, schema.getSequence(sequence.getName()));
}
int tables = 17;
// The additional T_DIRECTORY table for recursive queries
if (supportsRecursiveQueries()) {
tables++;
}
// The additional T_TRIGGERS table for INSERT .. RETURNING
if (TTriggers() != null) {
tables++;
}
// The additional T_UNSIGNED table
if (TUnsigned() != null) {
tables++;
}
// The additional T_IDENTITY table
if (TIdentity() != null) {
tables++;
}
// The additional T_IDENTITY_PK table
if (TIdentityPK() != null) {
tables++;
}
// [#959] The T_959 table for enum collisions with Java keywords
if (getDialect() == MYSQL ||
getDialect() == POSTGRES) {
tables++;
}
// [#986] Some foreign key name collision checks
if (getDialect() == ASE ||
getDialect() == CUBRID ||
getDialect() == DB2 ||
getDialect() == POSTGRES ||
getDialect() == SQLITE ||
getDialect() == SYBASE) {
tables += 2;
}
if (TArrays() == null) {
assertEquals(tables, schema.getTables().size());
}
// [#624] The V_INCOMPLETE view is only available in Oracle
// [#877] The T_877 table is only available in H2
else if (getDialect() == ORACLE ||
getDialect() == H2) {
assertEquals(tables + 2, schema.getTables().size());
}
// [#610] Collision-prone entities are only available in HSQLDB
else if (getDialect() == HSQLDB) {
assertEquals(tables + 11, schema.getTables().size());
}
else {
assertEquals(tables + 1, schema.getTables().size());
}
if (cUAddressType() == null) {
assertEquals(0, schema.getUDTs().size());
}
// [#643] The U_INVALID types are only available in Oracle
// [#799] The member procedure UDT's too
else if (getDialect() == ORACLE) {
assertEquals(7, schema.getUDTs().size());
}
else {
assertEquals(2, schema.getUDTs().size());
}
}
// Test correct source code generation for identity columns
assertNull(TAuthor().getIdentity());