Search in sources :

Example 21 with Branch

use of com.enonic.xp.branch.Branch in project xp by enonic.

the class BranchAclEntryTest method equals.

@Test
public void equals() throws Exception {
    final Branch branch = Branch.from("fisk");
    final PrincipalKeys keys = PrincipalKeys.from(PrincipalKey.ofRole("fisk"));
    final BranchAclEntry entry1 = new BranchAclEntry(branch, keys);
    final BranchAclEntry entry2 = new BranchAclEntry(branch, keys);
    assertEquals(entry1, entry2);
}
Also used : PrincipalKeys(com.enonic.xp.security.PrincipalKeys) Branch(com.enonic.xp.branch.Branch) Test(org.junit.jupiter.api.Test)

Example 22 with Branch

use of com.enonic.xp.branch.Branch in project xp by enonic.

the class FindNodesByMultiRepoQueryCommandTest method multi_repo_search_different_branches.

@Test
public void multi_repo_search_different_branches() throws Exception {
    final Repository repo1 = createRepo(REPO_USER_1, "repo1");
    final Repository repo2 = createRepo(REPO_USER_2, "repo2");
    // Create new branch in repo1
    final Branch otherBranch = callInContext(REPO_USER_1, repo1.getId(), MASTER_BRANCH, () -> createBranch("otherBranch"));
    final Node repo1MasterNode1 = callInContext(REPO_USER_1, repo1.getId(), MASTER_BRANCH, () -> createNode(NodePath.ROOT, "repo1Node"));
    final Node repo1OtherNode1 = callInContext(REPO_USER_1, repo1.getId(), otherBranch, () -> createNode(NodePath.ROOT, "repo1Node"));
    final Node repo2MasterNode1 = callInContext(REPO_USER_2, repo2.getId(), MASTER_BRANCH, () -> createNode(NodePath.ROOT, "repo2Node"));
    final SearchTargets targets = SearchTargets.create().add(createTarget(otherBranch, REPO_USER_1, repo1.getId())).add(createTarget(MASTER_BRANCH, REPO_USER_2, repo2.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, otherBranch);
    assertNodes(result, repo1OtherNode1.id(), repo2MasterNode1.id());
}
Also used : FindNodesByMultiRepoQueryResult(com.enonic.xp.node.FindNodesByMultiRepoQueryResult) Repository(com.enonic.xp.repository.Repository) Branch(com.enonic.xp.branch.Branch) Node(com.enonic.xp.node.Node) 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 23 with Branch

use of com.enonic.xp.branch.Branch in project xp by enonic.

the class FindNodesByMultiRepoQueryCommandTest method multi_repo_search_different_branches_same_repo.

@Test
public void multi_repo_search_different_branches_same_repo() throws Exception {
    final Repository repo1 = createRepo(REPO_USER_1, "repo1");
    final Repository repo2 = createRepo(REPO_USER_2, "repo2");
    // Create new branch in repo1
    final Branch otherBranch = callInContext(REPO_USER_1, repo1.getId(), MASTER_BRANCH, () -> createBranch("otherBranch"));
    final Node repo1MasterNode1 = callInContext(REPO_USER_1, repo1.getId(), MASTER_BRANCH, () -> createNode(NodePath.ROOT, "repo1Node"));
    final Node repo1OtherNode1 = callInContext(REPO_USER_1, repo1.getId(), otherBranch, () -> createNode(NodePath.ROOT, "repo1Node"));
    final Node repo2MasterNode1 = callInContext(REPO_USER_2, repo2.getId(), MASTER_BRANCH, () -> createNode(NodePath.ROOT, "repo2Node"));
    final SearchTargets targets = SearchTargets.create().add(createTarget(otherBranch, REPO_USER_1, repo1.getId())).add(createTarget(MASTER_BRANCH, REPO_USER_1, repo1.getId())).add(createTarget(MASTER_BRANCH, REPO_USER_2, repo2.getId())).build();
    final NodeQuery query = NodeQuery.create().parent(NodePath.ROOT).build();
    final FindNodesByMultiRepoQueryResult result = doQuery(query, targets);
    assertEquals(3L, result.getTotalHits());
    assertRepos(result, repo1.getId(), repo2.getId());
    assertBranches(result, MASTER_BRANCH, otherBranch);
    assertNodes(result, repo1OtherNode1.id(), repo1MasterNode1.id(), repo2MasterNode1.id());
}
Also used : FindNodesByMultiRepoQueryResult(com.enonic.xp.node.FindNodesByMultiRepoQueryResult) Repository(com.enonic.xp.repository.Repository) Branch(com.enonic.xp.branch.Branch) Node(com.enonic.xp.node.Node) 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 24 with Branch

use of com.enonic.xp.branch.Branch in project xp by enonic.

the class FindNodesByMultiRepoQueryCommandTest method assertBranches.

private void assertBranches(final FindNodesByMultiRepoQueryResult result, final Branch... branches) {
    final MultiRepoNodeHits nodeHits = result.getNodeHits();
    final Set<Branch> resultBranches = nodeHits.stream().map(MultiRepoNodeHit::getBranch).collect(Collectors.toSet());
    assertEquals(branches.length, resultBranches.size(), "Wrong number of branches in result");
    for (final Branch branch : resultBranches) {
        assertTrue(resultBranches.contains(branch), "missing repo '" + branch + "' in result set");
    }
}
Also used : Branch(com.enonic.xp.branch.Branch) MultiRepoNodeHits(com.enonic.xp.node.MultiRepoNodeHits)

Example 25 with Branch

use of com.enonic.xp.branch.Branch in project xp by enonic.

the class RepositoryServiceImplTest method update_data.

@Test
void update_data() {
    final String repoId = "repo-with-data";
    doCreateRepo(repoId);
    Context mockCurrentContext = ContextBuilder.create().branch("master").repositoryId(repoId).authInfo(REPO_TEST_DEFAULT_USER_AUTHINFO).build();
    PropertyTree data = new PropertyTree();
    data.setString("myProp", "b");
    mockCurrentContext.callWith(() -> repositoryService.updateRepository(UpdateRepositoryParams.create().repositoryId(RepositoryId.from(repoId)).editor(edit -> edit.data = data).build()));
    final Repository persistedRepo = getPersistedRepoWithoutCache(repoId);
    assertEquals("b", persistedRepo.getData().getString("myProp"));
}
Also used : Context(com.enonic.xp.context.Context) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) IdProviderKey(com.enonic.xp.security.IdProviderKey) CreateNodeParams(com.enonic.xp.node.CreateNodeParams) DeleteRepositoryParams(com.enonic.xp.repository.DeleteRepositoryParams) Node(com.enonic.xp.node.Node) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Branch(com.enonic.xp.branch.Branch) NodeHelper(com.enonic.xp.repo.impl.node.NodeHelper) RepositoryId(com.enonic.xp.repository.RepositoryId) ImmutableList(com.google.common.collect.ImmutableList) CreateBranchParams(com.enonic.xp.repository.CreateBranchParams) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ContextAccessor(com.enonic.xp.context.ContextAccessor) ContextBuilder(com.enonic.xp.context.ContextBuilder) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ByteSource(com.google.common.io.ByteSource) SystemConstants(com.enonic.xp.security.SystemConstants) PropertyTree(com.enonic.xp.data.PropertyTree) BinaryReference(com.enonic.xp.util.BinaryReference) DeleteBranchParams(com.enonic.xp.repository.DeleteBranchParams) User(com.enonic.xp.security.User) BinaryAttachment(com.enonic.xp.node.BinaryAttachment) NodePath(com.enonic.xp.node.NodePath) AuthenticationInfo(com.enonic.xp.security.auth.AuthenticationInfo) AccessControlList(com.enonic.xp.security.acl.AccessControlList) CreateRepositoryParams(com.enonic.xp.repository.CreateRepositoryParams) UpdateRepositoryParams(com.enonic.xp.repository.UpdateRepositoryParams) Test(org.junit.jupiter.api.Test) PrincipalKey(com.enonic.xp.security.PrincipalKey) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) RoleKeys(com.enonic.xp.security.RoleKeys) Context(com.enonic.xp.context.Context) Assertions.assertDoesNotThrow(org.junit.jupiter.api.Assertions.assertDoesNotThrow) AccessControlEntry(com.enonic.xp.security.acl.AccessControlEntry) Repository(com.enonic.xp.repository.Repository) Repository(com.enonic.xp.repository.Repository) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

Branch (com.enonic.xp.branch.Branch)52 Test (org.junit.jupiter.api.Test)19 Node (com.enonic.xp.node.Node)13 RepositoryId (com.enonic.xp.repository.RepositoryId)12 Context (com.enonic.xp.context.Context)10 NodeId (com.enonic.xp.node.NodeId)8 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)8 Repository (com.enonic.xp.repository.Repository)7 ContextAccessor (com.enonic.xp.context.ContextAccessor)5 ContextBuilder (com.enonic.xp.context.ContextBuilder)5 ContentId (com.enonic.xp.content.ContentId)4 PropertyTree (com.enonic.xp.data.PropertyTree)4 CreateBranchParams (com.enonic.xp.repository.CreateBranchParams)4 ContentConstants (com.enonic.xp.content.ContentConstants)3 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)3 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)3 GetActiveNodeVersionsResult (com.enonic.xp.node.GetActiveNodeVersionsResult)3 NodeIds (com.enonic.xp.node.NodeIds)3 NodePath (com.enonic.xp.node.NodePath)3 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)3