@Test
  public void testDelete1() throws Exception {
    final String[] commands = {
      "create-vdb myVdb vdbPath",
      "cd myVdb",
      "add-data-role myDataRole",
      "cd myDataRole",
      "add-permission myPermission",
      "cd myPermission",
      "add-mask myMask1",
      "add-mask myMask2",
      "delete-mask myMask1"
    };
    final CommandResult result = execute(commands);
    assertCommandResultOk(result);

    WorkspaceManager wkspMgr = WorkspaceManager.getInstance(_repo, getTransaction());
    Vdb[] vdbs = wkspMgr.findVdbs(getTransaction());
    assertEquals(1, vdbs.length);

    DataRole[] dataRoles = vdbs[0].getDataRoles(getTransaction());
    assertEquals(1, dataRoles.length);

    Permission[] permissions = dataRoles[0].getPermissions(getTransaction());
    assertEquals(1, permissions.length);
    assertEquals("myPermission", permissions[0].getName(getTransaction())); // $NON-NLS-1$

    Mask[] masks = permissions[0].getMasks(getTransaction());
    assertEquals(1, masks.length);
    assertEquals("myMask2", masks[0].getName(getTransaction())); // $NON-NLS-1$
  }
  @Test
  public void testAdd1() throws Exception {
    final String[] commands = {
      "create-vdb myVdb vdbPath",
      "cd myVdb",
      "add-model myModel",
      "cd myModel",
      "add-table myTable",
      "cd myTable",
      "add-access-pattern myAccessPattern"
    };
    final CommandResult result = execute(commands);
    assertCommandResultOk(result);

    WorkspaceManager wkspMgr = WorkspaceManager.getInstance(_repo);
    Vdb[] vdbs = wkspMgr.findVdbs(getTransaction());

    assertEquals(1, vdbs.length);

    Model[] models = vdbs[0].getModels(getTransaction());
    assertEquals(1, models.length);
    assertEquals("myModel", models[0].getName(getTransaction()));

    Table[] tables = models[0].getTables(getTransaction());
    assertEquals(1, tables.length);
    assertEquals("myTable", tables[0].getName(getTransaction()));

    AccessPattern[] accessPatterns = tables[0].getAccessPatterns(getTransaction());
    assertEquals(1, accessPatterns.length);
    assertEquals("myAccessPattern", accessPatterns[0].getName(getTransaction()));
  }
  @Test
  public void testAdd1() throws Exception {
    final String[] commands = {
      "create-vdb myVdb vdbPath",
      "cd myVdb",
      "add-model myModel",
      "cd myModel",
      "add-user-defined-function myUserDefinedFunction",
      "cd myUserDefinedFunction",
      "add-parameter myParameter"
    };
    final CommandResult result = execute(commands);
    assertCommandResultOk(result);

    WorkspaceManager wkspMgr = WorkspaceManager.getInstance(_repo, getTransaction());
    Vdb[] vdbs = wkspMgr.findVdbs(getTransaction());

    assertEquals(vdbs.length, 1);

    Model[] models = vdbs[0].getModels(getTransaction());
    assertEquals(1, models.length);
    assertEquals("myModel", models[0].getName(getTransaction())); // $NON-NLS-1$

    Function[] functions = models[0].getFunctions(getTransaction());
    assertEquals(1, functions.length);
    assertEquals(true, functions[0] instanceof UserDefinedFunction);
    assertEquals("myUserDefinedFunction", functions[0].getName(getTransaction())); // $NON-NLS-1$

    Parameter[] params = functions[0].getParameters(getTransaction());
    assertEquals(1, params.length);
    assertEquals("myParameter", params[0].getName(getTransaction())); // $NON-NLS-1$
  }
 protected Table createTable(
     final String vdbName, final String vdbPath, final String modelName, final String tableName)
     throws Exception {
   final WorkspaceManager mgr = WorkspaceManager.getInstance(_repo);
   final Vdb vdb = mgr.createVdb(this.uow, null, vdbName, vdbPath);
   final Model model = vdb.addModel(this.uow, modelName);
   return model.addTable(this.uow, tableName);
 }
  protected Model createModel(final String vdbName, final String vdbPath, final String modelName)
      throws Exception {
    final WorkspaceManager mgr = WorkspaceManager.getInstance(_repo);
    final Vdb vdb = mgr.createVdb(this.uow, null, vdbName, vdbPath);
    final Model model = vdb.addModel(this.uow, modelName);

    assertThat(model.getPrimaryType(this.uow).getName(), is(VdbLexicon.Vdb.DECLARATIVE_MODEL));
    assertThat(model.getName(this.uow), is(modelName));
    return model;
  }
  protected Vdb createVdb(
      final String vdbName, final KomodoObject parent, final String originalFilePath)
      throws Exception {
    final WorkspaceManager mgr = WorkspaceManager.getInstance(_repo);
    final Vdb vdb = mgr.createVdb(this.uow, parent, vdbName, originalFilePath);

    assertThat(vdb.getPrimaryType(this.uow).getName(), is(VdbLexicon.Vdb.VIRTUAL_DATABASE));
    assertThat(vdb.getName(this.uow), is(vdbName));
    assertThat(vdb.getOriginalFilePath(this.uow), is(originalFilePath));
    return vdb;
  }
  @Test
  public void testUnsetProperty1() throws Exception {
    final String[] commands = {
      "create-vdb myVdb vdbPath",
      "cd myVdb",
      "add-model myModel",
      "cd myModel",
      "add-table myTable",
      "cd myTable",
      "add-index myIndex",
      "cd myIndex",
      "set-property expression myExpression",
      "unset-property expression"
    };
    final CommandResult result = execute(commands);
    assertCommandResultOk(result);

    WorkspaceManager wkspMgr = WorkspaceManager.getInstance(_repo);
    Vdb[] vdbs = wkspMgr.findVdbs(getTransaction());

    assertEquals(1, vdbs.length);

    Model[] models = vdbs[0].getModels(getTransaction());
    assertEquals(1, models.length);
    assertEquals("myModel", models[0].getName(getTransaction())); // $NON-NLS-1$

    Table[] tables = models[0].getTables(getTransaction());
    assertEquals(1, tables.length);
    assertEquals("myTable", tables[0].getName(getTransaction())); // $NON-NLS-1$

    Index[] indexes = tables[0].getIndexes(getTransaction());
    assertEquals(1, indexes.length);
    assertEquals("myIndex", indexes[0].getName(getTransaction())); // $NON-NLS-1$

    assertEquals(null, indexes[0].getExpression(getTransaction()));
  }