@Test public void tableEquals() { final SchemaCrawlerOptions schemaCrawlerOptions = new SchemaCrawlerOptions(); schemaCrawlerOptions.setShowStoredProcedures(true); final Catalog catalog = testUtility.getCatalog(schemaCrawlerOptions); assertNotNull("Could not obtain catalog", catalog); assertTrue("Could not find any schemas", catalog.getSchemas().length > 0); final Schema schema = catalog.getSchema("PUBLIC"); assertNotNull("Could not obtain schema", schema); assertTrue("Could not find any tables", schema.getTables().length > 0); assertTrue("Could not find any procedures", schema.getProcedures().length > 0); // Try negative test final Table table0 = schema.getTables()[0]; assertTrue("Could not find any columns", table0.getColumns().length > 0); final MutableTable table1 = new MutableTable(table0.getCatalogName(), table0.getSchemaName(), "Test Table 1"); final MutableTable table2 = new MutableTable(table0.getCatalogName(), table0.getSchemaName(), "Test Table 2"); final PrimaryKey primaryKey = table0.getPrimaryKey(); table1.setPrimaryKey(primaryKey); table2.setPrimaryKey(primaryKey); for (final Column column : table0.getColumns()) { table1.addColumn((MutableColumn) column); table2.addColumn((MutableColumn) column); } for (final Index index : table0.getIndices()) { table1.addIndex((MutableIndex) index); table2.addIndex((MutableIndex) index); } for (final ForeignKey fk : table0.getForeignKeys()) { table1.addForeignKey((MutableForeignKey) fk); table2.addForeignKey((MutableForeignKey) fk); } for (final Trigger trigger : table0.getTriggers()) { table1.addTrigger((MutableTrigger) trigger); table2.addTrigger((MutableTrigger) trigger); } for (final Privilege privilege : table0.getPrivileges()) { table1.addPrivilege((MutablePrivilege) privilege); table2.addPrivilege((MutablePrivilege) privilege); } for (final CheckConstraint checkConstraint : table0.getCheckConstraints()) { table1.addCheckConstraint((MutableCheckConstraint) checkConstraint); table2.addCheckConstraint((MutableCheckConstraint) checkConstraint); } assertFalse("Tables should not be equal", table1.equals(table2)); }
@Test public void testSchema() { final SchemaCrawlerOptions schemaCrawlerOptions = (SchemaCrawlerOptions) appContext.getBean("schemaCrawlerOptions"); final Catalog catalog = testUtility.getCatalog(schemaCrawlerOptions); assertNotNull("Could not obtain catalog", catalog); assertTrue("Could not find any schemas", catalog.getSchemas().length > 0); final Schema schema = catalog.getSchema("PUBLIC"); assertNotNull("Could not obtain schema", schema); assertEquals(6, schema.getTables().length); }