@Test
public void getCreateForeignKeyConstraintSQL() 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.getCreateForeignKeyConstraintSQL(constraint);
assertEquals("ALTER TABLE table ADD CONSTRAINT name FOREIGN KEY (column1, column2) REFERENCES foreign_table (foreign_column1, foreign_column2) ON DELETE CASCADE ON UPDATE RESTRICT DEFERRABLE INITIALLY DEFERRED", result);
}