use of com.enonic.xp.project.Projects in project xp by enonic.
the class ProjectServiceImplTest method initialize.
@Test
void initialize() {
ContextBuilder.from(adminContext()).repositoryId(ContentConstants.CONTENT_REPO_ID).branch(ContentConstants.BRANCH_DRAFT).build().runWith(() -> {
final Projects projects = projectService.list();
assertEquals(1, projects.getSize());
assertTrue(nodeService.nodeExists(NodePath.create().addElement("content").build()));
assertTrue(nodeService.nodeExists(NodePath.create().addElement("issues").build()));
assertTrue(nodeService.nodeExists(NodePath.create().addElement("archive").build()));
});
}
use of com.enonic.xp.project.Projects in project xp by enonic.
the class ProjectServiceImplTest method list_with_custom_permissions.
@Test
void list_with_custom_permissions() {
doCreateProjectAsAdmin(ProjectName.from("test-project1"), ProjectPermissions.create().build());
doCreateProjectAsAdmin(ProjectName.from("test-project2"), ProjectPermissions.create().addOwner(REPO_TEST_OWNER.getKey()).build());
doCreateProjectAsAdmin(ProjectName.from("test-project3"), ProjectPermissions.create().addEditor(REPO_TEST_OWNER.getKey()).build());
doCreateProjectAsAdmin(ProjectName.from("test-project4"), ProjectPermissions.create().addAuthor(REPO_TEST_OWNER.getKey()).build());
doCreateProjectAsAdmin(ProjectName.from("test-project5"), ProjectPermissions.create().addContributor(REPO_TEST_OWNER.getKey()).build());
final AuthenticationInfo authenticationInfo = AuthenticationInfo.copyOf(REPO_TEST_CUSTOM_MANAGER_AUTHINFO).principals(ProjectAccessHelper.createRoleKey(ProjectName.from("test-project2"), ProjectRole.OWNER), ProjectAccessHelper.createRoleKey(ProjectName.from("test-project3"), ProjectRole.EDITOR), ProjectAccessHelper.createRoleKey(ProjectName.from("test-project4"), ProjectRole.AUTHOR), ProjectAccessHelper.createRoleKey(ProjectName.from("test-project5"), ProjectRole.CONTRIBUTOR)).build();
ContextBuilder.from(contentCustomManagerContext()).authInfo(authenticationInfo).build().runWith(() -> {
final Projects projects = projectService.list();
assertEquals(5, projectService.list().getSize());
assertFalse(projects.stream().anyMatch(project -> project.getName().toString().equals("test-project1")));
assertTrue(projects.stream().anyMatch(project -> project.getName().equals(ProjectName.from(ContentConstants.CONTENT_REPO_ID))));
});
}
Aggregations