Search in sources :

Example 16 with ProjectConfig

use of org.eclipse.che.api.core.model.project.ProjectConfig in project che by eclipse.

the class ProjectManagerReadTest method testSerializeProject.

@Test
public void testSerializeProject() throws Exception {
    ProjectConfig config = DtoConverter.asDto(pm.getProject("/fromConfig"));
    assertEquals("/fromConfig", config.getPath());
    assertEquals("primary1", config.getType());
}
Also used : ProjectConfig(org.eclipse.che.api.core.model.project.ProjectConfig) Test(org.junit.Test)

Example 17 with ProjectConfig

use of org.eclipse.che.api.core.model.project.ProjectConfig in project che by eclipse.

the class ProjectManagerWriteTest method testDeleteProjectEvent.

@Test
public void testDeleteProjectEvent() throws Exception {
    ProjectConfig pc = new NewProjectConfigImpl("/testDeleteProject", BaseProjectType.ID, null, "name", "descr", null, null, null);
    pm.createProject(pc, null);
    String[] deletedPath = new String[1];
    eventService.subscribe(new EventSubscriber<ProjectDeletedEvent>() {

        @Override
        public void onEvent(ProjectDeletedEvent event) {
            deletedPath[0] = event.getProjectPath();
        }
    });
    pm.delete("/testDeleteProject");
    assertEquals("/testDeleteProject", deletedPath[0]);
}
Also used : NewProjectConfig(org.eclipse.che.api.core.model.project.NewProjectConfig) ProjectConfig(org.eclipse.che.api.core.model.project.ProjectConfig) Test(org.junit.Test)

Example 18 with ProjectConfig

use of org.eclipse.che.api.core.model.project.ProjectConfig in project che by eclipse.

the class ProjectManagerWriteTest method testInvalidPTProjectCreateFailed.

@Test
public void testInvalidPTProjectCreateFailed() throws Exception {
    // SPECS:
    // project will be created as project of "blank" type
    // with problem code 12(Primary type "someType" is not registered. Base Project Type assigned.)
    // when primary project type is not registered in PT registry
    final String path = "/testInvalidPTProjectCreateFailed";
    ProjectConfig pc = new NewProjectConfigImpl(path, "invalid", null, "name", "descr", null, null, null);
    pm.createProject(pc, null);
    RegisteredProject project = projectRegistry.getProject(path);
    assertNotNull(project);
    assertNotNull(pm.getProjectsRoot().getChild(path));
    assertEquals(BaseProjectType.ID, project.getType());
    List<Problem> problems = project.getProblems();
    assertNotNull(problems);
    assertFalse(problems.isEmpty());
    assertEquals(1, problems.size());
    assertEquals(12, problems.get(0).code);
    //clean up
    project.getBaseFolder().getVirtualFile().delete();
    projectRegistry.removeProjects(path);
    assertNull(projectRegistry.getProject(path));
    // SPECS:
    // project will be created without mixin project type and
    // with problem code 12(Project type "someType" is not registered. Skipped.)
    // when mixin project type is not registered in PT registry
    List<String> ms = new ArrayList<>();
    ms.add("invalid");
    pc = new NewProjectConfigImpl(path, "blank", ms, "name", "descr", null, null, null);
    pm.createProject(pc, null);
    project = projectRegistry.getProject(path);
    assertNotNull(project);
    assertNotNull(pm.getProjectsRoot().getChild(path));
    assertTrue(project.getMixins().isEmpty());
    problems = project.getProblems();
    assertNotNull(problems);
    assertFalse(problems.isEmpty());
    assertEquals(1, problems.size());
    assertEquals(12, problems.get(0).code);
}
Also used : NewProjectConfig(org.eclipse.che.api.core.model.project.NewProjectConfig) ProjectConfig(org.eclipse.che.api.core.model.project.ProjectConfig) ArrayList(java.util.ArrayList) Problem(org.eclipse.che.api.project.server.RegisteredProject.Problem) Test(org.junit.Test)

Example 19 with ProjectConfig

use of org.eclipse.che.api.core.model.project.ProjectConfig in project che by eclipse.

