@Test(groups = "EnterpriseOnly")
  public void Enterprise40x_13863() throws Exception {
    /** Start Test */
    testName = getTestName();

    /** Test Data Setup */
    String siteName = getSiteName(testName);
    String testUser = getUserNameFreeDomain(testName);
    String fileName = getFileName(testName) + getRandomStringWithNumders(3) + ".txt";

    DocumentLibraryPage documentLibraryPage;

    // Login
    ShareUser.login(drone, testUser, DEFAULT_PASSWORD);

    documentLibraryPage = ShareUser.openSitesDocumentLibrary(drone, siteName);

    // Upload File
    String[] fileInfo = {fileName, DOCLIB};
    ShareUser.uploadFileInFolder(drone, fileInfo);

    DocumentDetailsPage detailsPage = documentLibraryPage.selectFile(fileName);

    // Click "Edit Properties" in Actions section;
    EditDocumentPropertiesPage editPropertiesPage = detailsPage.selectEditProperties().render();
    editPropertiesPage.selectMimeType(MimeType.XML);
    detailsPage = editPropertiesPage.selectSave().render();
    detailsPage.render();

    Map<String, Object> properties = detailsPage.getProperties();
    Assert.assertEquals(properties.get("Mimetype"), "XML");
  }
  public void createCloudAccount(String testName) throws Exception {
    String user1 = getUserNameForDomain(testName + "opUser", testDomain);
    String[] userInfo1 = new String[] {user1};
    String cloudUser = getUserNameForDomain(testName + "cloudUser", testDomain);
    String[] cloudUserInfo1 = new String[] {cloudUser};
    String opSite = getSiteName(testName) + "-OP";
    String fileName1 = getFileName(testName) + ".txt";

    // Create User1 (On-premise)
    CreateUserAPI.CreateActivateUser(drone, ADMIN_USERNAME, userInfo1);

    // Create User1 (Cloud)
    CreateUserAPI.CreateActivateUser(hybridDrone, ADMIN_USERNAME, cloudUserInfo1);
    CreateUserAPI.upgradeCloudAccount(hybridDrone, ADMIN_USERNAME, testDomain, "1000");

    // Login to User1, set up the cloud sync
    ShareUser.login(drone, user1, DEFAULT_PASSWORD);
    signInToAlfrescoInTheCloud(drone, cloudUser, DEFAULT_PASSWORD);

    // create Site
    ShareUser.createSite(drone, opSite, SITE_VISIBILITY_PUBLIC);

    // upload a file
    String[] fileInfo1 = {fileName1, DOCLIB};
    ShareUser.uploadFileInFolder(drone, fileInfo1).render();
    ShareUser.logout(drone);
  }
  @Test(groups = "EnterpriseOnly")
  public void Enterprise40x_3960() throws Exception {
    /** Start Test */
    testName = getTestName();

    /** Test Data Setup */
    String siteName = getSiteName(testName);
    String testUser = getUserNameFreeDomain(testName);
    String fileName = getFileName(testName) + ".txt";
    DocumentLibraryPage documentLibraryPage;
    String filePath = downloadDirectory + fileName;

    setupCustomDrone(WebDroneType.DownLoadDrone);

    // Login
    ShareUser.login(customDrone, testUser, DEFAULT_PASSWORD);

    documentLibraryPage = ShareUser.openSitesDocumentLibrary(customDrone, siteName);
    // Document details page has been opened;
    DocumentDetailsPage detailsPage = documentLibraryPage.selectFile(fileName).render();
    Assert.assertFalse(detailsPage.getDocumentVersion().equals("1.0"));

    // Click Download icon for previous version;
    detailsPage.selectDownloadPreviousVersion("2.0");

    // Check the file is downloaded successfully
    detailsPage.waitForFile(maxWaitTime, downloadDirectory + fileName);

    String body = FileUtils.readFileToString(new File(filePath));
    if (body.length() == 0) {
      body = FileUtils.readFileToString(new File(filePath));
    }

    Assert.assertEquals(body, String.format("New version of document %s: %s", 2, fileName));
  }
  @Test(groups = "EnterpriseOnly")
  public void Enterprise40x_14032() {
    /** Start Test */
    testName = getTestName();

    /** Test Data Setup */
    String siteName = getSiteName(testName);
    String testUser = getUserNameFreeDomain(testName);
    String fileName = getFileName(testName) + ".txt";

    DocumentLibraryPage documentLibraryPage;

    // Login
    ShareUser.login(drone, testUser, DEFAULT_PASSWORD);

    documentLibraryPage = ShareUser.openSitesDocumentLibrary(drone, siteName);

    DocumentDetailsPage detailsPage = documentLibraryPage.selectFile(fileName);

    // Click 'Change Type' action
    ChangeTypePage changeTypePage = detailsPage.selectChangeType().render();
    assertTrue(changeTypePage.isChangeTypeDisplayed());

    // Select any type if present and click Cancel
    // The behavior for standard install is: no types are available -> click cancel
    changeTypePage.selectCancel();
  }
  /** AONE-15605:Form - Items */
  @Test(groups = "Hybrid", enabled = true)
  public void AONE_15605() throws Exception {
    String testName = getTestName() + System.currentTimeMillis();
    String user1 = getUserNameForDomain(testName + "opUser", testDomain);
    String cloudUser = getUserNameForDomain(testName + "cloudUser", testDomain);
    String cloudSite = getSiteName(testName) + "CL" + "-2";
    String dueDate = getDueDateString();
    String folderName = getFolderName(testName);

    createCloudAccount(testName);

    ShareUser.login(hybridDrone, cloudUser, DEFAULT_PASSWORD);
    ShareUser.createSite(hybridDrone, cloudSite, SITE_VISIBILITY_PUBLIC);
    ShareUserSitePage.createFolder(hybridDrone, folderName, folderName);
    ShareUser.logout(hybridDrone);

    // Login as OP user
    ShareUser.login(drone, user1, DEFAULT_PASSWORD);

    // Start Simple Cloud Task Workflow
    CloudTaskOrReviewPage cloudTaskOrReviewPage =
        ShareUserWorkFlow.startCloudReviewTaskWorkFlow(drone).render();

    // ---- Step 1 ----
    // --- Step action ---
    // Fill in all the fields except Items.
    // --- Expected results ---
    // Performed correctly.

    cloudTaskOrReviewPage.selectAfterCompleteDropDown(KeepContentStrategy.KEEPCONTENT);
    Assert.assertTrue(
        cloudTaskOrReviewPage.isAfterCompletionSelected(KeepContentStrategy.KEEPCONTENT));
    Assert.assertFalse(cloudTaskOrReviewPage.isLockOnPremiseSelected());

    cloudTaskOrReviewPage.selectLockOnPremiseCheckbox(true);
    Assert.assertTrue(cloudTaskOrReviewPage.isLockOnPremiseSelected());

    cloudTaskOrReviewPage.enterDueDateText(dueDate);
    cloudTaskOrReviewPage.selectPriorityDropDown(Priority.HIGH);

    DestinationAndAssigneePage destinationAndAssigneePage =
        cloudTaskOrReviewPage.selectDestinationAndAssigneePage().render();
    destinationAndAssigneePage.selectSite(cloudSite);
    destinationAndAssigneePage.selectSubmitButtonToSync();
    AssignmentPage assignmentPage = cloudTaskOrReviewPage.selectAssignmentPage().render();
    assignmentPage.selectAssignee(cloudUser);

    // ---- Step 2 ----
    // --- Step action ---
    // Click on Start Workflow button
    // --- Expected results ---
    // Workflow could not be started' dialog with the message '08150481 At least one content item is
    // required to start a Cloud workflow' is displayed.
    cloudTaskOrReviewPage.clickStartWorkflow();
    String error = cloudTaskOrReviewPage.getWorkFlowCouldNotBeStartedPromptMessage();
    Assert.assertTrue(
        error.contains("At least one content item is required to start a Cloud workflow"),
        "Error is not displayed when no one file is added");
  }
  @Test(groups = "EnterpriseOnly")
  public void Enterprise40x_3910() {
    /** Start Test */
    testName = getTestName();

    /** Test Data Setup */
    String siteName = getSiteName(testName);
    String testUser = getUserNameFreeDomain(testName);
    String fileName = getFileName(testName) + ".txt";
    String text = getRandomString(5);
    DocumentLibraryPage documentLibraryPage;

    // Login
    ShareUser.login(drone, testUser, DEFAULT_PASSWORD);

    documentLibraryPage = ShareUser.openSitesDocumentLibrary(drone, siteName);

    DocumentDetailsPage detailsPage = documentLibraryPage.selectFile(fileName);
    AddCommentForm addCommentForm = detailsPage.clickAddCommentButton();

    // 1. Type any text and make it bold;
    TinyMceEditor tinyMceEditor = addCommentForm.getTinyMceEditor();
    tinyMceEditor.setText(text);

    tinyMceEditor.clickTextFormatter(BOLD);
    assertEquals(
        tinyMceEditor.getContent(),
        String.format("<p><b>%s</b></p>", text),
        "The text didn't mark as bold.");

    tinyMceEditor.clickTextFormatter(ITALIC);
    assertEquals(
        tinyMceEditor.getContent(),
        String.format("<p><i><b>%s</b></i></p>", text),
        "The text didn't italic.");

    tinyMceEditor.clickTextFormatter(BULLET);
    assertEquals(
        tinyMceEditor.getContent(),
        String.format("<ul><li><i><b>%s</b></i></li></ul>", text),
        "List didn't display.");

    tinyMceEditor.clickTextFormatter(NUMBER);
    assertEquals(
        tinyMceEditor.getContent(),
        String.format("<ol><li><i><b>%s</b></i></li></ol>", text),
        "Numbered list didn't display.");

    tinyMceEditor.clickColorCode(TinyMceColourCode.BLUE);
    assertEquals(
        tinyMceEditor.getColourAttribute(), "BLUE", "The text didn't highlight with any color.");

    addCommentForm.clickAddCommentButton();
    assertTrue(detailsPage.isCommentCorrect(text), "Comment didn't create");
  }
  /** AONE-15604:Form - Items */
  @Test(groups = "Hybrid", enabled = true)
  public void AONE_15604() throws Exception {
    String testName = getTestName() + System.currentTimeMillis();
    String user1 = getUserNameForDomain(testName + "opUser", testDomain);
    String cloudUser = getUserNameForDomain(testName + "cloudUser", testDomain);
    String cloudSite = getSiteName(testName) + "CL" + "-3";
    String opSite = getSiteName(testName) + "-OP";
    String fileName1 = getFileName(testName) + ".txt";
    String dueDate = getDueDateString();

    createCloudAccount(testName);

    ShareUser.login(hybridDrone, cloudUser, DEFAULT_PASSWORD);
    ShareUser.createSite(hybridDrone, cloudSite, SITE_VISIBILITY_PUBLIC);
    ShareUser.logout(hybridDrone);

    // Login as OP user
    ShareUser.login(drone, user1, DEFAULT_PASSWORD);

    ShareUser.openSiteDocumentLibraryFromSearch(drone, opSite);

    // Start Simple Cloud Task Workflow
    CloudTaskOrReviewPage cloudTaskOrReviewPage =
        ShareUserWorkFlow.startWorkFlowFromDocumentLibraryPage(drone, fileName1).render();

    // ---- Step 1 ----
    // --- Step action ---
    // Fill in all the fields except Assignee/Reviewers.
    // --- Expected results ---
    /** Performed correctly. */
    cloudTaskOrReviewPage.selectAfterCompleteDropDown(KeepContentStrategy.KEEPCONTENT);
    cloudTaskOrReviewPage.enterDueDateText(dueDate);
    cloudTaskOrReviewPage.selectLockOnPremiseCheckbox(true);
    cloudTaskOrReviewPage.selectPriorityDropDown(Priority.HIGH);
    DestinationAndAssigneePage destinationAndAssigneePage =
        cloudTaskOrReviewPage.selectDestinationAndAssigneePage().render();
    destinationAndAssigneePage.selectSite(cloudSite);
    destinationAndAssigneePage.selectSubmitButtonToSync();

    // ---- Step 2 ----
    // --- Step action ---
    // Click on Start Workflow button
    // --- Expected results ---
    // 'The value cannot be empty.' balloon pop-up is displayed above the the Assignee/Reviewers
    // section.
    cloudTaskOrReviewPage.clickStartWorkflow();
    Assert.assertTrue(
        cloudTaskOrReviewPage.isErrorBalloonPresent(),
        "Baloon error is not displayed when Assignee is not specified");
    Assert.assertEquals(
        cloudTaskOrReviewPage.getErrorBalloonMessage(), "The value cannot be empty.");
  }
  /**
   * Test: AONE-6554:Hidden files
   *
   * <ul>
   *   <li>Map Alfresco Webdav as a network drive
   *   <li>Create a folder with the name started with dot (e.g. '.folder new')
   *   <li>Create a file with the name started with dot (e.g. '.test.txt')
   *   <li>Log into Share
   *   <li>Verify the presence of the file and folder
   *   <li>The file and folder are not displayed
   * </ul>
   *
   * @throws Exception
   */
  @AlfrescoTest(testlink = "AONE-6554")
  @Test(
      groups = {"WEBDAVWindowsClient", "EnterpriseOnly"},
      timeOut = 600000)
  public void AONE_6554() throws Exception {

    if (!CifsUtil.checkDirOrFileExists(10, 200, networkDrive + sitesPath)) {
      Assert.fail("Mapping was not done " + testUser);
    }
    // Alfresco WebDAV connection is established
    String docLib = "\\documentLibrary";
    // Alfresco WebDAV connection is established
    String fullPath = networkDrive + sitesPath + siteName.toLowerCase() + docLib + "\\";

    explorer.openWindowsExplorer();
    explorer.openFolder(fullPath);

    // The space / the site's doclib is opened via WebDAV
    String windowName = ldtpUtil.findWindowName("documentLibrary");
    explorer.activateApplicationWindow(windowName);

    // Create a folder with the name started with dot (e.g. '.folder new')
    explorer.createNewFolderMenu(folderName);

    // Create a file with the name started with dot (e.g. '.test.txt')
    explorer.rightClickCreate("documentLibrary", fileName, Application.TEXTFILE);

    explorer.activateApplicationWindow(windowName);

    Ldtp newLdtp = new Ldtp(windowName);
    String[] objects = newLdtp.getObjectList();
    Assert.assertTrue(
        Arrays.asList(objects).contains(fileNameCheck),
        "Expected file '" + fileName + "' isn't displayed");
    Assert.assertTrue(
        Arrays.asList(objects).contains(folderNameCheck),
        "Expected folder '" + folderName + "' isn't displayed");
    logger.info("Close window");
    explorer.closeExplorer();

    // Log into Share
    ShareUser.login(drone, testUser);
    DocumentLibraryPage docLibPage = ShareUser.openSitesDocumentLibrary(drone, siteName);

    int fileCount = docLibPage.getFiles().size();

    ShareUser.logout(drone);

    // The file and folder are not displayed
    Assert.assertTrue(
        fileCount == 0, "Some file isn't hidden in Document Library. MNT-13125 and MNT-8116");
  }
  @Test(groups = "EnterpriseOnly")
  public void Enterprise40x_13861() throws Exception {
    /** Start Test */
    testName = getTestName();

    /** Test Data Setup */
    String siteName = getSiteName(testName);
    String testUser = getUserNameFreeDomain(testName);
    String fileName = getFileName(testName) + ".txt";

    DocumentLibraryPage documentLibraryPage;

    String workFlowName1 = testName + System.currentTimeMillis() + "-1-WF";
    String dueDate = new DateTime().plusDays(2).toString("dd/MM/yyyy");

    // Login
    ShareUser.login(drone, testUser, DEFAULT_PASSWORD);

    documentLibraryPage = ShareUser.openSitesDocumentLibrary(drone, siteName);

    DocumentDetailsPage detailsPage = documentLibraryPage.selectFile(fileName);

    // Click Start Workflow from Actions section

    StartWorkFlowPage startWorkFlowPage =
        ShareUserWorkFlow.selectStartWorkFlowFromDetailsPage(drone).render();

    NewWorkflowPage newWorkflowPage =
        startWorkFlowPage.getWorkflowPage(WorkFlowType.NEW_WORKFLOW).render();

    List<String> reviewers = new ArrayList<String>();
    reviewers.add(username);

    WorkFlowFormDetails formDetails = new WorkFlowFormDetails(siteName, siteName, reviewers);
    formDetails.setMessage(workFlowName1);
    formDetails.setDueDate(dueDate);
    formDetails.setTaskPriority(Priority.MEDIUM);
    // detailsPage = newWorkflowPage.startWorkflow(formDetails).render();

    newWorkflowPage.startWorkflow(formDetails).render();

    // check the document is marked with icon
    assertTrue(detailsPage.isPartOfWorkflow(), "Verifying the file is part of a workflow");

    // site creator logs out and assignee user logs in
    ShareUser.logout(drone);
    ShareUser.login(drone, ADMIN_USERNAME, ADMIN_PASSWORD);

    // check the task is in MyTasks for site creator
    MyTasksPage myTasksPage = ShareUserWorkFlow.navigateToMyTasksPage(drone);
    assertTrue(myTasksPage.isTaskPresent(workFlowName1));
  }
  @AfterMethod(groups = "teardown", timeOut = 150000)
  public void endTest() {
    try {
      removeMappedDrive = Runtime.getRuntime().exec("cmd /c start /WAIT net use * /d /y");
      removeMappedDrive.waitFor();
    } catch (IOException | InterruptedException e) {
      logger.error("Error occurred during delete mapped drive ", e);
    }

    ShareUser.login(drone, testUser);
    SiteUtil.deleteSite(drone, siteName);
    ShareUser.logout(drone);
    ShareUser.login(drone, ADMIN_USERNAME, ADMIN_PASSWORD);
    ShareUser.deleteUser(drone, testUser).render();
  }
  /**
   * Test - AONE-13002:Keyword search for text field
   *
   * <ul>
   *   <li>Login
   *   <li>From My Dashboard, access the Advance Search CRM form
   *   <li>In the Keyword Search text of the CRM search form, enter crm:accountId:001b0000009aPo1AAE
   *   <li>Validate the search results are 4 rows and one result item is from helloaccount folder.
   * </ul>
   */
  @Test
  public void AONE_13883() throws PageException, Exception {
    // Login
    ShareUser.login(drone, salesforceUserName, salesforcePassword);

    // Advance CRM Search with keyword
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.KEYWORD.getSearchKeys(), basic_Search_accountIdentifier);

    List<SearchResult> results = ShareUserSearchPage.advanceSearchForCRM(drone, keyWordSearchText);
    Assert.assertTrue(results.size() == 4);

    List<String> folders = new LinkedList<String>();

    // Finding the specific result item.
    for (SearchResult searchItem : results) {
      if (searchItem.getTitle().equalsIgnoreCase(account_Content)) {
        // Retrieving the folderNames from folderPath of the first resultItem.
        folders = ((SearchResultItem) searchItem).getFolderNamesFromContentPath();
      }
    }
    Assert.assertTrue(folders.size() > 0);
    Assert.assertTrue(folders.get(0).equalsIgnoreCase(attachments_Folder));
    Assert.assertTrue(folders.get(1).equalsIgnoreCase(accountName));
  }
  @Test(groups = {"DataPrepDocumentLibrary"})
  public void dataPrep_Enterprise40x_13863() throws Exception {
    String testName = getTestName();
    String testUser = getUserNameFreeDomain(testName);
    String siteName = getSiteName(testName);

    // User
    String[] testUserInfo = new String[] {testUser};
    CreateUserAPI.CreateActivateUser(drone, ADMIN_USERNAME, testUserInfo);

    // Login
    ShareUser.login(drone, testUser, DEFAULT_PASSWORD);

    // Create Site
    ShareUser.createSite(drone, siteName, AbstractUtils.SITE_VISIBILITY_PUBLIC);
    ShareUser.openSiteDashboard(drone, siteName);
  }
  /** AONE-15603:Negative case - Destination is not specified */
  @Test(groups = "Hybrid", enabled = true)
  public void AONE_15603() throws Exception {
    String testName = getTestName() + System.currentTimeMillis();
    String user1 = getUserNameForDomain(testName + "opUser", testDomain);
    String opSite = getSiteName(testName) + "-OP";
    String fileName1 = getFileName(testName) + ".txt";
    String dueDate = getDueDateString();

    createCloudAccount(testName);

    // Login as OP user
    ShareUser.login(drone, user1, DEFAULT_PASSWORD);

    ShareUser.openSiteDocumentLibraryFromSearch(drone, opSite);

    // Start Simple Cloud Task Workflow
    CloudTaskOrReviewPage cloudTaskOrReviewPage =
        ShareUserWorkFlow.startWorkFlowFromDocumentLibraryPage(drone, fileName1).render();

    // ---- Step 1 ----
    // --- Step action ---
    // Fill in all the fields except Destination
    // --- Expected results ---
    // Performed correctly.
    cloudTaskOrReviewPage.enterDueDateText(dueDate);
    cloudTaskOrReviewPage.selectLockOnPremiseCheckbox(true);
    cloudTaskOrReviewPage.selectPriorityDropDown(Priority.MEDIUM);

    // ---- Step 2 ----
    // --- Step action ---
    // Click on Start Workflow button
    // --- Expected results ---
    // 'The value cannot be empty.' baloon pop-up is displayed above the Destination section.
    cloudTaskOrReviewPage.clickStartWorkflow();
    Assert.assertTrue(
        cloudTaskOrReviewPage.isErrorBalloonPresent(),
        "Baloon error is not displayed when Destination is not specified");
    Assert.assertEquals(
        cloudTaskOrReviewPage.getErrorBalloonMessage(), "The value cannot be empty.");

    ShareUser.logout(drone);
  }
  /**
   * Test - AONE-13000:Combination - Account and Case
   *
   * <ul>
   *   <li>Login
   *   <li>From My Dashboard, access the Advance Search CRM form
   *   <li>In the Account Identifier Search text of the CRM search form, enter 001b0000009aPo1AAE
   *   <li>In the Account Name Search text of the CRM search form, enter helloaccount
   *   <li>In the Case Number Search text of the CRM search form, enter 00001006
   *   <li>In the Case Name Search text of the CRM search form, enter 00001006
   *   <li>Validate the search results is same for all combinations of search and any one of the
   *       result item should be from helloaccountoppor folder.
   * </ul>
   */
  @Test
  public void AONE_13881() throws PageException, Exception {
    // Login
    ShareUser.login(drone, salesforceUserName, salesforcePassword);

    // Advance CRM Search with Account Name and Contract Number
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.ACCOUNT_NAME.getSearchKeys(), accountName);
    keyWordSearchText.put(SearchKeys.CASE_NUMBER.getSearchKeys(), caseNameOrNumber);

    List<SearchResult> results = ShareUserSearchPage.advanceSearchForCRM(drone, keyWordSearchText);
    Assert.assertTrue(results.size() > 0);
    Assert.assertTrue(results.size() == 1);
    Assert.assertTrue(results.get(0).getTitle().equalsIgnoreCase(case_Content));

    // Advance CRM Search with Account Name, Identifier, Case Number and Case Name.
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.ACCOUNT_NAME.getSearchKeys(), accountName);
    keyWordSearchText.put(SearchKeys.CASE_NAME.getSearchKeys(), caseNameOrNumber);
    keyWordSearchText.put(SearchKeys.CASE_NUMBER.getSearchKeys(), caseNameOrNumber);
    keyWordSearchText.put(SearchKeys.ACCOUNT_IDENTIFIER.getSearchKeys(), accountIdentifier);

    results = ShareUserSearchPage.advanceSearchForCRM(drone, keyWordSearchText);
    Assert.assertTrue(results.size() > 0);
    Assert.assertTrue(results.size() == 1);
    Assert.assertTrue(results.get(0).getTitle().equalsIgnoreCase(case_Content));

    // Retrieving the folderNames from folderPath of the first resultItem.
    List<String> folders = ((SearchResultItem) results.get(0)).getFolderNamesFromContentPath();

    Assert.assertTrue(folders.get(0).equalsIgnoreCase(attachments_Folder));
    Assert.assertTrue(folders.get(1).equalsIgnoreCase(caseNameOrNumber));

    // Advance CRM Search with Account Identifier and Case Name.
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.CASE_NAME.getSearchKeys(), caseNameOrNumber);
    keyWordSearchText.put(SearchKeys.ACCOUNT_IDENTIFIER.getSearchKeys(), accountIdentifier);

    results = ShareUserSearchPage.advanceSearchForCRM(drone, keyWordSearchText);
    Assert.assertTrue(results.size() > 0);
    Assert.assertTrue(results.size() == 1);
    Assert.assertTrue(results.get(0).getTitle().equalsIgnoreCase(case_Content));

    // Advance CRM Search with Account Identifier and Case Number.
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.CASE_NUMBER.getSearchKeys(), caseNameOrNumber);
    keyWordSearchText.put(SearchKeys.ACCOUNT_IDENTIFIER.getSearchKeys(), accountIdentifier);

    results = ShareUserSearchPage.advanceSearchForCRM(drone, keyWordSearchText);
    Assert.assertTrue(results.size() > 0);
    Assert.assertTrue(results.size() == 1);
    Assert.assertTrue(results.get(0).getTitle().equalsIgnoreCase(case_Content));
  }
  @BeforeMethod(groups = "setup", timeOut = 150000)
  public void precondition() throws Exception {

    // Create user
    String[] testUserInfo = new String[] {testUser};
    CreateUserAPI.CreateActivateUser(drone, ADMIN_USERNAME, testUserInfo);

    ShareUser.logout(drone);

    String networkPathNew = networkPath.concat("webdav");

    mapConnect =
        "cmd /c start /WAIT net use"
            + " "
            + networkDrive
            + " "
            + networkPathNew
            + " "
            + "/user:"******" "
            + DEFAULT_PASSWORD;

    // Runtime.getRuntime().exec(mapConnect);
    Process process = Runtime.getRuntime().exec(mapConnect);
    // waitProcessEnd(process);
    process.waitFor();

    if (CifsUtil.checkDirOrFileExists(10, 200, networkDrive + sitesPath)) {
      logger.info("----------Mapping succesfull " + testUser);
    } else {
      logger.error("----------Mapping was not done " + testUser);
      Assert.fail("Mapping was not done " + testUser);
    }

    // Any site is created
    ShareUser.login(drone, testUser);
    ShareUser.createSite(drone, siteName, SITE_VISIBILITY_PUBLIC);
    ShareUser.logout(drone);
  }
  @Test(groups = {"DataPrepDocumentLibrary"})
  public void dataPrep_Enterprise40x_3960() throws Exception {

    String testName = getTestName();
    String testUser = getUserNameFreeDomain(testName);
    String siteName = getSiteName(testName);
    String fileName = getFileName(testName) + ".txt";

    // User
    String[] testUserInfo = new String[] {testUser};
    CreateUserAPI.CreateActivateUser(drone, ADMIN_USERNAME, testUserInfo);

    // Login
    ShareUser.login(drone, testUser, DEFAULT_PASSWORD);

    // Create Site
    ShareUser.createSite(drone, siteName, AbstractUtils.SITE_VISIBILITY_PUBLIC);
    ShareUser.openSiteDashboard(drone, siteName);
    ShareUser.openSitesDocumentLibrary(drone, siteName);

    // Upload File
    String[] fileInfo = {fileName, DOCLIB};
    DocumentLibraryPage documentLibraryPage =
        ShareUser.uploadFileInFolder(drone, fileInfo).render();

    // Upload New version of the document.
    for (int i = 0; i < 2; i++) {
      UpdateFilePage updatePage =
          documentLibraryPage.getFileDirectoryInfo(fileName).selectUploadNewVersion().render();
      updatePage.selectMajorVersionChange();
      String fileContents = String.format("New version of document %s: %s", i + 2, fileName);
      File newFileName = newFile(DATA_FOLDER + (fileName + getRandomString(3)), fileContents);
      updatePage.uploadFile(newFileName.getCanonicalPath());
      updatePage.setComment(fileName);
      SitePage sitePage = updatePage.submit().render();
      documentLibraryPage = (DocumentLibraryPage) sitePage.render();
      FileUtils.forceDelete(newFileName);
    }
  }
  @Test(groups = "EnterpriseOnly")
  public void Enterprise40x_5675() {
    /** Start Test */
    testName = getTestName();

    /** Test Data Setup */
    String siteName = getSiteName(testName);
    String testUser = getUserNameFreeDomain(testName);
    String fileName = getFileName(testName) + ".txt";
    String text = getRandomString(5);
    DocumentLibraryPage documentLibraryPage;

    // Login
    ShareUser.login(drone, testUser, DEFAULT_PASSWORD);

    documentLibraryPage = ShareUser.openSitesDocumentLibrary(drone, siteName);
    // Click Comment link near created file
    DocumentDetailsPage detailsPage =
        documentLibraryPage.getFileDirectoryInfo(fileName).clickCommentsLink().render();
    // Write some text in text box and click Add Comment button
    detailsPage.addComment(text);

    // Go to document library and verify comment counter

    documentLibraryPage = ShareUser.openDocumentLibrary(drone);
    Assert.assertEquals(documentLibraryPage.getFileDirectoryInfo(fileName).getCommentsCount(), 1);

    // Go to Details page and delete the comment
    detailsPage = documentLibraryPage.selectFile(fileName);
    detailsPage.removeComment(text);

    // Go to document library and verify comment counter

    documentLibraryPage = ShareUser.openDocumentLibrary(drone);
    Assert.assertEquals(documentLibraryPage.getFileDirectoryInfo(fileName).getCommentsCount(), 0);
  }
  /**
   * Test - AONE-12996:Case Search based on Case name
   *
   * <ul>
   *   <li>Login
   *   <li>From My Dashboard, access the Advance Search CRM form
   *   <li>In the Case Name Search text of the CRM search form, enter 00001006
   *   <li>Validate the search results, any one of the result item should be from 00001006 folder.
   * </ul>
   */
  @Test
  public void AONE_13877() throws PageException, Exception {
    // Login
    ShareUser.login(drone, salesforceUserName, salesforcePassword);

    // Advance CRM Search with Case Name
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.CASE_NAME.getSearchKeys(), caseNameOrNumber);
    List<SearchResult> results = ShareUserSearchPage.advanceSearchForCRM(drone, keyWordSearchText);
    Assert.assertTrue(results.size() > 0);

    // Retrieving the folderNames from folderPath of the first resultItem.
    List<String> folders = ((SearchResultItem) results.get(0)).getFolderNamesFromContentPath();
    Assert.assertTrue(folders.get(0).equalsIgnoreCase(attachments_Folder));
    Assert.assertTrue(folders.get(1).equalsIgnoreCase(caseNameOrNumber));
  }
  /**
   * Test - AONE-13003: Basic Search for CRM property
   *
   * <ul>
   *   <li>Login
   *   <li>From My Dashboard, access the Basic Search form
   *   <li>In the Search text of the basic search form, enter case name or number
   *   <li>Validate the search results are returned.
   *   <li>In the Search text of the basic search form, enter contract property
   *   <li>Validate that only one search result item is returned.
   *   <li>In the Search text of the basic search form, enter account property
   *   <li>Validate that only 4 search result items are returned.
   *   <li>In the Search text of the basic search form, enter opportunity property
   *   <li>Validate that only one search result item is returned.
   * </ul>
   */
  @Test
  public void AONE_13884() throws PageException, Exception {
    // Login
    ShareUser.login(drone, salesforceUserName, salesforcePassword);

    // Advance Basic Search with caseNameOrNumber
    List<SearchResult> results = ShareUserSearchPage.basicSearch(drone, caseNameOrNumber, false);
    Assert.assertTrue(results.size() > 0);

    // Advance Basic Search with caseNameOrNumber
    results = ShareUserSearchPage.basicSearch(drone, basic_Search_contractNumber, false);
    Assert.assertTrue(results.size() == 1);

    // Advance Basic Search with caseNameOrNumber
    results = ShareUserSearchPage.basicSearch(drone, basic_Search_accountIdentifier, false);
    Assert.assertTrue(results.size() == 4);

    // Advance Basic Search with caseNameOrNumber
    results = ShareUserSearchPage.basicSearch(drone, basic_Search_oppName, false);
    Assert.assertTrue(results.size() == 1);
  }
  /**
   * Test - AONE-13001:Negative test case for combination
   *
   * <ul>
   *   <li>Login
   *   <li>From My Dashboard, access the Advance Search CRM form
   *   <li>In the Oppo Name Search text of the CRM search form, enter helloaccount
   *   <li>In the Contract Name Search text of the CRM search form, enter 00000104
   *   <li>In the Case Name Search text of the CRM search form, enter 00001006
   *   <li>Validate the search results is zero.
   * </ul>
   */
  @Test
  public void AONE_13882() throws PageException, Exception {
    // Login
    ShareUser.login(drone, salesforceUserName, salesforcePassword);

    // Advance CRM Search with Opportunity Name and Contract Name
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.OPPORTUNITY_NAME.getSearchKeys(), oppName);
    keyWordSearchText.put(SearchKeys.CONTRACT_NAME.getSearchKeys(), contractNameOrNumber);

    List<SearchResult> results = ShareUserSearchPage.advanceSearchForCRM(drone, keyWordSearchText);
    Assert.assertTrue(results.size() == 0);

    // Advance CRM Search with Contract Name and Case Name.
    keyWordSearchText.clear();
    keyWordSearchText.put(SearchKeys.CASE_NAME.getSearchKeys(), caseNameOrNumber);
    keyWordSearchText.put(SearchKeys.CONTRACT_NAME.getSearchKeys(), contractNameOrNumber);

    results = ShareUserSearchPage.advanceSearchForCRM(drone, keyWordSearchText);
    Assert.assertTrue(results.size() == 0);
  }
  /**
   * Enterprise40x-6553:Search for items
   *
   * <ul>
   *   <li>Search for Content using Keywords search criteria
   *   <li>Search for Content using Name search criteria
   *   <li>Search for Content using Title search criteria
   *   <li>Search for Content using Description search criteria
   *   <li>Search for Content using Mimetype search criteria
   *   <li>Search for Content using Modified Date search criteria
   *   <li>Search for Content using Modifier search criteria
   *   <li>Click View in Browser icon
   *   <li>Click Download icon
   *   <li>Search for Folder using Keywords search criteria
   *   <li>Search for Folder using Name search criteria
   *   <li>Search for Folder using Title search criteria
   *   <li>Search for Folder using Description search criteria
   *   <li>Click on folder's path
   *   <li>Sort the found items by any criteria
   * </ul>
   *
   * @throws Exception
   */
  @Test(groups = {"Sanity", "Search"})
  public void enterprise40x_6553() throws Exception {
    testName = getTestName();
    String searchTerm = testName + "-" + System.currentTimeMillis();
    Boolean searchOk;

    String testUser = getUserNameFreeDomain(searchTerm);
    String siteName = getSiteName(searchTerm);
    String folderName = getFolderName(searchTerm + "-1");
    String folderName2 = getFolderName(searchTerm + "-2");
    String fileName = getFileName(searchTerm);

    CreateUserAPI.CreateActivateUser(drone, ADMIN_USERNAME, testUser);

    ShareUser.login(drone, testUser, DEFAULT_PASSWORD);

    // Create a Site
    ShareUser.createSite(drone, siteName, SITE_VISIBILITY_PUBLIC).render();

    // Open Document library
    ShareUser.openDocumentLibrary(drone);

    // Create 2 Folder
    ShareUserSitePage.createFolder(drone, folderName, folderName + "Title1", folderName + "Desc1");
    ShareUserSitePage.createFolder(drone, folderName2, folderName + "Title2", folderName + "Desc2");

    // Create 2 Documents
    for (int i = 0; i < 2; i++) {
      ContentDetails contentDetails = new ContentDetails();
      contentDetails.setName(fileName + "-Name-0" + i);
      contentDetails.setTitle(fileName + "-Title-0" + i);
      contentDetails.setDescription(fileName + "-Desc-0" + i);

      ShareUser.createContent(drone, contentDetails, ContentType.PLAINTEXT);
    }
    htmlFileName = fileName + "-Name-0" + TEST_HTML_FILE;
    ShareUser.uploadFileInFolder(drone, new String[] {htmlFileName});

    /** Start Test */

    // Searching and sorting the content items
    List<String> searchInfo = Arrays.asList(ADV_CONTENT_SEARCH);
    Map<String, String> keyWordSearchText = new HashMap<String, String>();

    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    Calendar cal = Calendar.getInstance();
    String todaysDate = dateFormat.format(cal.getTime());
    cal.add(Calendar.DATE, -1);

    try {
      keyWordSearchText.put(SearchKeys.KEYWORD.getSearchKeys(), searchTerm);
      List<SearchResultItem> searchResults = null;
      // Content Search with keyword: common part of filename
      searchResults = ShareUserSearchPage.advanceSearch(drone, searchInfo, keyWordSearchText);

      // Check the Search Results: Search with Retry for Solr
      assertTrue(
          ShareUserSearchPage.checkSearchResultsWithRetry(
              drone, ADV_CONTENT_SEARCH, searchTerm, fileName + "-Name-01", true),
          "Incorrect Search Results for: Keyword search- " + searchTerm + " file1 not displayed");

      searchOk = ShareUserSearchPage.isSearchItemAvailable(drone, fileName + "-Name-00");
      Assert.assertTrue(
          searchOk,
          "Incorrect Search Results for Name search- "
              + searchTerm
              + ". Result item - "
              + fileName
              + "-Name-00"
              + " not found");

      keyWordSearchText.clear();

      // Searching for valid Name.
      searchTerm = "-Name-00";
      keyWordSearchText.put(SearchKeys.NAME.getSearchKeys(), searchTerm);
      searchResults = ShareUserSearchPage.advanceSearch(drone, searchInfo, keyWordSearchText);

      searchOk = ShareUserSearchPage.isSearchItemAvailable(drone, fileName + searchTerm);
      Assert.assertTrue(searchOk, "Incorrect Search Results for Name search- " + searchTerm);

      keyWordSearchText.clear();

      // Searching for valid Title string
      searchTerm = "-Title-01";
      keyWordSearchText.put(SearchKeys.TITLE.getSearchKeys(), searchTerm);
      searchResults = ShareUserSearchPage.advanceSearch(drone, searchInfo, keyWordSearchText);

      searchOk = ShareUserSearchPage.isSearchItemAvailable(drone, fileName + "-Name-01");
      Assert.assertTrue(searchOk, "Incorrect Search Results for Name search- " + searchTerm);

      keyWordSearchText.clear();

      // Searching for valid Description string
      searchTerm = "-Desc-01";
      keyWordSearchText.put(SearchKeys.DESCRIPTION.getSearchKeys(), searchTerm);
      ShareUserSearchPage.advanceSearch(drone, searchInfo, keyWordSearchText);

      searchOk = ShareUserSearchPage.isSearchItemAvailable(drone, fileName + "-Name-01");
      Assert.assertTrue(searchOk, "Incorrect Search Results for Name search- " + searchTerm);

      keyWordSearchText.clear();

      // Searching for valid MODIFIERTODATE string
      keyWordSearchText.put(SearchKeys.MODIFIERTODATE.getSearchKeys(), todaysDate);
      keyWordSearchText.put(SearchKeys.MODIFIERFROMDATE.getSearchKeys(), todaysDate);
      searchResults = ShareUserSearchPage.advanceSearch(drone, searchInfo, keyWordSearchText);

      assertTrue(
          searchResults.size() > 0, "There should be search results for to date - " + todaysDate);
      searchOk = ShareUserSearchPage.isSearchItemAvailable(drone, fileName + "-Name-01");
      Assert.assertTrue(
          searchOk,
          "Incorrect Search Results for Name search- "
              + keyWordSearchText
              + ". Result item - "
              + fileName
              + "-Name-00");

      keyWordSearchText.clear();

      // Searching for valid Name and Mime type.
      keyWordSearchText.put(SearchKeys.MIME.getSearchKeys(), "HTML");
      searchResults = ShareUserSearchPage.advanceSearch(drone, searchInfo, keyWordSearchText);

      assertTrue(searchResults.size() > 0, "There should be search results for html MIME TYPE.");
      searchOk = ShareUserSearchPage.isSearchItemAvailable(drone, htmlFileName);
      Assert.assertTrue(
          searchOk,
          "Incorrect Search Results for Name search- "
              + keyWordSearchText
              + ". Result item - "
              + fileName
              + "-Name-00"
              + " not found");

      searchResults.clear();

      keyWordSearchText.clear();

      // Searching for valid Name and Mime type.
      keyWordSearchText.put(SearchKeys.MODIFIER.getSearchKeys(), testUser);
      searchResults = ShareUserSearchPage.advanceSearch(drone, searchInfo, keyWordSearchText);

      assertTrue(
          searchResults.size() > 0,
          "There should be search results for " + testUser + " as modifier.");
      searchOk = ShareUserSearchPage.isSearchItemAvailable(drone, fileName + "-Name-00");
      Assert.assertTrue(
          searchOk,
          "Incorrect Search Results for Name search- "
              + keyWordSearchText
              + ". Result item - "
              + fileName
              + "-Name-00"
              + " not found");

      searchResults.clear();

      keyWordSearchText.clear();

      // Folder Search: Searching with keyword
      searchInfo = Arrays.asList(ADV_FOLDER_SEARCH);

      searchTerm = folderName;
      keyWordSearchText.put(SearchKeys.KEYWORD.getSearchKeys(), searchTerm);
      searchResults = ShareUserSearchPage.advanceSearch(drone, searchInfo, keyWordSearchText);

      searchOk = ShareUserSearchPage.isSearchItemAvailable(drone, folderName);
      Assert.assertTrue(
          searchOk,
          "Incorrect Search Results for Name search- "
              + searchTerm
              + ". Result item - "
              + fileName
              + "-Name-00"
              + " not found");

      keyWordSearchText.clear();

      // Searching for valid Name.
      keyWordSearchText.put(SearchKeys.NAME.getSearchKeys(), searchTerm);
      searchResults = ShareUserSearchPage.advanceSearch(drone, searchInfo, keyWordSearchText);

      assertTrue(searchResults.size() > 0, "There should be search results for name on folder.");
      searchOk = ShareUserSearchPage.isSearchItemAvailable(drone, folderName);
      Assert.assertTrue(
          searchOk,
          "Incorrect Search Results for Name search- "
              + searchTerm
              + ". Result item - "
              + fileName
              + "-Name-00"
              + " not found");

      keyWordSearchText.clear();

      // Searching for valid Title string
      keyWordSearchText.put(SearchKeys.TITLE.getSearchKeys(), searchTerm);
      searchResults = ShareUserSearchPage.advanceSearch(drone, searchInfo, keyWordSearchText);

      assertTrue(searchResults.size() > 0, "There should be search results for title on folder.");
      searchOk = ShareUserSearchPage.isSearchItemAvailable(drone, folderName);
      Assert.assertTrue(
          searchOk,
          "Incorrect Search Results for Name search- "
              + searchTerm
              + ". Result item - "
              + folderName
              + " not found");
      keyWordSearchText.clear();

      // Searching for valid Description string
      keyWordSearchText.put(SearchKeys.DESCRIPTION.getSearchKeys(), searchTerm);
      searchResults = ShareUserSearchPage.advanceSearch(drone, searchInfo, keyWordSearchText);

      assertTrue(
          searchResults.size() > 0, "There should be search results for description on folder.");
      searchOk = ShareUserSearchPage.isSearchItemAvailable(drone, folderName);
      Assert.assertTrue(
          searchOk,
          "Incorrect Search Results for Name search- "
              + searchTerm
              + ". Result item - "
              + folderName
              + " not found");

      // Sorting results by Name
      List<SearchResultItem> sortedByName =
          ShareUserSearchPage.sortSearchResults(drone, SortType.NAME);

      List<SearchResultItem> expectedResultsSortedByName =
          new ArrayList<SearchResultItem>(sortedByName);
      Collections.sort(expectedResultsSortedByName, new SortedSearchResultItemByName());

      // Check Sort order
      for (int i = 0; (i < 5 && i < expectedResultsSortedByName.size()); i++) {
        assertTrue(
            expectedResultsSortedByName
                .get(i)
                .getTitle()
                .equalsIgnoreCase(sortedByName.get(i).getTitle()),
            "The results are not sorted as expected - "
                + expectedResultsSortedByName.get(i).getTitle()
                + " - "
                + sortedByName.get(i).getTitle());
      }
    } catch (Throwable e) {
      reportError(drone, testName, e);
    } finally {
      testCleanup(drone, testName);
    }
  }
  /** AONE-15600:Form - Items */
  @Test(groups = "Hybrid", enabled = true)
  public void AONE_15600() throws Exception {
    String testName = getTestName() + System.currentTimeMillis();
    String user1 = getUserNameForDomain(testName + "opUser", testDomain);

    createCloudAccount(testName);

    // Login as OP user
    ShareUser.login(drone, user1, DEFAULT_PASSWORD);

    // Start Simple Cloud Task Workflow
    CloudTaskOrReviewPage cloudTaskOrReviewPage =
        ShareUserWorkFlow.startCloudReviewTaskWorkFlow(drone).render();

    // ---- Step 1 ----
    // --- Step action ---
    // Verify the Items section.
    // --- Expected results ---
    /**
     * The section contains the following controls: - After completion drop-down list - Lock
     * on-premise content check-box - Selected Items section - Add button - Remove All button
     */
    Assert.assertTrue(
        cloudTaskOrReviewPage.isAfterCompletionDropdownPresent(),
        "Completion drop-down list is not present");
    Assert.assertTrue(
        cloudTaskOrReviewPage.isRemoveAllButtonPresent(), "'Remove All' button is not presented");
    Assert.assertTrue(
        cloudTaskOrReviewPage.isNoItemsSelectedMessagePresent(),
        "Selected Items section doesn't contain 'No Items Selected' message");
    Assert.assertFalse(
        cloudTaskOrReviewPage.isLockOnPremiseSelected(), "Is lock on Premise selected by default");
    Assert.assertTrue(cloudTaskOrReviewPage.isAddButtonPresent(), "Add button is not present");

    // ---- Step 2 ----
    // --- Step action ---
    // Verify After completion drop-down list.
    // --- Expected results ---
    /**
     * The list contains the following values: - 'Keep content synced on cloud', - 'Keep content on
     * cloud and remove sync', - 'Delete content on cloud and remove sync'.
     */
    List<String> afterComplete = cloudTaskOrReviewPage.getAfterCompletionOptions();
    Assert.assertTrue(
        afterComplete.contains(KeepContentStrategy.KEEPCONTENTREMOVESYNC.getStrategy()),
        "Keep content on cloud and remove sync option is not displayed");
    Assert.assertTrue(
        afterComplete.contains(KeepContentStrategy.DELETECONTENT.getStrategy()),
        "Delete content on cloud and remove sync option is not displayed");
    Assert.assertTrue(
        afterComplete.contains(KeepContentStrategy.KEEPCONTENT.getStrategy()),
        "Keep content synced on cloud option is not displayed");

    // ---- Step 3 ----
    // --- Step action ---
    // Choose any value in After completion drop-down list.
    // --- Expected results ---
    // The value is chosen successfully.
    cloudTaskOrReviewPage.selectAfterCompleteDropDown(KeepContentStrategy.KEEPCONTENT);
    Assert.assertTrue(
        cloudTaskOrReviewPage.isAfterCompletionSelected(KeepContentStrategy.KEEPCONTENT),
        "Keep content synced on cloud option cannot be selected");

    // ---- Step 4 ----
    // --- Step action ---
    // Verify Lock on-premise content check-box.
    // --- Expected results ---
    // The check-box is unchecked by default.
    Assert.assertFalse(
        cloudTaskOrReviewPage.isLockOnPremiseSelected(), "Is lock on Premise selected by default");

    // ---- Step 5 ----
    // --- Step action ---
    // Try to check Lock on-premise content check-box.
    // --- Expected results ---
    // The check-box is checked successfully.
    cloudTaskOrReviewPage.selectLockOnPremiseCheckbox(true);
    Assert.assertTrue(
        cloudTaskOrReviewPage.isLockOnPremiseSelected(),
        "Is lock on Premise cannot be set to true");

    // ---- Step 6 ----
    // --- Step action ---
    // Verify Selected Items section.
    // --- Expected results ---
    // 'No items selected' message is displayed by default.
    Assert.assertTrue(
        cloudTaskOrReviewPage.isNoItemsSelectedMessagePresent(),
        "'No Items Selected' message' is not displayed");

    // ---- Step 7 ----
    // --- Step action ---
    // Verify the Add and Remove All buttons.
    // --- Expected results ---
    // Add button is enabled, Remove All button is disabled.
    Assert.assertTrue(
        cloudTaskOrReviewPage.isAddButtonPresent(), "Add button is not active or not displayed");
    Assert.assertFalse(
        cloudTaskOrReviewPage.isRemoveAllButtonEnabled(), "Remove All button is active");

    ShareUser.logout(drone);
  }
 @AfterMethod(alwaysRun = true)
 public void logout() {
   ShareUser.logout(drone);
   logger.info("User logged out - drone.");
 }
  /**
   * Test - AONE-13004: CRM property validation
   *
   * <ul>
   *   <li>Login
   *   <li>Access the document details page for the account content created Via SF
   *   <li>Verify that document details page should be displayed.
   *   <li>Access the document details page for the contract content created Via SF.
   *   <li>Verify that document details page should be displayed correctly
   *   <li>Access the document details page for the oppor content created Via SF.
   *   <li>Verify that document details page should be displayed correctly
   *   <li>Access the document details page for the case content created Via SF.
   *   <li>Verify that document details page should be displayed correctly
   * </ul>
   */
  @Test
  public void AONE_13885() throws PageException, Exception {
    // Login
    ShareUser.login(drone, salesforceUserName, salesforcePassword);

    // Opening Site Document library page
    ShareUser.openSitesDocumentLibrary(drone, siteName);

    // Account content details page
    DocumentLibraryPage docLibPage =
        ShareUserSitePage.navigateToFolder(drone, attachments_Folder + SLASH + accountName);
    DocumentDetailsPage detailsPage = ShareUser.openDocumentDetailPage(drone, account_Content);

    // Get the properties from details page
    Map<String, Object> properties = detailsPage.getProperties();

    Assert.assertNotNull(properties);
    Assert.assertFalse(properties.isEmpty());
    Assert.assertTrue(
        ((String) properties.get("AccountIdentifier")).equalsIgnoreCase(accountIdentifier));
    Assert.assertTrue(((String) properties.get("AccountName")).equalsIgnoreCase(accountName));

    // Opening Site Document library page
    ShareUser.openDocumentLibrary(drone);

    // Contract content details page
    docLibPage =
        ShareUserSitePage.navigateToFolder(
            drone, attachments_Folder + SLASH + contractNameOrNumber);
    detailsPage = ShareUser.openDocumentDetailPage(drone, contract_Content);

    // Get the properties from details page
    properties.clear();
    properties = detailsPage.getProperties();

    Assert.assertNotNull(properties);
    Assert.assertFalse(properties.isEmpty());
    Assert.assertTrue(
        ((String) properties.get("AccountIdentifier")).equalsIgnoreCase(accountIdentifier));
    Assert.assertTrue(
        ((String) properties.get("ContractNumber")).equalsIgnoreCase(contractNameOrNumber));
    Assert.assertTrue(
        ((String) properties.get("ContractName")).equalsIgnoreCase(contractNameOrNumber));

    // Opening Site Document library page
    ShareUser.openDocumentLibrary(drone);

    // Opportunity content details page
    docLibPage = ShareUserSitePage.navigateToFolder(drone, attachments_Folder + SLASH + oppName);
    detailsPage = ShareUser.openDocumentDetailPage(drone, oppo_Content);

    // Get the properties from details page
    properties.clear();
    properties = detailsPage.getProperties();

    Assert.assertNotNull(properties);
    Assert.assertFalse(properties.isEmpty());
    Assert.assertTrue(
        ((String) properties.get("AccountIdentifier")).equalsIgnoreCase(accountIdentifier));
    Assert.assertTrue(((String) properties.get("OpportunityName")).equalsIgnoreCase(oppName));

    // Opening Site Document library page
    ShareUser.openDocumentLibrary(drone);

    // Case content details page
    docLibPage =
        ShareUserSitePage.navigateToFolder(drone, attachments_Folder + SLASH + caseNameOrNumber);
    detailsPage = ShareUser.openDocumentDetailPage(drone, case_Content);

    // Get the properties from details page
    properties.clear();
    properties = detailsPage.getProperties();

    Assert.assertNotNull(properties);
    Assert.assertFalse(properties.isEmpty());
    Assert.assertTrue(
        ((String) properties.get("AccountIdentifier")).equalsIgnoreCase(accountIdentifier));
    Assert.assertTrue(((String) properties.get("CaseNumber")).equalsIgnoreCase(caseNameOrNumber));
    Assert.assertTrue(((String) properties.get("CaseName")).equalsIgnoreCase(caseNameOrNumber));
  }
  /** AONE-15602:Form - Items - Items were selected */
  @Test(groups = "Hybrid", enabled = true)
  public void AONE_15602() throws Exception {
    String testName = getTestName() + System.currentTimeMillis();
    String user1 = getUserNameForDomain(testName + "opUser", testDomain);
    String opSite = getSiteName(testName) + "-OP";
    String fileName1 = getFileName(testName) + ".txt";
    String fileName2 = "second" + getFileName(testName) + ".txt";

    createCloudAccount(testName);

    // login
    ShareUser.login(drone, user1, DEFAULT_PASSWORD);

    // start workflow
    WorkFlowPage workflow = ShareUserWorkFlow.startCloudReviewTaskWorkFlow(drone).render();
    SelectContentPage selectPage = workflow.clickAddItems();

    // add new document
    selectPage.addItemFromSite(fileName1, opSite);
    selectPage.selectOKButton();

    // ---- Step 1 ----
    // --- Step action ---
    // Verify the information and controls available for the Added document.
    // ---- Expected results ----
    /**
     * The section contains the following information and controls: - Document's thumbnail
     * placeholder (depends on mimetype) - Document's name (a link to Document Details page) -
     * Document's description - Document's modified date - View More Actions button - Remove button
     */
    CloudTaskOrReviewPage cloudTaskOrReviewPage = new CloudTaskOrReviewPage(drone);
    List<SelectedWorkFlowItem> selectedWorkFlowItems = workflow.getSelectedItem(fileName1);
    DateFormat dateFormat = new SimpleDateFormat("EEE d MMM yyyy");
    Calendar cal = Calendar.getInstance();
    String current_date = dateFormat.format(cal.getTime());
    String itemName = selectedWorkFlowItems.get(0).getItemName();
    ShareLink link = selectedWorkFlowItems.get(0).getItemNameLink();
    String url = link.getHref();

    Assert.assertEquals(itemName, fileName1, "File with incorrect name has been added");
    Assert.assertTrue(
        cloudTaskOrReviewPage.getItemDate(fileName1).contains(current_date),
        "Item Date is not correct for added file");
    Assert.assertTrue(
        selectedWorkFlowItems.get(0).getDescription().contains("None"),
        "Description has been added to file");

    Assert.assertTrue(
        selectedWorkFlowItems.get(0).isRemoveLinkPresent(),
        "'Remove link is not displayed for the file");
    Assert.assertTrue(
        selectedWorkFlowItems.get(0).isViewMoreActionsPresent(),
        "View more action is not displayed for the file");

    String handle1 = drone.getWindowHandle();
    // ---- Step 2 ----
    // --- Step action ---
    // Click on the document's name to open the page in a separate tab/window (e.g. via RBC > Open
    // Link in a new tab).
    // ---- Expected results ----
    // The document details page in opened. All data is displayed correctly. No information about
    // Sync or Workflows is present - the document is now not a
    // part of workflow and is not yet synced to Cloud.
    drone.createNewTab();
    drone.navigateTo(url);
    DocumentDetailsPage docDetails = drone.getCurrentPage().render();
    Assert.assertTrue(
        docDetails.isDocumentActionPresent(DocumentAction.START_WORKFLOW),
        "Start workflow is not present");
    Assert.assertTrue(
        docDetails.getContentTitle().contains(fileName1),
        "Title of new tab doesn't contain info about file");
    drone.closeTab();
    // drone.find(By.cssSelector("body")).sendKeys(Keys.CONTROL +"\t");

    drone.switchToWindow(handle1);

    // ---- Step 3 -----
    // --- Step action ---
    // Click on the View More Actions button to open the page in a separate tab/window (e.g. via
    // mouse scroll button).
    // ---- Expected results ----
    // The document details page in opened. All data is displayed correctly. No information about
    // Sync or Workflows is present - the document is now not a
    // part of workflow and is not yet synced to Cloud.
    cloudTaskOrReviewPage.selectViewMoreActionsBtn(fileName1).render();
    drone.getCurrentPage().render();
    Assert.assertTrue(
        docDetails.isDocumentActionPresent(DocumentAction.START_WORKFLOW),
        "Start workflow is not present");
    Assert.assertTrue(
        docDetails.getContentTitle().contains(fileName1),
        "Title of new tab doesn't contain info about file (via View More Actions Button)");

    workflow = ShareUserWorkFlow.startCloudReviewTaskWorkFlow(drone).render();
    selectPage = workflow.clickAddItems();

    // add new document
    selectPage.addItemFromSite(fileName1, opSite);
    selectPage.selectOKButton();

    // ---- Step 4 ----
    // --- Step action ---
    // Click on the Remove button.
    // ---- Expected results ----
    // The document is removed from the Items section.
    cloudTaskOrReviewPage.selecRemoveBtn(fileName1);
    Assert.assertTrue(
        cloudTaskOrReviewPage.isNoItemsSelectedMessagePresent(),
        "Failed is not removed from workFlow");

    // ---- Step 5 ----
    // --- Step action ---
    // The documents are selected.
    // ---- Expected results ----
    // The documents are selected.
    String[] fileInfo2 = {fileName2, DOCLIB};

    ShareUser.openSiteDashboard(drone, opSite);
    @SuppressWarnings("unused")
    DocumentLibraryPage documentLibraryPage =
        ShareUser.uploadFileInFolder(drone, fileInfo2).render();

    workflow = ShareUserWorkFlow.startCloudReviewTaskWorkFlow(drone).render();
    selectPage = workflow.clickAddItems();
    selectPage.addItemFromSite(fileName1, opSite);
    selectPage.selectOKButton();

    selectPage = workflow.clickAddItems();
    selectPage.addItemFromSite(fileName2, opSite);
    selectPage.selectOKButton();
    selectedWorkFlowItems = workflow.getSelectedItem(fileName1);
    itemName = selectedWorkFlowItems.get(0).getItemName();
    Assert.assertEquals(itemName, fileName1, "First file is not added to workFlow");
    selectedWorkFlowItems = workflow.getSelectedItem(fileName2);
    itemName = selectedWorkFlowItems.get(0).getItemName();
    Assert.assertEquals(itemName, fileName2, "Second file is not added to workFlow");

    // ---- Step 6 -----
    // --- Step action ---
    // Click on Remove action for any of the added document.
    // ---- Expected results ----
    // The document is removed from the Items section. All other previously added documents are
    // still present.
    cloudTaskOrReviewPage.selecRemoveBtn(fileName1);
    Assert.assertFalse(
        cloudTaskOrReviewPage.isItemAdded(fileName1), "First file is not removed from workFlow");
    Assert.assertTrue(
        cloudTaskOrReviewPage.isItemAdded(fileName2),
        "Second file is removed during deletion first file");

    // ---- Step 7 ----
    // --- Step action ---
    // Click on Remove All button.
    // ---- Expected results ----
    // All other previously added documents are removed.
    cloudTaskOrReviewPage.selectRemoveAllButton();
    Assert.assertFalse(
        cloudTaskOrReviewPage.isItemAdded(fileName2), "Remove All button doesn't work");
  }
  /** AONE-15601:Form - Items - Select Items */
  @Test(groups = "Hybrid", enabled = true)
  public void AONE_15601() throws Exception {
    String testName = getTestName() + System.currentTimeMillis();
    String user1 = getUserNameForDomain(testName + "opUser", testDomain);
    String opSite = getSiteName(testName) + "-OP";
    String fileName1 = getFileName(testName) + ".txt";

    createCloudAccount(testName);

    // Login as OP user
    ShareUser.login(drone, user1, DEFAULT_PASSWORD);

    // ---- Step 1----
    // --- Step action ---
    // Click on Add button.
    // --- Expected results ---
    // Select window is opened. Company Home directory is opened by default.
    WorkFlowPage workflow = ShareUserWorkFlow.startCloudReviewTaskWorkFlow(drone).render();
    SelectContentPage selectPage = workflow.clickAddItems();

    // ---- Step 2 ----
    // --- Step action ---
    // Verify the available controls.
    // --- Expected results ---
    /**
     * The section contains the following controls: - Folder Up picker (disabled when root directory
     * is chosen) - Navigator (contains parent directory structure) - Available Items section
     * (Directories from Company Home are displayed) - Selected Items section ('No items selected'
     * when no items are chosen) - OK button - Cancel button
     */
    Assert.assertFalse(
        selectPage.isFolderUpButtonEnabled(), "Folder Up button is enabled by default");
    Assert.assertEquals(
        selectPage.getNoItemsSelected(),
        "No items selected",
        "'No items selected' text is not displayed when no items are chosen");
    Assert.assertTrue(selectPage.isOkButtonPresent());
    Assert.assertTrue(selectPage.isCancelButtonPresent());
    Assert.assertTrue(selectPage.isCompanyHomeButtonPresent(), "Company button is not displayed");
    List<String> elements = selectPage.getDirectoriesLeftPanel();
    Assert.assertTrue(
        elements.contains("Data Dictionary")
            && elements.contains("Guest Home")
            && elements.contains("Imap Attachments")
            && elements.contains("IMAP Home")
            && elements.contains("Shared")
            && elements.contains("Sites")
            && elements.contains("User Homes"),
        "Default directories from Company Home are NOT displayed");

    // ---- Step 3 ----
    // --- Step action ---
    // Open any directory, e.g. Sites
    // --- Expected results ---
    // The directory is opened. Folder Up picker becomes enabled.
    selectPage.clickElementOnLeftPanel("Sites");
    Assert.assertTrue(
        selectPage.isFolderUpButtonEnabled(),
        "Folder Up is not active after selection child object");

    // ---- Step 4 ----
    // --- Step action ---
    // Click on Folder Up picker.
    // --- Expected results ---
    // Company Home directory is opened again.
    selectPage.clickFolderUpButton();
    Assert.assertTrue(
        selectPage.isCompanyHomeButtonPresent(),
        "Company Home directory is not displayed after using Up button");

    // ---- Step 5 ----
    // --- Step action ---
    // Open any directory, e.g. Sites.
    // --- Expected results ---
    // The directory is opened.

    selectPage.clickElementOnLeftPanel("Sites");

    // ---- Step 6 ----
    // --- Step action ---
    // Open Company Home using Navigator.
    // --- Expected results ---
    // Company Home directory is opened again.
    selectPage.navigateToRootDir();
    Assert.assertTrue(
        selectPage.isCompanyHomeButtonPresent(), "Company Home is not displayed after navigation");

    // ---- Step 7 ----
    // ---- Step 8 ----
    // ---- Step 9 ----
    // --- Step action ---
    // Navigate to the directory where the added in the pre-condition document is located.
    // Click on Add icon.
    // --- Expected results ----
    // The directory is opened.
    // The document appears in the Selected Items section. Add icon disappears for the added
    // document. Remove icon is present for the document which is
    // present in the Selected Items section.
    selectPage.addItemFromSite(fileName1, opSite);
    Assert.assertFalse(
        selectPage.isAddIconPresent(fileName1),
        "Add icon is not disabled after adding the file to workflow");
    List<String> addedItems = selectPage.getAddedItems();
    Assert.assertTrue(
        addedItems.contains(fileName1), "Added File is not displayed for Added section");
    Assert.assertTrue(
        selectPage.isRemoveIconPresent(fileName1),
        "Remove button is not displayed for added content");

    // ---- Step 10 ----
    // --- Step action ---
    // Click on Remove icon.
    // --- Expected results ----
    // The document disappears from the Selected Items section. Add icon appears for the removed
    // document in the Available Items section.
    selectPage.removeItem(fileName1);
    addedItems = selectPage.getAddedItems();
    Assert.assertFalse(
        addedItems.contains(fileName1),
        "File is still displayed for added section after removing.");
    Assert.assertTrue(
        selectPage.isAddIconPresent(fileName1),
        "Add button for the file is not displayed after removing.");

    // ---- Step 11 ----
    // ---- Step action ----
    // Repeat step 9.
    // ---- Expected results -----
    // The document appears in the Selected Items section. Add icon disappears for the added
    // document. Remove icon is present for the document which is
    // present in the Selected Items section.
    selectPage.addItemFromSite(fileName1, opSite);
    addedItems = selectPage.getAddedItems();
    Assert.assertTrue(
        addedItems.contains(fileName1), "Added File is not displayed for Added section");
    Assert.assertTrue(
        selectPage.isRemoveIconPresent(fileName1), "Remove icon is not displayed for Added file");
    Assert.assertFalse(
        selectPage.isAddIconPresent(fileName1),
        "Add icon is not disabled after adding the file to workflow");

    // ---- Step 12 ----
    // --- Step action ---
    // Click on Close button.
    // --- Expected results ----
    // The window is closed. No data was changed in Selected Items section - no document was added.
    selectPage.selectCloseButton();
    CloudTaskOrReviewPage cloudTaskOrReviewPage = new CloudTaskOrReviewPage(drone);
    Assert.assertTrue(
        cloudTaskOrReviewPage.isNoItemsSelectedMessagePresent(),
        "Content has been added after closing Select window");

    // ---- Step 13 ----
    // ---- Step action ---
    // Verify the Remove All button.
    // ---- Expected results ----
    // The button is disabled.
    Assert.assertFalse(
        cloudTaskOrReviewPage.isRemoveAllButtonEnabled(),
        "Button is enabled after closing Select window");

    // ---- Step 14 ----
    // --- Step action ---
    // Repeat steps 1-9.
    // ---- Expected results ----
    // The latest opened directory is opened in the window (step 2). The previously chosen document
    // is displayed in the Selected Items section (step 2). The
    // document is chosen.
    selectPage = workflow.clickAddItems();
    selectPage.removeItem(fileName1);
    selectPage.addItemFromSite(fileName1, opSite);

    // ---- Step 15 ----
    // ---- Step action ----
    // Click on Cancel button.
    // ---- Expected results ----
    // The window is closed. No data was changed in Selected Items section - no document was added.
    selectPage.selectCancelButton();
    Assert.assertTrue(
        cloudTaskOrReviewPage.isNoItemsSelectedMessagePresent(),
        "Content has been added after canceling Select window");

    // ---- Step 16 ----
    // ---- Step action ----
    // Verify the Remove All button.
    // ----- Expected results ----
    // The button is disabled.
    Assert.assertFalse(
        cloudTaskOrReviewPage.isRemoveAllButtonEnabled(),
        "Button is enabled after canceling Select window");

    // ---- Step 17 ----
    // --- Step action ---
    // Repeat steps 1-9.
    // ---- Expected results ----
    // The latest opened directory is opened in the window (step 2). The previously chosen document
    // is displayed in the Selected Items section (step 2). The
    // document is chosen.
    selectPage = workflow.clickAddItems();
    selectPage.removeItem(fileName1);
    selectPage.addItemFromSite(fileName1, opSite);

    // ---- Step 18 ----
    // --- Step action ---
    // Click on OK button.
    // ---- Expected results ----
    // The window is closed. The data was changed in Selected Items section - the document was
    // added.
    selectPage.selectOKButton();

    List<SelectedWorkFlowItem> selectedWorkFlowItems = workflow.getSelectedItem(fileName1);
    String itemName = selectedWorkFlowItems.get(0).getItemName();
    Assert.assertEquals(itemName, fileName1, "File was not added to workflow.");

    // ---- Step 19 ----
    // --- Step action ---
    // Verify the Remove All button.
    // ---- Expected results ----
    // The button is enabled.
    Assert.assertTrue(
        cloudTaskOrReviewPage.isRemoveAllButtonEnabled(),
        "Remove all button is still disabled after addition file");
  }