Search in sources :

Example 26 with Repository

use of com.enonic.xp.repository.Repository in project xp by enonic.

the class DumpServiceImplTest method obsolete_repository_deleted.

@Test
public void obsolete_repository_deleted() throws Exception {
    final AccessControlList newRepoACL = AccessControlList.create().add(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allowAll().build()).build();
    final Repository newRepoInsideDump = NodeHelper.runAsAdmin(() -> doCreateRepository(RepositoryId.from("new-repo-inside-dump"), newRepoACL, ChildOrder.manualOrder()));
    NodeHelper.runAsAdmin(() -> doDump(SystemDumpParams.create().dumpName("myTestDump").build()));
    final Repository newRepoOutsideDump = NodeHelper.runAsAdmin(() -> doCreateRepository(RepositoryId.from("new-repo-outside-dump"), newRepoACL, ChildOrder.manualOrder()));
    final Repositories oldRepos = NodeHelper.runAsAdmin(this::doListRepositories);
    NodeHelper.runAsAdmin(this::doLoad);
    final Repositories newRepos = NodeHelper.runAsAdmin(this::doListRepositories);
    assertEquals(6, oldRepos.getIds().getSize());
    assertEquals(5, newRepos.getIds().getSize());
    assertNotNull(newRepos.getRepositoryById(newRepoInsideDump.getId()));
    assertNull(newRepos.getRepositoryById(newRepoOutsideDump.getId()));
}
Also used : AccessControlList(com.enonic.xp.security.acl.AccessControlList) Repositories(com.enonic.xp.repository.Repositories) Repository(com.enonic.xp.repository.Repository) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 27 with Repository

use of com.enonic.xp.repository.Repository in project xp by enonic.

the class DumpServiceImplTest method doCreateRepository.

private Repository doCreateRepository(final RepositoryId repositoryId, final AccessControlList permissions, final ChildOrder childOrder) {
    final CreateRepositoryParams params = CreateRepositoryParams.create().repositoryId(repositoryId).data(new PropertyTree()).build();
    this.nodeRepositoryService.create(params);
    final Repository createRepositoryParams = Repository.create().id(repositoryId).branches(Branches.from(RepositoryConstants.MASTER_BRANCH)).build();
    this.repositoryEntryService.createRepositoryEntry(createRepositoryParams);
    final Repository repo = this.repositoryEntryService.getRepositoryEntry(repositoryId);
    createRootNode(repositoryId, permissions, childOrder);
    return repo;
}
Also used : CreateRepositoryParams(com.enonic.xp.repository.CreateRepositoryParams) Repository(com.enonic.xp.repository.Repository) PropertyTree(com.enonic.xp.data.PropertyTree)

Example 28 with Repository

use of com.enonic.xp.repository.Repository in project xp by enonic.

the class DumpServiceImplTest method root_node_gets_correct_properties.

@Test
public void root_node_gets_correct_properties() throws Exception {
    final AccessControlList newRepoACL = AccessControlList.create().add(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allowAll().build()).build();
    final Repository newRepo = NodeHelper.runAsAdmin(() -> doCreateRepository(RepositoryId.from("my-new-repo"), newRepoACL, ChildOrder.manualOrder()));
    final Context newContext = ContextBuilder.from(ContextAccessor.current()).repositoryId(newRepo.getId()).branch(RepositoryConstants.MASTER_BRANCH).build();
    newContext.runWith(() -> createNode(NodePath.ROOT, "myNode"));
    NodeHelper.runAsAdmin(() -> dumpDeleteAndLoad(true));
    final Node loadedRootNode = newContext.callWith(() -> this.nodeService.getRoot());
    assertEquals(newRepoACL, loadedRootNode.getPermissions());
}
Also used : AccessControlList(com.enonic.xp.security.acl.AccessControlList) BundleContext(org.osgi.framework.BundleContext) Context(com.enonic.xp.context.Context) InternalContext(com.enonic.xp.repo.impl.InternalContext) Repository(com.enonic.xp.repository.Repository) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 29 with Repository

use of com.enonic.xp.repository.Repository in project xp by enonic.

the class RepositoryServiceImplTest method delete_branch_deletes_from_repo.

@Test
void delete_branch_deletes_from_repo() {
    doCreateRepo("fisk");
    Branch branch = Branch.from("myBranch");
    NodeHelper.runAsAdmin(() -> repositoryService.createBranch(CreateBranchParams.from(branch)));
    NodeHelper.runAsAdmin(() -> repositoryService.deleteBranch(DeleteBranchParams.from(branch)));
    final Repository persistedRepo = getPersistedRepoWithoutCache("fisk");
    assertFalse(persistedRepo.getBranches().contains(branch));
}
Also used : Repository(com.enonic.xp.repository.Repository) Branch(com.enonic.xp.branch.Branch) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 30 with Repository

use of com.enonic.xp.repository.Repository in project xp by enonic.

the class RepositoryServiceImplTest method create_default_acl.

@Test
void create_default_acl() {
    final Repository repo = doCreateRepo("fisk");
    assertNotNull(repo);
    assertEquals(RepositoryId.from("fisk"), repo.getId());
    final Node rootNode = createAdminContext().callWith(() -> this.nodeService.getRoot());
    final AccessControlList acl = rootNode.getPermissions();
    System.out.println(acl.toString());
}
Also used : AccessControlList(com.enonic.xp.security.acl.AccessControlList) Repository(com.enonic.xp.repository.Repository) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

Repository (com.enonic.xp.repository.Repository)40 Test (org.junit.jupiter.api.Test)21 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)15 RepositoryId (com.enonic.xp.repository.RepositoryId)10 Node (com.enonic.xp.node.Node)9 Branch (com.enonic.xp.branch.Branch)8 PropertyTree (com.enonic.xp.data.PropertyTree)7 Context (com.enonic.xp.context.Context)6 FindNodesByMultiRepoQueryResult (com.enonic.xp.node.FindNodesByMultiRepoQueryResult)5 MultiRepoNodeQuery (com.enonic.xp.node.MultiRepoNodeQuery)5 NodeQuery (com.enonic.xp.node.NodeQuery)5 SearchTargets (com.enonic.xp.node.SearchTargets)5 ContextAccessor (com.enonic.xp.context.ContextAccessor)4 ContextBuilder (com.enonic.xp.context.ContextBuilder)4 CreateRepositoryParams (com.enonic.xp.repository.CreateRepositoryParams)4 RepositoryService (com.enonic.xp.repository.RepositoryService)4 SystemLoadResult (com.enonic.xp.dump.SystemLoadResult)3 BinaryAttachment (com.enonic.xp.node.BinaryAttachment)3 NodeService (com.enonic.xp.node.NodeService)3 Project (com.enonic.xp.project.Project)3