Search in sources :

Example 11 with FolderEntry

use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.

the class WorkspaceTest method testAddingNewModule.

@Test
public void testAddingNewModule() throws Exception {
    String pom = "<groupId>test</groupId>" + "<artifactId>testArtifact</artifactId>" + "<version>42</version>" + "<modules>" + "    <module>module1</module>" + "</modules>";
    FolderEntry parentFolder = createTestProject("parent", pom);
    String pomModule1 = "<groupId>test</groupId>" + "<artifactId>testModule1</artifactId>" + "<version>1</version>" + "<dependencies>" + "    <dependency>" + "        <groupId>junit</groupId>" + "        <artifactId>junit</artifactId>" + "        <version>4.12</version>" + "    </dependency>" + "</dependencies>";
    createTestProject("parent/module1", pomModule1);
    IProject parent = ResourcesPlugin.getWorkspace().getRoot().getProject("parent");
    mavenWorkspace.update(Collections.singletonList(parent));
    mavenWorkspace.waitForUpdate();
    assertThat(projectRegistry.getProjects()).hasSize(2).onProperty("path").containsOnly("/parent", "/parent/module1");
    VirtualFile parentPom = parentFolder.getChild("pom.xml").getVirtualFile();
    Model model = Model.readFrom(parentPom);
    List<String> modules = new ArrayList<>(model.getModules());
    modules.add("module2");
    model.setModules(modules);
    model.writeTo(parentPom);
    String pomModule2 = "<groupId>module2</groupId>" + "<artifactId>testModule2</artifactId>" + "<version>2</version>" + "<dependencies>" + "    <dependency>" + "        <groupId>junit</groupId>" + "        <artifactId>junit</artifactId>" + "        <version>4.12</version>" + "    </dependency>" + "</dependencies>";
    createTestProject("parent/module2", pomModule2);
    mavenWorkspace.update(Collections.singletonList(parent));
    mavenWorkspace.waitForUpdate();
    assertThat(projectRegistry.getProjects()).hasSize(3).onProperty("path").containsOnly("/parent", "/parent/module1", "/parent/module2");
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) FolderEntry(org.eclipse.che.api.project.server.FolderEntry) Model(org.eclipse.che.ide.maven.tools.Model) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Example 12 with FolderEntry

use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.

the class CreateNetCoreProjectHandler method onCreateProject.

@Override
public void onCreateProject(Path projectPath, Map<String, AttributeValue> attributes, Map<String, String> options) throws ForbiddenException, ConflictException, ServerException {
    VirtualFileSystem vfs = virtualFileSystemProvider.getVirtualFileSystem();
    FolderEntry baseFolder = new FolderEntry(vfs.getRoot().createFolder(projectPath.toString()));
    baseFolder.createFile(PROJECT_FILE_NAME, getProjectContent());
}
Also used : VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) FolderEntry(org.eclipse.che.api.project.server.FolderEntry)

Example 13 with FolderEntry

use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.

the class CProjectGenerator method onCreateProject.

@Override
public void onCreateProject(Path projectPath, Map<String, AttributeValue> attributes, Map<String, String> options) throws ForbiddenException, ConflictException, ServerException {
    VirtualFileSystem vfs = virtualFileSystemProvider.getVirtualFileSystem();
    FolderEntry baseFolder = new FolderEntry(vfs.getRoot().createFolder(projectPath.toString()));
    baseFolder.createFile(FILE_NAME, getClass().getClassLoader().getResourceAsStream("files/default_c_content"));
}
Also used : VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) FolderEntry(org.eclipse.che.api.project.server.FolderEntry)

Example 14 with FolderEntry

use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.

the class CppProjectGenerator method onCreateProject.

@Override
public void onCreateProject(Path projectPath, Map<String, AttributeValue> attributes, Map<String, String> options) throws ForbiddenException, ConflictException, ServerException {
    VirtualFileSystem vfs = virtualFileSystemProvider.getVirtualFileSystem();
    FolderEntry baseFolder = new FolderEntry(vfs.getRoot().createFolder(projectPath.toString()));
    baseFolder.createFile(FILE_NAME, getClass().getClassLoader().getResourceAsStream("files/default_cpp_content"));
}
Also used : VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) FolderEntry(org.eclipse.che.api.project.server.FolderEntry)

Example 15 with FolderEntry

use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.

the class SubversionProjectImporterTest method testValidImportSources.

/**
     * Test for {@link SubversionProjectImporter#importSources(org.eclipse.che.api.project.server.FolderEntry, org.eclipse.che.api.core.model.project.SourceStorage, org.eclipse.che.api.core.util.LineConsumerFactory)}
     * with a valid url.
     *
     * @throws Exception if anything goes wrong
     */
@Test
public void testValidImportSources() throws Exception {
    final String projectName = NameGenerator.generate("project-", 3);
    final VirtualFile virtualFile = root.createFolder(projectName);
    FolderEntry projectFolder = new FolderEntry(virtualFile);
    String repoUrl = Paths.get(repoRoot.getAbsolutePath()).toUri().toString();
    when(sourceStorage.getLocation()).thenReturn(repoUrl);
    projectImporter.importSources(projectFolder, sourceStorage, new TestUtils.SystemOutLineConsumerFactory());
    assertTrue(projectFolder.getChild(".svn").isFolder());
    assertTrue(projectFolder.getChild("trunk").isFolder());
    assertTrue(projectFolder.getChildFolder("trunk").getChild("A").isFolder());
    assertTrue(projectFolder.getChildFolder("trunk").getChildFolder("A").getChild("mu").isFile());
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) TestUtils(org.eclipse.che.plugin.svn.server.utils.TestUtils) FolderEntry(org.eclipse.che.api.project.server.FolderEntry) Test(org.junit.Test)

Aggregations

FolderEntry (org.eclipse.che.api.project.server.FolderEntry)33 VirtualFileEntry (org.eclipse.che.api.project.server.VirtualFileEntry)11 Test (org.testng.annotations.Test)11 VirtualFileSystem (org.eclipse.che.api.vfs.VirtualFileSystem)9 MavenServerManagerTest (org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)8 IProject (org.eclipse.core.resources.IProject)7 Problem (org.eclipse.che.ide.ext.java.shared.dto.Problem)6 MavenServerService (org.eclipse.che.plugin.maven.server.rest.MavenServerService)6 ServerException (org.eclipse.che.api.core.ServerException)5 FileEntry (org.eclipse.che.api.project.server.FileEntry)4 VirtualFile (org.eclipse.che.api.vfs.VirtualFile)4 ConflictException (org.eclipse.che.api.core.ConflictException)3 ValueProvider (org.eclipse.che.api.project.server.type.ValueProvider)3 Model (org.eclipse.che.ide.maven.tools.Model)3 ArrayList (java.util.ArrayList)2 ForbiddenException (org.eclipse.che.api.core.ForbiddenException)2 ProjectCreatedEvent (org.eclipse.che.api.project.server.ProjectCreatedEvent)2 ResourceChangedEvent (org.eclipse.che.jdt.core.resources.ResourceChangedEvent)2 TestUtils (org.eclipse.che.plugin.svn.server.utils.TestUtils)2 IResourceStatus (org.eclipse.core.resources.IResourceStatus)2