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