Search in sources :

Example 56 with RepositoryId

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

the class ProjectServiceImplTest method create_with_content_admin_permissions.

@Test
void create_with_content_admin_permissions() {
    final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
    final Project project = contentAdminContext().callWith(() -> doCreateProject(ProjectName.from(projectRepoId)));
    assertNotNull(project);
}
Also used : Project(com.enonic.xp.project.Project) RepositoryId(com.enonic.xp.repository.RepositoryId) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 57 with RepositoryId

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

the class ProjectServiceImplTest method create_without_permissions.

@Test
void create_without_permissions() {
    final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
    final RuntimeException ex = Assertions.assertThrows(RuntimeException.class, () -> doCreateProject(ProjectName.from(projectRepoId)));
    assertEquals("Denied [user:system:test-user] user access for [create] operation", ex.getMessage());
}
Also used : RepositoryId(com.enonic.xp.repository.RepositoryId) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 58 with RepositoryId

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

the class ProjectServiceImplTest method create_with_data.

@Test
void create_with_data() {
    final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
    final String displayName = "test display name";
    final String description = "test description";
    final PropertyTree data = new PropertyTree();
    final PropertySet projectData = data.addSet(ProjectConstants.PROJECT_DATA_SET_NAME);
    projectData.setString(ProjectConstants.PROJECT_DISPLAY_NAME_PROPERTY, displayName);
    projectData.setString(ProjectConstants.PROJECT_DESCRIPTION_PROPERTY, description);
    adminContext().callWith(() -> doCreateProject(ProjectName.from(projectRepoId), displayName, description));
    adminContext().runWith(() -> {
        final Repository projectRepo = repositoryService.get(projectRepoId);
        assertEquals(data, projectRepo.getData());
    });
}
Also used : Repository(com.enonic.xp.repository.Repository) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) RepositoryId(com.enonic.xp.repository.RepositoryId) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 59 with RepositoryId

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

the class GetRepositoryScriptTest method initialize.

@Override
public void initialize() throws Exception {
    super.initialize();
    repositoryService = Mockito.mock(RepositoryService.class);
    Mockito.when(repositoryService.get(Mockito.any())).thenAnswer(invocation -> {
        final RepositoryId repositoryId = (RepositoryId) invocation.getArguments()[0];
        return Repository.create().id(repositoryId).branches(Branches.from(RepositoryConstants.MASTER_BRANCH)).build();
    });
    addService(RepositoryService.class, repositoryService);
}
Also used : RepositoryId(com.enonic.xp.repository.RepositoryId) RepositoryService(com.enonic.xp.repository.RepositoryService)

Example 60 with RepositoryId

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

the class DeleteBranchHandler method doDeleteBranch.

private BranchMapper doDeleteBranch() {
    final RepositoryId repositoryId = ContextAccessor.current().getRepositoryId();
    if (isProtectedBranch(repositoryId, Branch.from(this.branchId))) {
        throw new RepositoryExeption("No allowed to delete branch [" + this.branchId + "] in repository [" + repositoryId + "]");
    }
    final DeleteBranchParams deleteBranchParams = DeleteBranchParams.from(branchId);
    final Branch deletedBranch = repositoryServiceSupplier.get().deleteBranch(deleteBranchParams);
    return deletedBranch == null ? null : new BranchMapper(deletedBranch);
}
Also used : RepositoryExeption(com.enonic.xp.repository.RepositoryExeption) Branch(com.enonic.xp.branch.Branch) RepositoryId(com.enonic.xp.repository.RepositoryId) DeleteBranchParams(com.enonic.xp.repository.DeleteBranchParams) BranchMapper(com.enonic.xp.lib.repo.mapper.BranchMapper)

Aggregations

RepositoryId (com.enonic.xp.repository.RepositoryId)61 Test (org.junit.jupiter.api.Test)21 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)19 Branch (com.enonic.xp.branch.Branch)14 Repository (com.enonic.xp.repository.Repository)11 Node (com.enonic.xp.node.Node)9 ByteSource (com.google.common.io.ByteSource)8 IOException (java.io.IOException)7 PropertyTree (com.enonic.xp.data.PropertyTree)6 Segment (com.enonic.xp.blob.Segment)5 Context (com.enonic.xp.context.Context)5 ContextAccessor (com.enonic.xp.context.ContextAccessor)5 ContextBuilder (com.enonic.xp.context.ContextBuilder)5 BlobKey (com.enonic.xp.blob.BlobKey)4 EventPublisher (com.enonic.xp.event.EventPublisher)4 BinaryAttachment (com.enonic.xp.node.BinaryAttachment)4 Project (com.enonic.xp.project.Project)4 DumpConstants (com.enonic.xp.repo.impl.dump.DumpConstants)4 DumpBlobRecord (com.enonic.xp.repo.impl.dump.blobstore.DumpBlobRecord)4 RepositoryIds (com.enonic.xp.repository.RepositoryIds)4