StandardDialect implements Dialect, SequenceSupport, IdentityColumnSupport, TriggerSupport { @Override public String getDropForeignKeyConstraintSQL(ForeignKeyConstraint key) { return MessageFormat.format(this.dropForeignKeyConstraintFormat(), key.getName(), key.getTable().getDDLName()); }  @Override String getTruncateTableSQL(TableProperties properties); @Override String getCreateForeignKeyConstraintSQL(ForeignKeyConstraint key); @Override String getDropForeignKeyConstraintSQL(ForeignKeyConstraint key); @Override String getCreateUniqueConstraintSQL(UniqueConstraint constraint); @Override String getDropUniqueConstraintSQL(UniqueConstraint constraint); @Override boolean isSelectForUpdate(String sql); @Override List<String> getDefaultSchemas(DatabaseMetaData metaData); @Override SequenceSupport getSequenceSupport(); @Override String parseSequence(String sql); @Override int getColumnType(ColumnProperties properties); @Override Collection<SequenceProperties> getSequences(DatabaseMetaData metaData, SequencePropertiesFactory factory); @Override String getNextSequenceValueSQL(SequenceProperties sequence); @Override String getAlterSequenceSQL(SequenceProperties sequence, long value); @Override IdentityColumnSupport getIdentityColumnSupport(); @Override String parseInsertTable(String sql); @Override String getAlterIdentityColumnSQL(TableProperties table, ColumnProperties column, long value); @Override String evaluateCurrentDate(String sql, java.sql.Date date); @Override String evaluateCurrentTime(String sql, java.sql.Time time); @Override String evaluateCurrentTimestamp(String sql, java.sql.Timestamp timestamp); @Override String evaluateRand(String sql); @Override boolean indicatesFailure(SQLException e); @Override boolean indicatesFailure(XAException e); @Override DumpRestoreSupport getDumpRestoreSupport(); @Override TriggerSupport getTriggerSupport(); @Override String getCreateTriggerSQL(String name, TableProperties table, TriggerEvent event, String action); @Override String getDropTriggerSQL(String name, TableProperties table); @Override String getTriggerRowAlias(TriggerTime time); @Override String getCreateSchemaSQL(String schema); @Override String getDropSchemaSQL(String schema); @Override Collection<QualifiedName> getTables(DatabaseMetaData metaData, QualifiedNameFactory factory); @Override Map<String, ColumnProperties> getColumns(DatabaseMetaData metaData, QualifiedName table, ColumnPropertiesFactory factory); @Override UniqueConstraint getPrimaryKey(DatabaseMetaData metaData, QualifiedName table, UniqueConstraintFactory factory); @Override Collection<ForeignKeyConstraint> getForeignKeyConstraints(DatabaseMetaData metaData, QualifiedName table, ForeignKeyConstraintFactory factory); @Override Collection<UniqueConstraint> getUniqueConstraints(DatabaseMetaData metaData, QualifiedName table, UniqueConstraint primaryKey, UniqueConstraintFactory factory); @Override Collection<String> getIdentityColumns(Collection<ColumnProperties> columns); @Override Map<Integer, Entry<String, Integer>> getTypes(DatabaseMetaData metaData); @Override IdentifierNormalizer createIdentifierNormalizer(DatabaseMetaData metaData); @Override QualifiedNameFactory createQualifiedNameFactory(DatabaseMetaData metaData, IdentifierNormalizer normalizer); @Override ColumnPropertiesFactory createColumnPropertiesFactory(IdentifierNormalizer normalizer); @Override SequencePropertiesFactory createSequencePropertiesFactory(QualifiedNameFactory factory); @Override ForeignKeyConstraintFactory createForeignKeyConstraintFactory(QualifiedNameFactory factory); @Override UniqueConstraintFactory createUniqueConstraintFactory(IdentifierNormalizer normalizer); @Override boolean isValid(Connection connection); @Override ConnectionProperties getConnectionProperties(D database, Decoder decoder);  }
@Test public void getDropForeignKeyConstraintSQL() throws SQLException { QualifiedName table = mock(QualifiedName.class); QualifiedName foreignTable = mock(QualifiedName.class); ForeignKeyConstraint constraint = mock(ForeignKeyConstraint.class); when(table.getDDLName()).thenReturn("table"); when(foreignTable.getDDLName()).thenReturn("foreign_table"); when(constraint.getName()).thenReturn("name"); when(constraint.getTable()).thenReturn(table); when(constraint.getColumnList()).thenReturn(Arrays.asList("column1", "column2")); when(constraint.getForeignTable()).thenReturn(foreignTable); when(constraint.getForeignColumnList()).thenReturn(Arrays.asList("foreign_column1", "foreign_column2")); when(constraint.getDeferrability()).thenReturn(DatabaseMetaData.importedKeyInitiallyDeferred); when(constraint.getDeleteRule()).thenReturn(DatabaseMetaData.importedKeyCascade); when(constraint.getUpdateRule()).thenReturn(DatabaseMetaData.importedKeyRestrict); String result = this.dialect.getDropForeignKeyConstraintSQL(constraint); assertEquals("ALTER TABLE table DROP CONSTRAINT name", result); }