@Test(
      description = "Rename a folder - Context menu -> Rename",
      groups = {"smoke"})
  public void RenameFolder_01() throws HarnessException {

    FolderItem inbox = FolderItem.importFromSOAP(app.zGetActiveAccount(), SystemFolder.Inbox);
    ZAssert.assertNotNull(inbox, "Verify the inbox is available");

    // Create the subfolder
    String name1 = "folder" + ZimbraSeleniumProperties.getUniqueString();

    app.zGetActiveAccount()
        .soapSend(
            "<CreateFolderRequest xmlns='urn:zimbraMail'>"
                + "<folder name='"
                + name1
                + "' l='"
                + inbox.getId()
                + "'/>"
                + "</CreateFolderRequest>");

    FolderItem subfolder1 = FolderItem.importFromSOAP(app.zGetActiveAccount(), name1);
    ZAssert.assertNotNull(subfolder1, "Verify the subfolder is available");

    // Click on Get Mail to refresh the folder list
    app.zPageMail.zToolbarPressButton(Button.B_GETMAIL);

    // Rename the folder using context menu
    DialogRenameFolder dialog =
        (DialogRenameFolder)
            app.zTreeMail.zTreeItem(Action.A_RIGHTCLICK, Button.B_RENAME, subfolder1);
    ZAssert.assertNotNull(dialog, "Verify the dialog opened");

    // Set the name, click OK
    String name2 = "folder" + ZimbraSeleniumProperties.getUniqueString();
    dialog.zSetNewName(name2);
    dialog.zClickButton(Button.B_OK);

    // Get all the folders and verify the new name appears and the old name disappears
    app.zGetActiveAccount().soapSend("<GetFolderRequest xmlns = 'urn:zimbraMail'/>");

    Element[] eFolder1 =
        app.zGetActiveAccount().soapSelectNodes("//mail:folder[@name='" + name1 + "']");
    ZAssert.assertEquals(eFolder1.length, 0, "Verify the old folder name no longer exists");

    Element[] eFolder2 =
        app.zGetActiveAccount().soapSelectNodes("//mail:folder[@name='" + name2 + "']");
    ZAssert.assertEquals(eFolder2.length, 1, "Verify the new folder name exists");
  }
  @Test(
      description = "Rename a folder - set to an invalid name with ':'",
      groups = {"functional"})
  public void RenameFolder_02() throws HarnessException {

    FolderItem inbox = FolderItem.importFromSOAP(app.zGetActiveAccount(), SystemFolder.Inbox);
    ZAssert.assertNotNull(inbox, "Verify the inbox is available");

    // Create the subfolder
    String name1 = "folder" + ZimbraSeleniumProperties.getUniqueString();

    app.zGetActiveAccount()
        .soapSend(
            "<CreateFolderRequest xmlns='urn:zimbraMail'>"
                + "<folder name='"
                + name1
                + "' l='"
                + inbox.getId()
                + "'/>"
                + "</CreateFolderRequest>");

    FolderItem subfolder1 = FolderItem.importFromSOAP(app.zGetActiveAccount(), name1);
    ZAssert.assertNotNull(subfolder1, "Verify the subfolder is available");

    // Click on Get Mail to refresh the folder list
    app.zPageMail.zToolbarPressButton(Button.B_GETMAIL);

    // Rename the folder using context menu
    DialogRenameFolder dialog =
        (DialogRenameFolder)
            app.zTreeMail.zTreeItem(Action.A_RIGHTCLICK, Button.B_RENAME, subfolder1);
    ZAssert.assertNotNull(dialog, "Verify the dialog opened");

    // Set the name, click OK
    String name2 = "folder:folder" + ZimbraSeleniumProperties.getUniqueString();
    dialog.zSetNewName(name2);
    dialog.zClickButton(Button.B_OK);

    DialogError error = app.zPageMain.zGetErrorDialog(DialogErrorID.InvalidFolderName);
    ZAssert.assertTrue(error.zIsActive(), "Verify the error dialog appears");

    error.zClickButton(Button.B_OK);
  }