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