the class ProjectManagerWriteTest method testCreateProjectWithRequiredProvidedAttributeWhenGivenProjectTypeHasNotGenerator.

@Test
public void testCreateProjectWithRequiredProvidedAttributeWhenGivenProjectTypeHasNotGenerator() throws Exception {
    // SPECS:
    // Project will be created with problem code = 13 (Value for required attribute is not initialized)
    // when project type has provided required attributes
    // but have not respective generator(CreateProjectHandler)
    final String path = "/testCreateProjectWithRequiredProvidedAttribute";
    final String projectTypeId = "pt4";
    final ProjectConfig pc = new NewProjectConfigImpl(path, projectTypeId, null, "name", "descr", null, null, null);
    pm.createProject(pc, null);
    final RegisteredProject project = projectRegistry.getProject(path);
    final List<VirtualFileEntry> children = project.getBaseFolder().getChildren();
    final List<Problem> problems = project.getProblems();
    assertNotNull(project);
    assertNotNull(pm.getProjectsRoot().getChild(path));
    assertEquals(projectTypeId, project.getType());
    assertTrue(children.isEmpty());
    assertTrue(project.getAttributes().isEmpty());
    assertFalse(problems.isEmpty());
    assertEquals(1, problems.size());
    assertEquals(13, problems.get(0).code);
}
Also used : NewProjectConfig(org.eclipse.che.api.core.model.project.NewProjectConfig) ProjectConfig(org.eclipse.che.api.core.model.project.ProjectConfig) Problem(org.eclipse.che.api.project.server.RegisteredProject.Problem) Test(org.junit.Test)

Example 20 with ProjectConfig

use of org.eclipse.che.api.core.model.project.ProjectConfig in project che by eclipse.

the class ProjectManagerWriteTest method testInvalidUpdateConfig.

@Test
public void testInvalidUpdateConfig() throws Exception {
    ProjectConfig pc = new NewProjectConfigImpl(null, BaseProjectType.ID, null, "name", "descr", null, null, null);
    try {
        pm.updateProject(pc);
        fail("ConflictException: Project path is not defined");
    } catch (ConflictException e) {
    }
    pc = new NewProjectConfigImpl("/nothing", BaseProjectType.ID, null, "name", "descr", null, null, null);
    try {
        pm.updateProject(pc);
        fail("NotFoundException: Project '/nothing' doesn't exist.");
    } catch (NotFoundException e) {
    }
}
Also used : NewProjectConfig(org.eclipse.che.api.core.model.project.NewProjectConfig) ProjectConfig(org.eclipse.che.api.core.model.project.ProjectConfig) ConflictException(org.eclipse.che.api.core.ConflictException) NotFoundException(org.eclipse.che.api.core.NotFoundException) Test(org.junit.Test)

Aggregations

ProjectConfig (org.eclipse.che.api.core.model.project.ProjectConfig)26 NewProjectConfig (org.eclipse.che.api.core.model.project.NewProjectConfig)20 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)7 List (java.util.List)7 ConflictException (org.eclipse.che.api.core.ConflictException)6 AttributeValue (org.eclipse.che.api.project.server.type.AttributeValue)6 NotFoundException (org.eclipse.che.api.core.NotFoundException)5 Problem (org.eclipse.che.api.project.server.RegisteredProject.Problem)5 ForbiddenException (org.eclipse.che.api.core.ForbiddenException)3 ServerException (org.eclipse.che.api.core.ServerException)3 ProjectTypeRegistry (org.eclipse.che.api.project.server.type.ProjectTypeRegistry)3 File (java.io.File)2 IOException (java.io.IOException)2 BadRequestException (org.eclipse.che.api.core.BadRequestException)2 UnauthorizedException (org.eclipse.che.api.core.UnauthorizedException)2 SourceStorage (org.eclipse.che.api.core.model.project.SourceStorage)2 ProjectHandlerRegistry (org.eclipse.che.api.project.server.handlers.ProjectHandlerRegistry)2 ProjectImporter (org.eclipse.che.api.project.server.importer.ProjectImporter)2