private void compareColumnDescription( TableDescription xmlTableDescription, TableDescription databaseTableDescription) { String tableName = xmlTableDescription.getTableName(); for (int i = 0; i < xmlTableDescription.getColumnSize(); i++) { ColumnDescription xmlColumnDescription = xmlTableDescription.getColumn(i); ColumnDescription databaseColumnDescription = databaseTableDescription.getColumn(xmlColumnDescription.getColumnName()); assertTrue( "Column: " + xmlTableDescription + "." + xmlColumnDescription + " not in database.", databaseColumnDescription != null); if (databaseColumnDescription != null) { assertTrue( "Table: " + tableName + ", ColumnName: " + xmlColumnDescription.getColumnName() + "... Wrong Precision! Expected Precision: " + xmlColumnDescription.getPrecision() + " databasePrecision: " + databaseColumnDescription.getPrecision(), isPrecisionCompatible(xmlColumnDescription, databaseColumnDescription)); assertTrue( "Table: " + tableName + ", ColumnName: " + xmlColumnDescription.getColumnName() + "... Wrong Scale! Expected Scale: " + xmlColumnDescription.getScale() + " databaseScale: " + databaseColumnDescription.getScale(), isScaleCompatible(xmlColumnDescription, databaseColumnDescription)); assertTrue( "Table: " + tableName + ", ColumnName: " + xmlColumnDescription.getColumnName() + "... Wrong Type! Expected Type: " + xmlColumnDescription.getTypeName() + " databaseType: " + databaseColumnDescription.getTypeName(), isTypeCompatible(xmlColumnDescription, databaseColumnDescription)); assertTrue( "Table: " + tableName + ", ColumnName: " + xmlColumnDescription.getColumnName() + "... : expected " + nullable(xmlColumnDescription.isNullable()) + " but was " + nullable(databaseColumnDescription.isNullable()), xmlColumnDescription.isNullable() == databaseColumnDescription.isNullable()); } } }
protected boolean isTypeCompatible(ColumnDescription expected, ColumnDescription actual) { return expected.getTypeName().equalsIgnoreCase(actual.getTypeName()); }