Search in sources :

Example 6 with ProjectName

use of com.enonic.xp.project.ProjectName in project xp by enonic.

the class ContentInitializerTest method testBranchNotFound.

@Test
public void testBranchNotFound() {
    when(repositoryService.isInitialized(Mockito.any())).thenReturn(true);
    when(nodeService.getByPath(Mockito.any())).thenThrow(new BranchNotFoundException(Branch.from("draft")));
    final ProjectName projectName = ProjectName.from("my-project");
    Assertions.assertFalse(ContentInitializer.create().setIndexService(indexService).setNodeService(nodeService).setRepositoryService(repositoryService).repositoryId(projectName.getRepoId()).build().isInitialized());
}
Also used : ProjectName(com.enonic.xp.project.ProjectName) BranchNotFoundException(com.enonic.xp.repository.BranchNotFoundException) Test(org.junit.jupiter.api.Test)

Example 7 with ProjectName

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")));
}
Also used : ProjectName(com.enonic.xp.project.ProjectName) Projects(com.enonic.xp.project.Projects) ProgressReporter(com.enonic.xp.task.ProgressReporter) Test(org.junit.jupiter.api.Test)

Example 8 with ProjectName

use of com.enonic.xp.project.ProjectName in project xp by enonic.

the class ArchiveInitializerTest method testBranchNotFound.

@Test
public void testBranchNotFound() {
    when(nodeService.getByPath(Mockito.any())).thenThrow(new BranchNotFoundException(Branch.from("draft")));
    final ProjectName projectName = ProjectName.from("my-project");
    Assertions.assertFalse(ArchiveInitializer.create().setIndexService(indexService).setNodeService(nodeService).repositoryId(projectName.getRepoId()).build().isInitialized());
}
Also used : ProjectName(com.enonic.xp.project.ProjectName) BranchNotFoundException(com.enonic.xp.repository.BranchNotFoundException) Test(org.junit.jupiter.api.Test)

Example 9 with ProjectName

use of com.enonic.xp.project.ProjectName 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());
}
Also used : Project(com.enonic.xp.project.Project) ProjectName(com.enonic.xp.project.ProjectName) ProgressReporter(com.enonic.xp.task.ProgressReporter) Test(org.junit.jupiter.api.Test)

Example 10 with ProjectName

use of com.enonic.xp.project.ProjectName in project xp by enonic.

the class ProjectServiceImplTest method delete_with_content_admin_permissions.

@Test
void delete_with_content_admin_permissions() {
    final ProjectName projectName = ProjectName.from("test-project");
    doCreateProjectAsAdmin(projectName);
    contentAdminContext().runWith(() -> {
        assertNotNull(this.projectService.get(projectName));
        this.projectService.delete(projectName);
        assertNull(this.projectService.get(projectName));
    });
}
Also used : ProjectName(com.enonic.xp.project.ProjectName) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

ProjectName (com.enonic.xp.project.ProjectName)20 Test (org.junit.jupiter.api.Test)13 Project (com.enonic.xp.project.Project)7 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)7 RepositoryId (com.enonic.xp.repository.RepositoryId)6 Context (com.enonic.xp.context.Context)5 AuthenticationInfo (com.enonic.xp.security.auth.AuthenticationInfo)5 EnumSet (java.util.EnumSet)5 ContentId (com.enonic.xp.content.ContentId)4 ContextAccessor (com.enonic.xp.context.ContextAccessor)4 ContextBuilder (com.enonic.xp.context.ContextBuilder)4 PropertyTree (com.enonic.xp.data.PropertyTree)4 ProjectService (com.enonic.xp.project.ProjectService)4 RoleKeys (com.enonic.xp.security.RoleKeys)4 Collectors (java.util.stream.Collectors)4 Content (com.enonic.xp.content.Content)3 ContentInheritType (com.enonic.xp.content.ContentInheritType)3 ResetContentInheritParams (com.enonic.xp.content.ResetContentInheritParams)3 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)3 WorkflowInfo (com.enonic.xp.content.WorkflowInfo)3