Search in sources :

Example 6 with ProjectConfig

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

the class ProjectManagerReadTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    new File(root, "/fromFolder").mkdir();
    new File(root, "/normal").mkdir();
    new File(root, "/normal/module").mkdir();
    List<ProjectConfig> projects = new ArrayList<>();
    projects.add(DtoFactory.newDto(ProjectConfigDto.class).withPath("/normal").withName("project1Name").withType("primary1"));
    projects.add(DtoFactory.newDto(ProjectConfigDto.class).withPath("/fromConfig").withName("").withType("primary1"));
    projects.add(DtoFactory.newDto(ProjectConfigDto.class).withPath("/normal/module").withName("project1Name").withType("primary1"));
    workspaceHolder = new TestWorkspaceHolder(projects);
    ProjectTypeRegistry projectTypeRegistry = new ProjectTypeRegistry(new HashSet<>());
    projectTypeRegistry.registerProjectType(new PT1());
    projectTypeRegistry.registerProjectType(new PT3());
    ProjectHandlerRegistry projectHandlerRegistry = new ProjectHandlerRegistry(new HashSet<>());
    projectRegistry = new ProjectRegistry(workspaceHolder, vfsProvider, projectTypeRegistry, projectHandlerRegistry, eventService);
    projectRegistry.initProjects();
    pm = new ProjectManager(vfsProvider, projectTypeRegistry, projectRegistry, projectHandlerRegistry, null, fileWatcherNotificationHandler, fileTreeWatcher, workspaceHolder, fileWatcherManager);
    pm.initWatcher();
}
Also used : ProjectConfig(org.eclipse.che.api.core.model.project.ProjectConfig) ProjectTypeRegistry(org.eclipse.che.api.project.server.type.ProjectTypeRegistry) ProjectHandlerRegistry(org.eclipse.che.api.project.server.handlers.ProjectHandlerRegistry) ArrayList(java.util.ArrayList) File(java.io.File) Before(org.junit.Before)

Example 7 with ProjectConfig

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

the class ProjectManagerWriteTest method testConflictAttributesProjectCreateFailed.

@Test
public void testConflictAttributesProjectCreateFailed() throws Exception {
    // SPECS:
    // project will be created with problem code 13(Attribute name conflict)
    // when there are attributes with the same name in primary and mixin PT or between mixins
    final String path = "/testConflictAttributesProjectCreateFailed";
    final String projectTypeId = "pt2";
    final String mixin = "m2";
    final List<String> ms = new ArrayList<>(1);
    ms.add(mixin);
    ProjectConfig pc = new NewProjectConfigImpl(path, projectTypeId, ms, "name", "descr", null, null, null);
    pm.createProject(pc, null);
    final RegisteredProject project = projectRegistry.getProject(path);
    assertNotNull(project);
    assertNotNull(pm.getProjectsRoot().getChild(path));
    final List<String> mixins = project.getMixins();
    assertFalse(mixins.isEmpty());
    assertEquals(mixin, mixins.get(0));
    final List<Problem> problems = project.getProblems();
    assertNotNull(problems);
    assertFalse(problems.isEmpty());
    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) ArrayList(java.util.ArrayList) Problem(org.eclipse.che.api.project.server.RegisteredProject.Problem) Test(org.junit.Test)

Example 8 with ProjectConfig

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

the class ProjectManagerWriteTest method testSettableValueProvider.

@Test
public void testSettableValueProvider() throws Exception {
    assertTrue(((Variable) projectTypeRegistry.getProjectType("settableVPPT").getAttribute("my")).isValueProvided());
    ProjectConfig pc = new NewProjectConfigImpl("/testSettableValueProvider", "settableVPPT", null, "", "", new HashMap<>(), null, null);
    pm.createProject(pc, null);
    RegisteredProject project = pm.getProject("/testSettableValueProvider");
    assertEquals(1, project.getAttributes().size());
    assertEquals("notset", project.getAttributes().get("my").get(0));
    Map<String, List<String>> attributes = new HashMap<>();
    attributes.put("my", new AttributeValue("set").getList());
    pc = new NewProjectConfigImpl("/testSettableValueProvider", "settableVPPT", null, "", "", attributes, null, null);
    pm.updateProject(pc);
    project = pm.getProject("/testSettableValueProvider");
    assertEquals("set", project.getAttributes().get("my").get(0));
}
Also used : NewProjectConfig(org.eclipse.che.api.core.model.project.NewProjectConfig) ProjectConfig(org.eclipse.che.api.core.model.project.ProjectConfig) AttributeValue(org.eclipse.che.api.project.server.type.AttributeValue) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 9 with ProjectConfig

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

the class ProjectManagerWriteTest method testCreateInnerProject.

@Test
public void testCreateInnerProject() throws Exception {
    ProjectConfig pc = new NewProjectConfigImpl("/testCreateInnerProject", BaseProjectType.ID, null, "name", "descr", null, null, null);
    pm.createProject(pc, null);
    pc = new NewProjectConfigImpl("/testCreateInnerProject/inner", BaseProjectType.ID, null, "name", "descr", null, null, null);
    pm.createProject(pc, null);
    assertNotNull(projectRegistry.getProject("/testCreateInnerProject/inner"));
    assertEquals(2, projectRegistry.getProjects().size());
    assertEquals(1, projectRegistry.getProjects("/testCreateInnerProject").size());
    // If there are no parent folder it will be created
    pc = new NewProjectConfigImpl("/nothing/inner", BaseProjectType.ID, null, "name", "descr", null, null, null);
    pm.createProject(pc, null);
    assertNotNull(projectRegistry.getProject("/nothing/inner"));
    assertNotNull(projectRegistry.getProject("/nothing"));
    assertNotNull(pm.getProjectsRoot().getChildFolder("/nothing"));
}
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 10 with ProjectConfig

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

the class ProjectManagerWriteTest method testProvidedAttributesNotSerialized.

@Test
public void testProvidedAttributesNotSerialized() throws Exception {
    Map<String, List<String>> attributes = new HashMap<>();
    attributes.put("pt2-var2", new AttributeValue("test2").getList());
    attributes.put("pt2-var1", new AttributeValue("test1").getList());
    ProjectConfig pc = new NewProjectConfigImpl("/testProvidedAttributesNotSerialized", "pt3", null, "name", "descr", attributes, null, null);
    pm.createProject(pc, null);
    for (ProjectConfig project : workspaceHolder.getProjects()) {
        if (project.getPath().equals("/testProvidedAttributesNotSerialized")) {
            assertNotNull(project.getAttributes().get("pt2-var1"));
            assertNotNull(project.getAttributes().get("pt2-var2"));
            assertNull(project.getAttributes().get("pt2-const1"));
            assertNull(project.getAttributes().get("pt2-provided1"));
        }
    }
}
Also used : NewProjectConfig(org.eclipse.che.api.core.model.project.NewProjectConfig) ProjectConfig(org.eclipse.che.api.core.model.project.ProjectConfig) AttributeValue(org.eclipse.che.api.project.server.type.AttributeValue) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) 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