Search in sources :

Example 6 with FindNodesByMultiRepoQueryResult

use of com.enonic.xp.node.FindNodesByMultiRepoQueryResult in project xp by enonic.

the class FindNodesByMultiRepoQueryCommandTest method no_access_in_one_repo.

@Test
public void no_access_in_one_repo() throws Exception {
    final Repository repo1 = createRepo(REPO_USER_1, "repo1");
    final Repository repo2 = createRepo(REPO_USER_2, "repo2");
    runInContext(REPO_USER_1, repo1.getId(), () -> createNode(NodePath.ROOT, "repo1Node"));
    runInContext(REPO_USER_2, repo2.getId(), () -> createNode(NodePath.ROOT, "repo2Node"));
    final SearchTargets targets = SearchTargets.create().add(createTarget(MASTER_BRANCH, REPO_USER_1, repo1.getId())).add(// repoUser2 has no access
    createTarget(MASTER_BRANCH, REPO_USER_1, repo2.getId())).build();
    final NodeQuery query = NodeQuery.create().parent(NodePath.ROOT).build();
    final FindNodesByMultiRepoQueryResult result = doQuery(query, targets);
    assertEquals(1L, result.getTotalHits());
    assertRepos(result, repo1.getId());
    assertBranches(result, MASTER_BRANCH);
}
Also used : FindNodesByMultiRepoQueryResult(com.enonic.xp.node.FindNodesByMultiRepoQueryResult) Repository(com.enonic.xp.repository.Repository) MultiRepoNodeQuery(com.enonic.xp.node.MultiRepoNodeQuery) NodeQuery(com.enonic.xp.node.NodeQuery) SearchTargets(com.enonic.xp.node.SearchTargets) Test(org.junit.jupiter.api.Test)

Example 7 with FindNodesByMultiRepoQueryResult

use of com.enonic.xp.node.FindNodesByMultiRepoQueryResult in project xp by enonic.

the class FindNodesByMultiRepoQueryCommandTest method no_access_in_one_repo_of_three.

@Test
public void no_access_in_one_repo_of_three() throws Exception {
    final Repository repo1 = createRepo(REPO_USER_1, "repo1");
    final Repository repo2 = createRepo(REPO_USER_2, "repo2");
    final Repository repo3 = createRepo(REPO_USER_3, "repo3");
    runInContext(REPO_USER_1, repo1.getId(), () -> createNode(NodePath.ROOT, "repo1Node"));
    runInContext(REPO_USER_2, repo2.getId(), () -> createNode(NodePath.ROOT, "repo2Node"));
    runInContext(REPO_USER_3, repo3.getId(), () -> createNode(NodePath.ROOT, "repo2Node"));
    final SearchTargets targets = SearchTargets.create().add(createTarget(MASTER_BRANCH, REPO_USER_1, repo1.getId())).add(createTarget(MASTER_BRANCH, REPO_USER_2, repo2.getId())).add(// repoUser1 has no access
    createTarget(MASTER_BRANCH, REPO_USER_1, repo3.getId())).build();
    final NodeQuery query = NodeQuery.create().parent(NodePath.ROOT).build();
    final FindNodesByMultiRepoQueryResult result = doQuery(query, targets);
    assertEquals(2L, result.getTotalHits());
    assertRepos(result, repo1.getId(), repo2.getId());
    assertBranches(result, MASTER_BRANCH);
}
Also used : FindNodesByMultiRepoQueryResult(com.enonic.xp.node.FindNodesByMultiRepoQueryResult) Repository(com.enonic.xp.repository.Repository) MultiRepoNodeQuery(com.enonic.xp.node.MultiRepoNodeQuery) NodeQuery(com.enonic.xp.node.NodeQuery) SearchTargets(com.enonic.xp.node.SearchTargets) Test(org.junit.jupiter.api.Test)

Aggregations

FindNodesByMultiRepoQueryResult (com.enonic.xp.node.FindNodesByMultiRepoQueryResult)7 MultiRepoNodeQuery (com.enonic.xp.node.MultiRepoNodeQuery)6 NodeQuery (com.enonic.xp.node.NodeQuery)6 Test (org.junit.jupiter.api.Test)6 SearchTargets (com.enonic.xp.node.SearchTargets)5 Repository (com.enonic.xp.repository.Repository)5 Branch (com.enonic.xp.branch.Branch)2 Node (com.enonic.xp.node.Node)2 JsonMapGenerator (com.enonic.xp.script.serializer.JsonMapGenerator)1