use of org.eclipse.che.api.core.model.project.NewProjectConfig in project che by eclipse.
the class ProjectManagerWriteTest method testCreateProjectWhenSourceCodeIsNotReachable.
@Test
public void testCreateProjectWhenSourceCodeIsNotReachable() throws Exception {
final String projectPath = "/testProject";
final SourceStorageDto source = DtoFactory.newDto(SourceStorageDto.class).withLocation("someLocation").withType("importType");
final NewProjectConfigDto config = createProjectConfigObject("testProject1", projectPath, BaseProjectType.ID, source);
final List<NewProjectConfig> configs = new ArrayList<>(1);
configs.add(config);
try {
pm.createBatchProjects(configs, false, new ProjectOutputLineConsumerFactory("ws", 300));
fail("Exception should be thrown when source code is not reachable");
} catch (Exception e) {
assertEquals(0, projectRegistry.getProjects().size());
assertNull(projectRegistry.getProject(projectPath));
assertNull(pm.getProjectsRoot().getChild(projectPath));
}
}
use of org.eclipse.che.api.core.model.project.NewProjectConfig in project che by eclipse.
the class ProjectManagerWriteTest method testCreateBatchProjectsWithInnerProject.
@Test
public void testCreateBatchProjectsWithInnerProject() throws Exception {
final String rootProjectPath = "/testProject1";
final String innerProjectPath = "/testProject1/innerProject";
final String importType = "importType1";
final String innerProjectType = "pt2";
Map<String, List<String>> attributes = new HashMap<>();
attributes.put("pt2-var2", new AttributeValue("test").getList());
final String[] paths1 = { "folder1/", "folder1/file1.txt" };
final String[] paths2 = { "innerProject/", "innerProject/folder2/", "innerProject/folder2/file2.txt" };
final List<String> children1 = Arrays.asList(paths1);
final List<String> children2 = Arrays.asList(paths2);
final List<String> children = new ArrayList<>(children1);
children.addAll(children2);
registerImporter(importType, prepareZipArchiveBasedOn(children));
SourceStorageDto source = DtoFactory.newDto(SourceStorageDto.class).withLocation("someLocation").withType(importType);
NewProjectConfigDto config1 = createProjectConfigObject("testProject1", rootProjectPath, BaseProjectType.ID, source);
NewProjectConfigDto config2 = createProjectConfigObject("innerProject", innerProjectPath, innerProjectType, null);
config2.setAttributes(attributes);
List<NewProjectConfig> configs = new ArrayList<>(2);
configs.add(config1);
configs.add(config2);
pm.createBatchProjects(configs, false, new ProjectOutputLineConsumerFactory("ws", 300));
RegisteredProject rootProject = projectRegistry.getProject(rootProjectPath);
FolderEntry rootProjectFolder = rootProject.getBaseFolder();
RegisteredProject innerProject = projectRegistry.getProject(innerProjectPath);
FolderEntry innerProjectFolder = innerProject.getBaseFolder();
assertNotNull(rootProject);
assertTrue(rootProjectFolder.getVirtualFile().exists());
assertEquals(rootProjectPath, rootProject.getPath());
checkChildrenFor(rootProjectFolder, children1);
assertNotNull(innerProject);
assertTrue(innerProjectFolder.getVirtualFile().exists());
assertEquals(innerProjectPath, innerProject.getPath());
assertEquals(innerProjectType, innerProject.getType());
checkChildrenFor(rootProjectFolder, children2);
}
use of org.eclipse.che.api.core.model.project.NewProjectConfig in project che by eclipse.
the class ProjectManagerWriteTest method testCreateProjectWithInvalidAttribute.
@Test
public void testCreateProjectWithInvalidAttribute() throws Exception {
// SPECS:
// Project will be created with problem code = 13(Value for required attribute is not initialized)
// when required attribute is not initialized
final String path = "/testCreateProjectInvalidAttributes";
final String projectType = "pt2";
final NewProjectConfig config = new NewProjectConfigImpl(path, projectType, null, "name", "descr", null, null, null);
pm.createProject(config, null);
RegisteredProject project = projectRegistry.getProject(path);
assertNotNull(project);
assertNotNull(pm.getProjectsRoot().getChild(path));
assertEquals(projectType, project.getType());
List<Problem> problems = project.getProblems();
assertNotNull(problems);
assertFalse(problems.isEmpty());
assertEquals(1, problems.size());
assertEquals(13, problems.get(0).code);
}
use of org.eclipse.che.api.core.model.project.NewProjectConfig in project che by eclipse.
the class ProjectManagerWriteTest method shouldCreateBatchProjectsWithoutMixinPTWhenThisOneIsUnregistered.
@Test
public void shouldCreateBatchProjectsWithoutMixinPTWhenThisOneIsUnregistered() throws Exception {
// If declared mixin PT is not registered, project is created w/o it, with Problem 12
final String projectPath = "/testProject";
final String mixinPType = "unregistered";
final NewProjectConfig config = createProjectConfigObject("projectName", projectPath, BaseProjectType.ID, null);
config.getMixins().add(mixinPType);
final List<NewProjectConfig> configs = new ArrayList<>(1);
configs.add(config);
pm.createBatchProjects(configs, false, new ProjectOutputLineConsumerFactory("ws", 300));
final RegisteredProject project = projectRegistry.getProject(projectPath);
final List<Problem> problems = project.getProblems();
checkProjectExist(projectPath);
assertEquals(1, problems.size());
assertEquals(12, problems.get(0).code);
assertTrue(project.getMixins().isEmpty());
assertEquals(1, projectRegistry.getProjects().size());
}
use of org.eclipse.che.api.core.model.project.NewProjectConfig in project che by eclipse.
the class ProjectManagerWriteTest method testCreateBatchProjectsWhenConfigContainsOnlyPath.
@Test
public void testCreateBatchProjectsWhenConfigContainsOnlyPath() throws Exception {
// NewProjectConfig object contains only one mandatory Project Path field
final String projectPath1 = "/testProject1";
final String projectPath2 = "/testProject2";
final NewProjectConfig config1 = createProjectConfigObject(null, projectPath1, null, null);
final NewProjectConfig config2 = createProjectConfigObject(null, projectPath2, null, null);
final List<NewProjectConfig> configs = new ArrayList<>(2);
configs.add(config1);
configs.add(config2);
pm.createBatchProjects(configs, false, new ProjectOutputLineConsumerFactory("ws", 300));
checkProjectExist(projectPath1);
checkProjectExist(projectPath2);
assertEquals(2, projectRegistry.getProjects().size());
}
Aggregations