/** deploy vdb and create connection profile (modelExplorer.deployVDB() doesn't create CP) */
  private void executeVDB(String project, String vdb) {
    modelExplorer.activate();
    vdb = (vdb.contains(".vdb")) ? vdb : vdb + ".vdb";

    new DefaultTreeItem(project, vdb).select();
    new ContextMenu("Modeling", "Execute VDB").select();

    new WaitWhile(new IsInProgress(), TimePeriod.VERY_LONG);
    new WaitWhile(new JobIsRunning(), TimePeriod.LONG);
    new WorkbenchShell();
    TeiidPerspective.activate();
  }
  @Test
  public void recursiveXmlTest() throws Exception {
    // create relational source model
    FlatImportWizard importWizard = new FlatImportWizard();
    importWizard.open();
    importWizard.selectLocalFileImportMode();
    importWizard.next();
    importWizard.selectProfile(flatProfile);
    importWizard.selectFile("EmpData.csv     <<<<");
    importWizard.setSourceModel(EMPDATA_SOURCE);
    importWizard.setProject(PROJECT_NAME);
    importWizard.next();
    importWizard.next();
    importWizard.next();
    importWizard.setViewModel(EMPLOYEES_VIEW);
    importWizard.setViewTable(EMP_TABLE);
    importWizard.setProject(PROJECT_NAME);
    importWizard.finish();

    // import xml schema
    XMLSchemaImportWizard xmlWizard = new XMLSchemaImportWizard();
    xmlWizard.open();
    xmlWizard.selectLocalImportMode();
    xmlWizard.next();
    xmlWizard.setFromDirectory(new File(RESOURCES_XSD).getAbsolutePath());
    xmlWizard.setToDirectory(PROJECT_NAME);
    xmlWizard.selectSchema(EMPLOYEES_SCHEMA_XSD);
    xmlWizard.finish();

    // create virtual document XML model
    MetadataModelWizard modelWizard = new MetadataModelWizard();
    modelWizard.open();
    modelWizard.setLocation(PROJECT_NAME);
    modelWizard.setModelName(EMP_DOC_VIEW);
    modelWizard.selectModelClass(ModelClass.XML);
    modelWizard.selectModelType(ModelType.VIEW);
    modelWizard.selectModelBuilder(ModelBuilder.BUILD_FROM_XML_SCHEMA);
    modelWizard.next();
    modelWizard.selectXMLSchemaFile(PROJECT_NAME, EMPLOYEES_SCHEMA_XSD);
    modelWizard.addElement(ROOT_ELEM);
    modelWizard.finish();

    // employees mapping transformation model
    Project project = teiidBot.modelExplorer().getProject(PROJECT_NAME);
    project.getProjectItem(EMP_DOC_VIEW + ".xmi", SIMPLE_EMPLOYEES_DOCUMENT).open();

    MappingDiagramEditor mappingDiagramEditor = new MappingDiagramEditor(EMP_DOC_VIEW + ".xmi");
    mappingDiagramEditor.addMappingClassColumns(EMPLOYEE, EMPLOYEE_COLUMNS);

    // attributes must be in the same order!
    mappingDiagramEditor.addMappingClassColumns(SUPERVISOR, SUPERVISOR_COLUMNS1);
    mappingDiagramEditor.copyAttribute(EMPLOYEE, SUPERVISOR, "State");
    mappingDiagramEditor.addMappingClassColumns(SUPERVISOR, SUPERVISOR_COLUMNS2);

    // employee - transf. diagram
    new ModelEditor(EMP_DOC_VIEW + ".xmi").showMappingTransformation(EMPLOYEE);
    ModelExplorerView mew = TeiidPerspective.getInstance().getModelExplorerView();
    mew.addTransformationSource(PROJECT_NAME, EMPLOYEES_VIEW + ".xmi", EMP_TABLE);
    new ModelEditor(EMP_DOC_VIEW + ".xmi").save();

    // reconciller
    Reconciler rec = new ModelEditor(EMP_DOC_VIEW + ".xmi").openReconciler();
    rec.bindAttributes("MiddleInitial : string", "MiddleName");
    rec.bindAttributes("Phone : string", "HomePhone");
    rec.bindAttributes("mgrID : biginteger", "Manager");
    rec.clearRemainingUnmatchedSymbols();
    rec.resolveTypes(ExpressionBuilder.KEEP_VIRTUAL_TARGET);
    rec.close();

    ModelEditor modelEditor = new ModelEditor(EMP_DOC_VIEW + ".xmi");
    new SWTWorkbenchBot().toolbarButtonWithTooltip("Show Parent Diagram").click();
    modelEditor.showMappingTransformation(SUPERVISOR);
    mew.addTransformationSource(PROJECT_NAME, EMPLOYEES_VIEW + ".xmi", EMP_TABLE);
    InputSetEditor ise = modelEditor.openInputSetEditor(true);
    ise.createNewInputParam(EMPLOYEE, "mgrID : positiveInteger");
    ise.close(); // and save
    modelEditor.save();

    mappingDiagramEditor = new MappingDiagramEditor(EMP_DOC_VIEW + ".xmi");
    RecursionEditor recEd = mappingDiagramEditor.clickOnRecursiveButton(SUPERVISOR);
    recEd.enableRecursion();
    recEd.close();
    mappingDiagramEditor.showTransformation();
    mappingDiagramEditor.save();

    // reconciller
    rec = modelEditor.openReconciler();
    rec.bindAttributes("MiddleInitial : string", "MiddleName");
    rec.bindAttributes("Phone : string", "HomePhone");
    rec.bindAttributes("mgrID : biginteger", "Manager");
    rec.clearRemainingUnmatchedSymbols();
    rec.resolveTypes(ExpressionBuilder.KEEP_VIRTUAL_TARGET);
    rec.close();

    // criteria builder
    CriteriaBuilder cb = modelEditor.criteriaBuilder();
    cb.selectLeftAttribute("INPUTS", "mgrID");
    cb.selectRightAttribute("Employees.EmpTable", "EmpId");
    cb.selectOperator(OperatorType.EQUALS);
    cb.apply();
    cb.close();
    modelEditor.save();

    // create new view model
    modelWizard = new MetadataModelWizard();
    modelWizard.open();
    modelWizard.setLocation(PROJECT_NAME);
    modelWizard.setModelName(EMP_V);
    modelWizard.selectModelClass(ModelClass.RELATIONAL);
    modelWizard.selectModelType(ModelType.VIEW);
    modelWizard.selectModelBuilder(ModelBuilder.TRANSFORM_EXISTING);
    modelWizard.next();
    modelWizard.setExistingModel(PROJECT_NAME, EMPLOYEES_VIEW + ".xmi");
    modelWizard.finish();

    // create data source
    mew.createDataSource(
        ConnectionSourceType.USE_MODEL_CONNECTION_INFO,
        null,
        PROJECT_NAME,
        EMPDATA_SOURCE + "Source.xmi");

    // create new vdb
    CreateVDB createVDB = new CreateVDB();
    createVDB.setFolder(PROJECT_NAME);
    createVDB.setName(VDB);
    createVDB.execute(true);

    // add models to the vdb
    VDBEditor editor = VDBEditor.getInstance(VDB + ".vdb");
    editor.show();
    editor.addModel(PROJECT_NAME, EMPDATA_SOURCE + "Source");
    editor.addModel(PROJECT_NAME, EMP_DOC_VIEW);
    editor.addModel(PROJECT_NAME, EMP_V);
    editor.save();

    // deploy vdb
    VDB vdb = new ModelExplorer().getModelProject(PROJECT_NAME).getVDB(VDB + ".vdb");
    vdb.deployVDB();

    // check sql
    checkSql(SQL);
  }