Ejemplo 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));
  }
Ejemplo n.º 2
0
  @Test
  public void shouldSetTableReference() throws Exception {
    final Table newTable =
        RelationalModelFactory.createTable(getTransaction(), _repo, mock(Model.class), "newTable");
    this.foreignKey.setReferencesTable(getTransaction(), newTable);
    commit(); // must commit so that query used in next method will work

    assertThat(this.foreignKey.getReferencesTable(getTransaction()), is(newTable));
  }
Ejemplo n.º 3
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));
  }
Ejemplo n.º 4
0
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.komodo.relational.vdb.DataRole#addPermission(org.komodo.spi.repository.Repository.UnitOfWork,
  *     java.lang.String)
  */
 @Override
 public Permission addPermission(final UnitOfWork transaction, final String permissionName)
     throws KException {
   return RelationalModelFactory.createPermission(
       transaction, getRepository(), this, permissionName);
 }