/** Qmetry ID: 65855 Unlock a Node ================ */
  @Test
  public void test01_UnlockNode() {
    String fileTitle = "Ecms_Admin_Unlock_Node";
    String content = "Unlock A Node In Content Administration";
    By eLockedFile = By.xpath(cMenu.ELEMENT_FILE_TITLE.replace("${titleOfFile}", fileTitle));
    String elementLockedArticleIcon =
        cMenu.ELEMENT_FILE_LOCKED_BY_ADMIN.replace("${titleOfFile}", fileTitle);

    info("-- Test case: Unlock a node --");

    // Go to Site Explorer
    nav.goToSiteExplorer();
    // actBar.goToSitesManagement();
    ecms.goToNode("intranet/documents");

    // Create a new File
    actBar.goToAddNewContent();
    cTemplate.createNewFile(fileTitle, content, fileTitle);

    // Lock this File
    cMenu.contextMenuAction(eLockedFile, cMenu.ELEMENT_CONTEXT_MENU_LOCK);
    click(cMenu.ELEMENT_DOCUMENT);
    waitForAndGetElement(elementLockedArticleIcon);

    // Unlock Node in Admin
    ecMain.goToLockedTab();
    click(ecMain.ELEMENT_UNLOCK_NODE.replace("${lockedNode}", fileTitle));
    waitForElementNotPresent(ecMain.ELEMENT_UNLOCK_NODE.replace("${lockedNode}", fileTitle));

    info("-- Restore data --");
    nav.goToSiteExplorer();
    cMenu.deleteDocument(eLockedFile);
  }
  /** Qmetry: ID 66909 -- Case No 036 / ID 003 -- Copy a Category and paste into itself -- */
  @Test
  public void test03_CopyACategoryAndPasteIntoItself() {
    By ELEMENT_SELECTED_CATEGORY_NAME =
        By.xpath(cMenu.ELEMENT_FILE_TITLE.replace("${titleOfFile}", categoryName));

    info("-- Step 1: Create a Category --");

    String categoryTreeName = "categoryAction03";

    nav.goToContentAdministration();

    // Add category tree
    String[] form1 = {categoryTreeName, categoryWorkspace, nodeHomePath};
    String[] form2 = {"", ""};
    String[] form3 = {actionName, optionLifeCycle, nodeTargetPath};
    boolean[] setPermission = {true, false, false};
    magCa.addNewCategoryTree(form1, true, false, form2, DATA_USER1, setPermission, form3);
    waitForTextPresent(categoryTreeName);

    info("-- Step 2: Copy a Category --");
    magCa.addChildCategory(categoryTreeName, categoryName);
    click(magCa.ELEMENT_COPY_CATEGORY_ICON.replace("${categoryName}", categoryName));

    info("-- Step 3: Paste copied Category into itself --");
    click(magCa.ELEMENT_PASTE_TO_CATEGORY_ICON.replace("${categoryName}", categoryName));
    click(ELEMENT_SELECTED_CATEGORY_NAME);
    waitForTextPresent(categoryName);

    info("-- Restore original data --");
    button.close();
    magCa.deleteCategory(categoryTreeName);

    info("-- Sign Out --");
    // signOut();
  }
  /** Qmetry: ID 66792 -- Case No 039 / ID 006 -- Cut a Category and paste into its child node -- */
  @Test
  public void test06_CutACategoryAndPasteIntoItsChildNode() {
    By ELEMENT_SELECTED_CATEGORY_NAME =
        By.xpath(cMenu.ELEMENT_FILE_TITLE.replace("${titleOfFile}", categoryName));

    info("-- Step 1: Create a Category --");

    String categoryTreeName = "categoryAction06";

    nav.goToContentAdministration();

    // Add category tree
    String[] form1 = {categoryTreeName, categoryWorkspace, nodeHomePath};
    String[] form2 = {groupID, "*"};
    String[] form3 = {actionName, optionLifeCycle, nodeTargetPath};
    boolean[] setPermission = {true, false, false};
    magCa.addNewCategoryTree(form1, false, true, form2, DATA_USER1, setPermission, form3);
    waitForTextPresent(categoryTreeName);

    info("-- Step 2: Cut a Category --");
    magCa.addChildCategory(categoryTreeName, categoryName);
    magCa.addChildCategory(categoryName, newCategoryName, true);
    ecms.clickUpLevel();
    click(magCa.ELEMENT_CUT_CATEGORY_ICON.replace("${categoryName}", categoryName));

    info("-- Step 3: Paste a cut Category into its child node --");
    click(ELEMENT_SELECTED_CATEGORY_NAME);
    click(magCa.ELEMENT_PASTE_TO_CATEGORY_ICON.replace("${categoryName}", newCategoryName));
    waitForMessage(magCa.MESSAGE_INFO_PASTE_TO_CATEGORY);
    // dialog.closeMessageDialog();
    click(button.ELEMENT_OK_BUTTON);

    info("-- Restore original data --");
    button.close();
    magCa.deleteCategory(categoryTreeName);

    info("-- Sign Out --");
    // signOut();
  }
  /** Qmetry ID: 67841 Manage Lock ================ */
  @Test
  public void test02_ManageLock() {
    String fileTitle = "Ecms_Admin_Manage_Lock";
    String content = "All users in the selected group, would be able to unlock";
    By eLockedFile = By.xpath(cMenu.ELEMENT_FILE_TITLE.replace("${titleOfFile}", fileTitle));
    String elementLockedArticleIcon =
        cMenu.ELEMENT_FILE_LOCKED_BY_ADMIN.replace("${titleOfFile}", fileTitle);

    By ELEMENT_GROUP_MEMBERSHIP = By.linkText("manager");
    String ELEMENT_GROUP_MEMBERSHIP_DISPLAY = "manager";
    String ELEMENT_GROUP_TO_SELECT = "Platform/Content Management";
    String ELEMENT_GROUP_DISPLAY = "platform/web-contributors";

    info("-- Test case: Manage lock --");

    // Go to Site Explorer
    nav.goToSiteExplorer();
    // actBar.goToSitesManagement();
    ecms.goToNode("intranet/documents");

    // Create a new File
    actBar.goToAddNewContent();
    cTemplate.createNewFile(fileTitle, content, fileTitle);

    // Lock this File
    cMenu.contextMenuAction(eLockedFile, cMenu.ELEMENT_CONTEXT_MENU_LOCK);
    click(cMenu.ELEMENT_DOCUMENT);
    waitForAndGetElement(elementLockedArticleIcon);

    // Open form to add permission for Users/Group (unlock node)
    // Add permission for group to unlock node
    ecMain.goToManageLockTab();
    userGroup.selectGroup(ELEMENT_GROUP_TO_SELECT, true);
    click(ELEMENT_GROUP_MEMBERSHIP);

    // Groups are listed on the table
    waitForTextPresent(ELEMENT_GROUP_MEMBERSHIP_DISPLAY + ":/" + ELEMENT_GROUP_DISPLAY);

    // Login with user in the selected group and un lock that node
    driver.close();
    driver = new FirefoxDriver();
    driver.get(baseUrl);
    nav = new NavigationToolbar(driver);
    magAcc = new ManageAccount(driver);
    ecMain = new ECMainFunction(driver);
    adminPer = new Permission(driver);
    cMenu = new ContextMenu(driver);
    ecms = new EcmsBase(driver);

    magAcc.signIn("mary", "gtn");
    ecMain.goToLockedTab();
    click(ecMain.ELEMENT_UNLOCK_NODE.replace("${lockedNode}", fileTitle));
    waitForTextNotPresent(fileTitle);

    // Admin re-LogIn and Delete Permission...
    magAcc.signOut();
    magAcc.signIn(DATA_USER, DATA_PASS);
    ecMain.goToManageLockTab();
    click(
        adminPer.ELEMENT_DELETE_SELECTED_GROUP.replace("${selectedGroup}", ELEMENT_GROUP_DISPLAY));
    waitForTextNotPresent(ELEMENT_GROUP_MEMBERSHIP_DISPLAY + ":/" + ELEMENT_GROUP_DISPLAY);

    // Restore data
    nav.goToSiteExplorer();
    ecms.goToNode("intranet/documents");
    cMenu.deleteDocument(eLockedFile);
  }