Exemplo n.º 1
0
  @Test
  public void shouldAddReferencesColumns() throws Exception {
    final Column columnA =
        RelationalModelFactory.createColumn(getTransaction(), _repo, this.refTable, "columnRefA");
    this.foreignKey.addReferencesColumn(getTransaction(), columnA);

    final Column columnB =
        RelationalModelFactory.createColumn(getTransaction(), _repo, this.refTable, "columnRefB");
    this.foreignKey.addReferencesColumn(getTransaction(), columnB);

    commit(); // must commit so that query used in getReferencesColumns will work

    assertThat(this.foreignKey.getReferencesColumns(getTransaction()).length, is(2));
    assertThat(
        Arrays.asList(this.foreignKey.getReferencesColumns(getTransaction())),
        hasItems(columnA, columnB));
  }
Exemplo n.º 2
0
  @Test
  public void shouldRemoveReferencesColumn() throws Exception {
    final Column columnA =
        RelationalModelFactory.createColumn(
            getTransaction(), _repo, this.refTable, "removeRefColumnA");
    this.foreignKey.addReferencesColumn(getTransaction(), columnA);
    commit(); // must commit so that query used in next method will work

    this.foreignKey.removeReferencesColumn(getTransaction(), columnA);
    assertThat(this.foreignKey.getReferencesColumns(getTransaction()).length, is(0));
  }