use of com.enonic.xp.project.Project in project xp by enonic.
the class ProjectServiceImplTest method get.
@Test
void get() {
final Project createdProject = doCreateProjectAsAdmin(ProjectName.from("test-project"));
adminContext().runWith(() -> {
assertProjectEquals(createdProject, projectService.get(createdProject.getName()));
});
}
use of com.enonic.xp.project.Project in project xp by enonic.
the class ProjectsSyncTaskTest method syncAll.
@Test
void syncAll() {
final Project parent = createProject("parent", null);
final Project child1 = createProject("child1", "parent");
final Project child2 = createProject("child2", "child1");
when(projectService.list()).thenReturn(Projects.create().addAll(Set.of(parent, child1, child2)).build());
ProjectsSyncTask.create().projectService(projectService).syncContentService(syncContentService).build().run(TaskId.from("taskId"), mock(ProgressReporter.class, withSettings().stubOnly()));
verify(syncContentService, times(2)).syncProject(paramsCaptor.capture());
final List<ProjectName> syncProjects = paramsCaptor.getAllValues().stream().map(ProjectSyncParams::getTargetProject).collect(Collectors.toList());
assertThat(syncProjects).containsExactly(child1.getName(), child2.getName());
}
use of com.enonic.xp.project.Project 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.project.Project in project xp by enonic.
the class ProjectServiceImplTest method get_icon.
@Test
void get_icon() throws Exception {
final Project project = doCreateProjectAsAdmin(ProjectName.from("test-project"));
final ByteSource source = ByteSource.wrap("new bytes".getBytes());
adminContext().runWith(() -> {
assertNull(projectService.getIcon(project.getName()));
projectService.modifyIcon(ModifyProjectIconParams.create().name(project.getName()).icon(CreateAttachment.create().mimeType("image/png").label("My New Image").name("MyNewImage.png").byteSource(ByteSource.wrap("new bytes".getBytes())).build()).build());
try {
assertArrayEquals(source.read(), projectService.getIcon(project.getName()).read());
} catch (IOException e) {
throw new UncheckedIOException(e);
}
});
Assertions.assertThrows(ProjectAccessException.class, () -> projectService.getIcon(project.getName()));
}
use of com.enonic.xp.project.Project 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