use of com.enonic.xp.project.ProjectName in project xp by enonic.
the class ProjectsSyncTaskTest method order.
@Test
void order() {
final Projects projects = Projects.create().addAll(Set.of(createProject("turkey-tr-tr", "turkey-tr"), createProject("enonic-common", null), createProject("corporate", "enonic-common"), createProject("corporate-no", "corporate"), createProject("countries", "enonic-common"), createProject("denmark", "countries"), createProject("without-actual-parent1", "unknown-parent1"), createProject("denmark-de", "denmark"), createProject("sweden", "countries"), createProject("sweden-sw", "sweden"), createProject("sweden-sw-sw", "sweden-sw"), createProject("root1", null), createProject("child1", "root1"), createProject("without-actual-parent2", "unknown-parent2"), createProject("turkey", "countries"), createProject("turkey-tr", "turkey"))).build();
when(projectService.list()).thenReturn(projects);
ProjectsSyncTask.create().projectService(projectService).syncContentService(syncContentService).build().run(TaskId.from("taskId"), mock(ProgressReporter.class, withSettings().stubOnly()));
verify(syncContentService, times(14)).syncProject(paramsCaptor.capture());
final List<ProjectName> syncProjects = paramsCaptor.getAllValues().stream().map(ProjectSyncParams::getTargetProject).collect(Collectors.toList());
assertAll(() -> assertThat(syncProjects.indexOf(ProjectName.from("turkey-tr-tr"))).isGreaterThan(syncProjects.indexOf(ProjectName.from("turkey-tr"))), () -> assertThat(syncProjects.indexOf(ProjectName.from("turkey-tr"))).isGreaterThan(syncProjects.indexOf(ProjectName.from("turkey"))), () -> assertThat(syncProjects.indexOf(ProjectName.from("turkey"))).isGreaterThan(syncProjects.indexOf(ProjectName.from("countries"))), () -> assertThat(syncProjects.indexOf(ProjectName.from("corporate-no"))).isGreaterThan(syncProjects.indexOf(ProjectName.from("corporate"))), () -> assertThat(syncProjects.indexOf(ProjectName.from("denmark-de"))).isGreaterThan(syncProjects.indexOf(ProjectName.from("denmark"))), () -> assertThat(syncProjects.indexOf(ProjectName.from("denmark"))).isGreaterThan(syncProjects.indexOf(ProjectName.from("countries"))), () -> assertThat(syncProjects.indexOf(ProjectName.from("sweden-sw-sw"))).isGreaterThan(syncProjects.indexOf(ProjectName.from("sweden-sw"))), () -> assertThat(syncProjects.indexOf(ProjectName.from("sweden-sw"))).isGreaterThan(syncProjects.indexOf(ProjectName.from("sweden"))), () -> assertThat(syncProjects.indexOf(ProjectName.from("sweden"))).isGreaterThan(syncProjects.indexOf(ProjectName.from("countries"))), () -> assertThat(syncProjects.indexOf(ProjectName.from("child1"))).isGreaterThan(syncProjects.indexOf(ProjectName.from("root1"))), () -> assertThat(syncProjects.indexOf(ProjectName.from("without-actual-parent1"))).isGreaterThanOrEqualTo(12), () -> assertThat(syncProjects.indexOf(ProjectName.from("without-actual-parent2"))).isGreaterThanOrEqualTo(12), () -> assertThat(syncProjects).doesNotContain(ProjectName.from("enoic-common"), ProjectName.from("root1")));
}
use of com.enonic.xp.project.ProjectName in project xp by enonic.
the class SyncContentServiceImplTest method resetWithRemovedSource.
@Test
public void resetWithRemovedSource() throws Exception {
final Content source = sourceContext.callWith(() -> createContent(ContentPath.ROOT));
syncCreated(source.getId());
targetContext.runWith(() -> {
contentService.update(new UpdateContentParams().contentId(source.getId()).editor(edit -> {
edit.workflowInfo = WorkflowInfo.ready();
edit.data = new PropertyTree();
}));
});
sourceContext.runWith(() -> contentService.deleteWithoutFetch(DeleteContentParams.create().contentPath(source.getPath()).build()));
assertThrows(IllegalArgumentException.class, () -> syncContentService.resetInheritance(ResetContentInheritParams.create().contentId(source.getId()).inherit(EnumSet.of(ContentInheritType.CONTENT)).projectName(targetProject.getName()).build()));
}
use of com.enonic.xp.project.ProjectName in project xp by enonic.
the class ProjectServiceImplTest method delete_with_custom_permissions.
@Test
void delete_with_custom_permissions() {
final ProjectName projectName = ProjectName.from("test-project");
doCreateProjectAsAdmin(projectName);
adminContext().runWith(() -> assertNotNull(this.projectService.get(projectName)));
contentCustomManagerContext().runWith(() -> {
final RuntimeException ex = Assertions.assertThrows(RuntimeException.class, () -> projectService.delete(projectName));
assertEquals("Denied [user:system:custom-user] user access for [delete] operation", ex.getMessage());
});
}
use of com.enonic.xp.project.ProjectName in project xp by enonic.
the class ProjectServiceImplTest method create_project_with_public_readAccess.
@Test
void create_project_with_public_readAccess() {
final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
final ProjectName projectName = ProjectName.from(projectRepoId);
adminContext().callWith(() -> doCreateProject(projectName, null, false, null, AccessControlList.create().add(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allow(Permission.READ).build()).build()));
ContextBuilder.from(adminContext()).branch(ContentConstants.BRANCH_DRAFT).repositoryId(projectRepoId).build().runWith(() -> {
final Node rootContentNode = nodeService.getByPath(ContentConstants.CONTENT_ROOT_PATH);
final AccessControlList rootContentPermissions = rootContentNode.getPermissions();
assertTrue(rootContentPermissions.getEntry(RoleKeys.EVERYONE).isAllowed(Permission.READ));
});
}
use of com.enonic.xp.project.ProjectName in project xp by enonic.
the class ProjectServiceImplTest method create_with_root_content_permissions.
@Test
void create_with_root_content_permissions() {
final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
final ProjectName projectName = ProjectName.from(projectRepoId);
doCreateProjectAsAdmin(projectName);
List.of(ContextBuilder.from(adminContext()).branch(ContentConstants.BRANCH_DRAFT).repositoryId(projectRepoId).build(), ContextBuilder.from(adminContext()).branch(ContentConstants.BRANCH_MASTER).repositoryId(projectRepoId).build()).forEach(context -> context.runWith(() -> {
final Node rootContentNode = nodeService.getByPath(ContentConstants.CONTENT_ROOT_PATH);
final AccessControlList rootContentPermissions = rootContentNode.getPermissions();
assertTrue(rootContentPermissions.getEntry(RoleKeys.ADMIN).isAllowedAll());
assertTrue(rootContentPermissions.getEntry(RoleKeys.CONTENT_MANAGER_ADMIN).isAllowedAll());
assertTrue(rootContentPermissions.getEntry(PrincipalKey.ofRole("cms.project.test-project.owner")).isAllowedAll());
assertTrue(rootContentPermissions.getEntry(PrincipalKey.ofRole("cms.project.test-project.editor")).isAllowedAll());
assertTrue(rootContentPermissions.getEntry(PrincipalKey.ofRole("cms.project.test-project.author")).isAllowed(Permission.READ, Permission.CREATE, Permission.MODIFY, Permission.DELETE));
assertTrue(rootContentPermissions.getEntry(PrincipalKey.ofRole("cms.project.test-project.contributor")).isAllowed(Permission.READ));
assertTrue(rootContentPermissions.getEntry(PrincipalKey.ofRole("cms.project.test-project.viewer")).isAllowed(Permission.READ));
assertNull(rootContentPermissions.getEntry(RoleKeys.EVERYONE));
}));
}
Aggregations