コード例 #1
0
  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());
      }
    }
  }
コード例 #2
0
 /**
  * @param databaseTableDescription - table for columns actually in the database
  * @param configColumns - column names of configurated columns
  */
 private void checkUnknownColumns(
     TableDescription databaseTableDescription, String[] configColumns) {
   Collection<String> c = getUnmappedColumns(databaseTableDescription.getTableName());
   String[] unmappedColumns = c.toArray(new String[0]);
   // check that unmapped columns exist in database
   for (String unmapped : c) {
     assertTrue(
         "Column: "
             + databaseTableDescription.getTableName()
             + "."
             + unmapped
             + " [declared as unknown, but] not in database",
         databaseTableDescription.getColumn(unmapped) != null);
   }
   String[] dbColumns = databaseTableDescription.getColumnNames();
   for (String theDbColumn : dbColumns) {
     if (!containsIgnoreCase(unmappedColumns, theDbColumn)) {
       assertTrue(
           "Table "
               + databaseTableDescription.getTableName()
               + " contains unknown column: '"
               + theDbColumn
               + "'",
           containsIgnoreCase(configColumns, theDbColumn));
     }
   }
 }