示例#1
0
  private void prepare() throws UserNotConnectedException, IOException {
    DocumentBasePage documentBasePage;
    DocumentBasePage s = login();

    // Create a new user if not exist
    UsersGroupsBasePage page;
    UsersTabSubPage usersTab = s.getAdminCenter().getUsersGroupsHomePage().getUsersTab();
    usersTab = usersTab.searchUser(TEST_USERNAME);
    if (!usersTab.isUserFound(TEST_USERNAME)) {
      page =
          usersTab
              .getUserCreatePage()
              .createUser(
                  TEST_USERNAME,
                  TEST_USERNAME,
                  null,
                  null,
                  TEST_USERNAME,
                  TEST_PASSWORD,
                  "members");
      usersTab = page.getUsersTab(true);
    } // search user usersTab =
    usersTab.searchUser(TEST_USERNAME);
    assertTrue(usersTab.isUserFound(TEST_USERNAME));

    // create a wokspace1 and grant all rights to the test user
    documentBasePage =
        usersTab
            .exitAdminCenter()
            .getHeaderLinks()
            .getNavigationSubPage()
            .goToDocument("Workspaces");
    DocumentBasePage workspacePage = createWorkspace(documentBasePage, WORKSPACE1_TITLE, null);
    PermissionsSubPage permissionsSubPage = workspacePage.getPermissionsTab();
    // Need Read
    if (!permissionsSubPage.hasPermissionForUser("Read", TEST_USERNAME)) {
      permissionsSubPage.grantPermissionForUser("Read", TEST_USERNAME);
    }
    // Create test File 1
    createFile(workspacePage, FILE1_NAME, null, false, null, null, null);

    workspacePage.getHeaderLinks().getNavigationSubPage().goToDocument("Workspaces");
    workspacePage = createWorkspace(documentBasePage, WORKSPACE2_TITLE, null);
    permissionsSubPage = workspacePage.getPermissionsTab();
    if (!permissionsSubPage.hasPermissionForUser("Manage everything", TEST_USERNAME)) {
      permissionsSubPage.grantPermissionForUser("Manage everything", TEST_USERNAME);
    }

    logout();
  }
示例#2
0
  /**
   * Test trash management.
   *
   * @since 7.1
   */
  @Test
  public void testTrashPurge() throws UserNotConnectedException, IOException {
    DocumentBasePage documentBasePage = login();

    // Create a file under workspace.
    DocumentBasePage workspacePage = documentBasePage.createWorkspace(WORKSPACE_TITLE, null);
    DocumentBasePage filePage =
        workspacePage.createFile(TEST_FILE_TITLE, null, false, null, null, null);

    // Copy/paste it to get 5 files.
    ContentTabSubPage content =
        filePage
            .getHeaderLinks()
            .getNavigationSubPage()
            .goToDocument(WORKSPACE_TITLE)
            .getContentTab()
            .copyByTitle(TEST_FILE_TITLE)
            .paste()
            .paste()
            .paste()
            .paste();

    List<WebElement> docs = content.getChildDocumentRows();
    assertNotNull(docs);
    assertEquals(5, docs.size());
    // Select all files and remove them.
    docs = content.removeAllDocuments().getChildDocumentRows();
    assertNotNull(docs);
    assertEquals(0, docs.size());

    // Go to trash page.
    TrashSubPage trashSubPage = asPage(DocumentBasePage.class).getManageTab().getTrashSubTab();
    docs = trashSubPage.getChildDocumentRows();
    assertNotNull(docs);
    assertEquals(5, docs.size());

    // Empty the trash.
    docs = trashSubPage.emptyTrash().getChildDocumentRows();
    assertNotNull(docs);
    assertEquals(0, docs.size());

    // cleanup workspace
    asPage(DocumentBasePage.class).getNavigationSubPage().goToDocument("Workspaces");
    asPage(ContentTabSubPage.class).removeDocument(WORKSPACE_TITLE);
  }