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);
  }
  /** 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");
  }
  @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: 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");
  }
  /** 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(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();
  }
  /** 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);
  }
  /** 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.");
 }