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()));
}
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;
}
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());
}
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));
}
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());
}
Aggregations