use of com.enonic.xp.project.Project in project xp by enonic.
the class ResetContentInheritanceCommand method fetchSourceProjectName.
private ProjectName fetchSourceProjectName(final ProjectName targetProjectName) {
final Project targetProject = createAdminContext().callWith(() -> projectService.get(targetProjectName));
if (targetProject == null) {
throw new IllegalArgumentException(String.format("Project with name [%s] doesn't exist", targetProjectName));
}
if (targetProject.getParent() == null) {
throw new IllegalArgumentException(String.format("Project with name [%s] has no parent", targetProject.getName()));
}
final Project sourceProject = createAdminContext().callWith(() -> projectService.get(targetProject.getParent()));
if (sourceProject == null) {
throw new IllegalArgumentException(String.format("Project with name [%s] doesn't exist", targetProject.getParent()));
}
return sourceProject.getName();
}
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 ProjectServiceImplTest method get_default_project.
@Test
void get_default_project() {
contentCustomManagerContext().runWith(() -> {
final Project defaultProject = projectService.get(ProjectConstants.DEFAULT_PROJECT_NAME);
assertNotNull(defaultProject);
});
}
use of com.enonic.xp.project.Project in project xp by enonic.
the class ProjectServiceImplTest method create.
@Test
void create() {
final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
final Project project = doCreateProjectAsAdmin(ProjectName.from(projectRepoId));
assertNotNull(project);
assertEquals("test-project", project.getName().toString());
final NodeBranchEntry nodeBranchEntry = this.branchService.get(Node.ROOT_UUID, InternalContext.create(adminContext()).repositoryId(projectRepoId).build());
assertNotNull(nodeBranchEntry);
adminContext().runWith(() -> {
final Repository pro = repositoryService.get(projectRepoId);
assertNotNull(pro);
});
}
use of com.enonic.xp.project.Project in project xp by enonic.
the class ProjectServiceImplTest method create_parent.
@Test
void create_parent() {
adminContext().runWith(() -> {
doCreateProject(ProjectName.from("test-project"), null, true, ProjectName.from("parent"));
final Project modifiedProject = projectService.get(ProjectName.from("test-project"));
assertEquals(ProjectName.from("parent"), modifiedProject.getParent());
});
}
Aggregations