Ejemplo n.º 1
0
  @Test
  public void listChildPagePaths() throws IOException, GitAPIException {
    register(globalRepoManager.createProjectCentralRepository(PROJECT, USER));
    register(globalRepoManager.createProjectBranchRepository(PROJECT, BRANCH_1, null));
    saveRandomPage(BRANCH_1, DocumentrConstants.HOME_PAGE_NAME + "/foo"); // $NON-NLS-1$
    saveRandomPage(BRANCH_1, DocumentrConstants.HOME_PAGE_NAME + "/foo/bar"); // $NON-NLS-1$
    saveRandomPage(BRANCH_1, DocumentrConstants.HOME_PAGE_NAME + "/foo/bar/baz"); // $NON-NLS-1$
    saveRandomPage(BRANCH_1, DocumentrConstants.HOME_PAGE_NAME + "/foo/qux"); // $NON-NLS-1$

    Set<String> expected =
        Sets.newHashSet(
            DocumentrConstants.HOME_PAGE_NAME + "/foo/bar", // $NON-NLS-1$
            DocumentrConstants.HOME_PAGE_NAME + "/foo/qux"); // $NON-NLS-1$
    Set<String> result =
        Sets.newHashSet(
            pageStore.listChildPagePaths(
                PROJECT, BRANCH_1, DocumentrConstants.HOME_PAGE_NAME + "/foo")); // $NON-NLS-1$
    assertEquals(expected, result);
    expected =
        Collections.singleton(DocumentrConstants.HOME_PAGE_NAME + "/foo/bar/baz"); // $NON-NLS-1$
    result =
        Sets.newHashSet(
            pageStore.listChildPagePaths(
                PROJECT, BRANCH_1, DocumentrConstants.HOME_PAGE_NAME + "/foo/bar")); // $NON-NLS-1$
    assertEquals(expected, result);
  }
Ejemplo n.º 2
0
  @Test
  public void relocatePage() throws IOException, GitAPIException {
    register(globalRepoManager.createProjectCentralRepository(PROJECT, USER));
    ILockedRepository repo =
        globalRepoManager.createProjectBranchRepository(PROJECT, BRANCH_1, null);
    register(repo);
    saveRandomPage(BRANCH_1, "home"); // $NON-NLS-1$
    saveRandomPage(BRANCH_1, "home/foo"); // $NON-NLS-1$
    Page page = saveRandomPage(BRANCH_1, "home/foo/bar"); // $NON-NLS-1$
    saveRandomPage(BRANCH_1, "home/foo/bar/quuux"); // $NON-NLS-1$
    saveRandomPage(BRANCH_1, "home/foo/quux"); // $NON-NLS-1$
    saveRandomPage(BRANCH_1, "home/baz"); // $NON-NLS-1$
    saveRandomPage(BRANCH_1, "home/baz/bar"); // $NON-NLS-1$
    saveRandomPage(BRANCH_1, "home/baz/qux"); // $NON-NLS-1$
    Page attachment =
        saveRandomAttachment(BRANCH_1, "home/foo/bar", "test.txt"); // $NON-NLS-1$ //$NON-NLS-2$
    saveRandomAttachment(BRANCH_1, "home/baz/bar", "test.txt"); // $NON-NLS-1$ //$NON-NLS-2$

    pageStore.relocatePage(
        PROJECT, BRANCH_1, "home/foo/bar", "home/baz", USER); // $NON-NLS-1$ //$NON-NLS-2$
    assertEquals(
        Sets.newHashSet("home/foo/quux"), // $NON-NLS-1$
        Sets.newHashSet(
            pageStore.listChildPagePaths(PROJECT, BRANCH_1, "home/foo"))); // $NON-NLS-1$
    assertEquals(
        Sets.newHashSet("home/baz/bar", "home/baz/qux"), // $NON-NLS-1$ //$NON-NLS-2$
        Sets.newHashSet(
            pageStore.listChildPagePaths(PROJECT, BRANCH_1, "home/baz"))); // $NON-NLS-1$
    assertEquals(
        Sets.newHashSet("home/baz/bar/quuux"), // $NON-NLS-1$
        Sets.newHashSet(
            pageStore.listChildPagePaths(PROJECT, BRANCH_1, "home/baz/bar"))); // $NON-NLS-1$
    assertEquals(
        page.getData(),
        pageStore.getPage(PROJECT, BRANCH_1, "home/baz/bar", true).getData()); // $NON-NLS-1$
    assertEquals(
        attachment.getData(),
        pageStore
            .getAttachment(PROJECT, BRANCH_1, "home/baz/bar", "test.txt")
            .getData()); //$NON-NLS-1$ //$NON-NLS-2$

    assertClean(repo.r());
  }
Ejemplo n.º 3
0
  @Test
  public void deletePage() throws IOException, GitAPIException {
    register(globalRepoManager.createProjectCentralRepository(PROJECT, USER));
    ILockedRepository repo =
        globalRepoManager.createProjectBranchRepository(PROJECT, BRANCH_1, null);
    register(repo);
    saveRandomPage(BRANCH_1, "home"); // $NON-NLS-1$
    saveRandomPage(BRANCH_1, "home/foo"); // $NON-NLS-1$
    saveRandomAttachment(BRANCH_1, "home/foo", "test.txt"); // $NON-NLS-1$ //$NON-NLS-2$
    saveRandomPage(BRANCH_1, "home/foo/bar"); // $NON-NLS-1$
    File pageFile =
        new File(
            new File(new File(RepositoryUtil.getWorkingDir(repo.r()), "pages"), "home"),
            "foo.page"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    File metaFile =
        new File(
            new File(new File(RepositoryUtil.getWorkingDir(repo.r()), "pages"), "home"),
            "foo.meta"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    File subPagesDir =
        new File(
            new File(new File(RepositoryUtil.getWorkingDir(repo.r()), "pages"), "home"),
            "foo"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    File attachmentsDir =
        new File(
            new File(new File(RepositoryUtil.getWorkingDir(repo.r()), "attachments"), "home"),
            "foo"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    assertTrue(pageFile.isFile());
    assertTrue(metaFile.isFile());
    assertTrue(subPagesDir.isDirectory());
    assertTrue(attachmentsDir.isDirectory());

    pageStore.deletePage(PROJECT, BRANCH_1, "home/foo", USER); // $NON-NLS-1$
    List<String> result = pageStore.listChildPagePaths(PROJECT, BRANCH_1, "home"); // $NON-NLS-1$
    assertTrue(result.isEmpty());
    assertFalse(pageFile.exists());
    assertFalse(metaFile.exists());
    assertFalse(subPagesDir.exists());
    assertFalse(attachmentsDir.exists());

    assertClean(repo.r());
  }