Search in sources :

Example 1 with Project

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();
}
Also used : Project(com.enonic.xp.project.Project)

Example 2 with Project

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()));
    });
}
Also used : Project(com.enonic.xp.project.Project) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 3 with Project

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);
    });
}
Also used : Project(com.enonic.xp.project.Project) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 4 with Project

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);
    });
}
Also used : Project(com.enonic.xp.project.Project) Repository(com.enonic.xp.repository.Repository) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) RepositoryId(com.enonic.xp.repository.RepositoryId) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 5 with Project

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());
    });
}
Also used : Project(com.enonic.xp.project.Project) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

Project (com.enonic.xp.project.Project)31 Test (org.junit.jupiter.api.Test)19 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)18 ProjectName (com.enonic.xp.project.ProjectName)9 ProjectPermissions (com.enonic.xp.project.ProjectPermissions)9 RepositoryId (com.enonic.xp.repository.RepositoryId)9 CreateProjectParams (com.enonic.xp.project.CreateProjectParams)7 ModifyProjectParams (com.enonic.xp.project.ModifyProjectParams)7 Repository (com.enonic.xp.repository.Repository)7 Context (com.enonic.xp.context.Context)6 ContextBuilder (com.enonic.xp.context.ContextBuilder)6 ProjectGraph (com.enonic.xp.project.ProjectGraph)6 RoleKeys (com.enonic.xp.security.RoleKeys)6 AuthenticationInfo (com.enonic.xp.security.auth.AuthenticationInfo)6 ByteSource (com.google.common.io.ByteSource)6 IOException (java.io.IOException)6 UncheckedIOException (java.io.UncheckedIOException)6 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)5