ForeignKeyImpl extends TableConstraintImpl implements ForeignKey { @Override public Column[] getReferencesColumns( final UnitOfWork transaction ) throws KException { ArgCheck.isNotNull( transaction, "transaction" ); ArgCheck.isTrue( ( transaction.getState() == State.NOT_STARTED ), "transaction state is not NOT_STARTED" ); final Repository repository = getRepository(); Column[] result = null; final Property property = getProperty( transaction, Constraint.TABLE_REFERENCE_REFERENCES ); if ( property == null ) { result = new Column[ 0 ]; } else { final String[] columnRefs = property.getStringValues( transaction ); result = new Column[ columnRefs.length ]; int i = 0; for ( final String columnId : columnRefs ) { final KomodoObject kobject = repository.getUsingId( transaction, columnId ); if ( kobject == null ) { throw new KException( Messages.getString( Relational.REFERENCED_COLUMN_NOT_FOUND, columnId ) ); } result[i] = new ColumnImpl( transaction, repository, kobject.getAbsolutePath() ); ++i; } } return result; } ForeignKeyImpl( final UnitOfWork uow,
                           final Repository repository,
                           final String workspacePath ); @Override KomodoType getTypeIdentifier(UnitOfWork uow); @Override void addReferencesColumn( final UnitOfWork transaction,
                                     final Column newReferencesColumn ); @Override ConstraintType getConstraintType(); @Override Column[] getReferencesColumns( final UnitOfWork transaction ); @Override Table getReferencesTable( final UnitOfWork transaction ); @Override int getTypeId(); @Override Table getParent( final UnitOfWork transaction ); @Override void removeReferencesColumn( final UnitOfWork transaction,
                                        final Column removeReferencesColumn ); @Override void setReferencesTable( final UnitOfWork transaction,
                                    final Table newReferencesTable );  }
@Test public void shouldNotHaveColumnReferencesAfterConstruction() throws Exception { assertThat( this.foreignKey.getReferencesColumns( getTransaction() ), is( notNullValue() ) ); assertThat( this.foreignKey.getReferencesColumns( getTransaction() ).length, is( 0 ) ); }