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