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