Search in sources :

Example 6 with Problem

use of org.eclipse.che.api.project.server.RegisteredProject.Problem 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);
}
Also used : Problem(org.eclipse.che.api.project.server.RegisteredProject.Problem) NewProjectConfig(org.eclipse.che.api.core.model.project.NewProjectConfig) Test(org.junit.Test)

Example 7 with Problem

use of org.eclipse.che.api.project.server.RegisteredProject.Problem 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());
}
Also used : ArrayList(java.util.ArrayList) Problem(org.eclipse.che.api.project.server.RegisteredProject.Problem) NewProjectConfig(org.eclipse.che.api.core.model.project.NewProjectConfig) Test(org.junit.Test)

Example 8 with Problem

use of org.eclipse.che.api.project.server.RegisteredProject.Problem in project che by eclipse.

the class ProjectManagerWriteTest method testUpdateProjectWithProvidedAttributes.

@Test
public void testUpdateProjectWithProvidedAttributes() throws Exception {
    // SPECS: Project should be updated with problem code = 13 when value for required attribute is not initialized
    Map<String, List<String>> attributes = new HashMap<>();
    attributes.put("pt2-var2", new AttributeValue("test").getList());
    ProjectConfig pc = new NewProjectConfigImpl("/testUpdateProject", "pt2", null, "name", "descr", attributes, null, null);
    pm.createProject(pc, null);
    pc = new NewProjectConfigImpl("/testUpdateProject", "pt3", null, "updatedName", "descr", attributes, null, null);
    RegisteredProject project = pm.updateProject(pc);
    final List<Problem> problems = project.getProblems();
    assertNotNull(problems);
    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) AttributeValue(org.eclipse.che.api.project.server.type.AttributeValue) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) Problem(org.eclipse.che.api.project.server.RegisteredProject.Problem) Test(org.junit.Test)

Example 9 with Problem

use of org.eclipse.che.api.project.server.RegisteredProject.Problem in project che by eclipse.

the class ProjectTypes method addTransient.

void addTransient(FolderEntry projectFolder) {
    for (ProjectTypeDef pt : projectTypeRegistry.getProjectTypes()) {
        // NOTE: Only mixable types allowed
        if (pt.isMixable() && !pt.isPersisted() && pt.resolveSources(projectFolder).matched()) {
            all.put(pt.getId(), pt);
            mixins.put(pt.getId(), pt);
            for (Attribute attr : pt.getAttributes()) {
                final String attrName = attr.getName();
                if (attributeDefs.containsKey(attrName)) {
                    problems.add(new Problem(ATTRIBUTE_NAME_PROBLEM, format("Attribute name conflict. Duplicated attributes detected for %s. " + "Attribute %s declared in %s already declared in %s. Skipped.", projectPath, attrName, pt.getId(), attributeDefs.get(attrName).getProjectType())));
                }
                attributeDefs.put(attrName, attr);
            }
        }
    }
}
Also used : Attribute(org.eclipse.che.api.core.model.project.type.Attribute) ProjectTypeDef(org.eclipse.che.api.project.server.type.ProjectTypeDef) Problem(org.eclipse.che.api.project.server.RegisteredProject.Problem)

Aggregations

Problem (org.eclipse.che.api.project.server.RegisteredProject.Problem)9 NewProjectConfig (org.eclipse.che.api.core.model.project.NewProjectConfig)8 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)6 ProjectConfig (org.eclipse.che.api.core.model.project.ProjectConfig)5 HashMap (java.util.HashMap)2 List (java.util.List)2 AttributeValue (org.eclipse.che.api.project.server.type.AttributeValue)2 ProjectTypeDef (org.eclipse.che.api.project.server.type.ProjectTypeDef)2 Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)1 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 IOException (java.io.IOException)1 String.format (java.lang.String.format)1 PathMatcher (java.nio.file.PathMatcher)1 Map (java.util.Map)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors (java.util.concurrent.Executors)1 Collectors (java.util.stream.Collectors)1 PreDestroy (javax.annotation.PreDestroy)1 Inject (javax.inject.Inject)1