Search in sources :

Example 16 with MavenProject

use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.

the class WorkspaceTest method testImportParentInSiblingFolder.

@Test
public void testImportParentInSiblingFolder() throws Exception {
    String parentPom = "" + "  <groupId>com.mycompany.app</groupId>\n" + "  <artifactId>my-app</artifactId>\n" + "  <version>1</version>\n" + "  <packaging>pom</packaging>\n" + " \n" + "  <modules>\n" + "    <module>../my-module</module>\n" + "  </modules>";
    createTestProject("parent", parentPom);
    String relativePom = "<parent>\n" + "    <groupId>com.mycompany.app</groupId>\n" + "    <artifactId>my-app</artifactId>\n" + "    <version>1</version>\n" + "    <relativePath>../parent/pom.xml</relativePath>\n" + "  </parent>\n" + "  <artifactId>my-module</artifactId>\n";
    createTestProject("my-module", relativePom);
    IProject test = ResourcesPlugin.getWorkspace().getRoot().getProject("my-module");
    mavenWorkspace.update(Collections.singletonList(test));
    mavenWorkspace.waitForUpdate();
    MavenProject mavenProject = mavenProjectManager.findMavenProject(test);
    assertThat(mavenProject).isNotNull();
}
Also used : MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Example 17 with MavenProject

use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.

the class WorkspaceTest method testImportRelativeChildPom.

@Test
public void testImportRelativeChildPom() throws Exception {
    String parentPom = "" + "  <groupId>com.mycompany.app</groupId>\n" + "  <artifactId>my-app</artifactId>\n" + "  <version>1</version>\n" + "  <packaging>pom</packaging>\n" + " \n" + "  <modules>\n" + "    <module>../my-module/pom.xml</module>\n" + "  </modules>";
    createTestProject("parent", parentPom);
    String relativePom = "<parent>\n" + "    <groupId>com.mycompany.app</groupId>\n" + "    <artifactId>my-app</artifactId>\n" + "    <version>1</version>\n" + "    <relativePath>../parent/pom.xml</relativePath>\n" + "  </parent>\n" + "  <artifactId>my-module</artifactId>\n";
    createTestProject("my-module", relativePom);
    IProject test = ResourcesPlugin.getWorkspace().getRoot().getProject("parent");
    mavenWorkspace.update(Collections.singletonList(test));
    mavenWorkspace.waitForUpdate();
    IProject myModule = ResourcesPlugin.getWorkspace().getRoot().getProject("my-module");
    MavenProject mavenProject = mavenProjectManager.findMavenProject(myModule);
    assertThat(mavenProject).isNotNull();
    assertThat(mavenProject.getDependencies()).isNotNull();
}
Also used : MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Example 18 with MavenProject

use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.

the class MavenProjectManagerTest method testUpdateProject.

@Test
public void testUpdateProject() throws Exception {
    when(project.getFile(MavenConstants.POM_FILE_NAME)).thenReturn(pom);
    when(pom.getLocation()).thenReturn(new Path(MavenProjectManagerTest.class.getResource("/FirstProject/pom.xml").getFile()));
    when(pom.getFullPath()).thenReturn(new Path("/FirstProject/pom.xml"));
    when(project.getFullPath()).thenReturn(new Path("/FirstProject/"));
    projectManager.addListener(listener);
    MavenProject mavenProject = new MavenProject(project, workspace);
    mavenProject.read(project, manager);
    MavenKey mavenKey = mavenProject.getMavenKey();
    assertThat(mavenKey).isNotNull();
    projectManager.update(Collections.singletonList(project), true);
    verify(listener).projectUpdated(mapArgument.capture(), any());
}
Also used : Path(org.eclipse.core.runtime.Path) MavenKey(org.eclipse.che.maven.data.MavenKey) MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) Test(org.testng.annotations.Test)

Example 19 with MavenProject

use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.

the class MavenProjectManagerTest method testUpdateMultimoduleProject.

@Test
public void testUpdateMultimoduleProject() throws Exception {
    IProject testProject = mock(IProject.class);
    IFile testPom = mock(IFile.class);
    IProject subModuleProject = mock(IProject.class);
    IFile subPom = mock(IFile.class);
    IFile testFile = mock(IFile.class);
    when(project.getFile(MavenConstants.POM_FILE_NAME)).thenReturn(pom);
    when(pom.getLocation()).thenReturn(new Path(MavenProjectManagerTest.class.getResource("/multimoduleProject/pom.xml").getFile()));
    when(pom.getFullPath()).thenReturn(new Path("/multimoduleProject/pom.xml"));
    when(project.getFullPath()).thenReturn(new Path("/multimoduleProject/"));
    when(testProject.getFile(MavenConstants.POM_FILE_NAME)).thenReturn(testPom);
    when(subModuleProject.getFile(MavenConstants.POM_FILE_NAME)).thenReturn(subPom);
    when(testProject.getFullPath()).thenReturn(new Path("/multimoduleProject/test"));
    when(subModuleProject.getFullPath()).thenReturn(new Path("/multimoduleProject/subModule"));
    when(testPom.getFullPath()).thenReturn(new Path("/multimoduleProject/test/pom.xml"));
    when(subPom.getFullPath()).thenReturn(new Path("/multimoduleProject/subModule/pom.xml"));
    when(testPom.getLocation()).thenReturn(new Path(MavenProjectManagerTest.class.getResource("/multimoduleProject/test/pom.xml").getFile()));
    when(subPom.getLocation()).thenReturn(new Path(MavenProjectManagerTest.class.getResource("/multimoduleProject/subModule/pom.xml").getFile()));
    when(workspaceRoot.getProject("/multimoduleProject/test")).thenReturn(testProject);
    when(workspaceRoot.getProject("/multimoduleProject/subModule")).thenReturn(subModuleProject);
    when(workspaceRoot.getFile(any())).thenReturn(testFile);
    when(testFile.exists()).thenReturn(false);
    projectManager.addListener(listener);
    MavenProject mavenProject = new MavenProject(project, workspace);
    mavenProject.read(project, manager);
    MavenKey mavenKey = mavenProject.getMavenKey();
    assertThat(mavenKey).isNotNull();
    projectManager.update(Collections.singletonList(project), true);
    verify(listener).projectUpdated(mapArgument.capture(), any());
}
Also used : Path(org.eclipse.core.runtime.Path) MavenKey(org.eclipse.che.maven.data.MavenKey) IFile(org.eclipse.core.resources.IFile) MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test)

Example 20 with MavenProject

use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.

the class MavenProjectManagerTest method testResolveProject.

@Test
public void testResolveProject() throws Exception {
    when(project.getFile(MavenConstants.POM_FILE_NAME)).thenReturn(pom);
    when(pom.getLocation()).thenReturn(new Path(MavenProjectManagerTest.class.getResource("/FirstProject/pom.xml").getFile()));
    when(pom.getFullPath()).thenReturn(new Path("/FirstProject/pom.xml"));
    when(project.getFullPath()).thenReturn(new Path("/FirstProject/"));
    projectManager.addListener(listener);
    MavenProject mavenProject = new MavenProject(project, workspace);
    mavenProject.read(project, manager);
    MavenKey mavenKey = mavenProject.getMavenKey();
    assertThat(mavenKey).isNotNull();
    projectManager.resolveMavenProject(project, mavenProject);
    verify(listener).projectResolved(any(), any());
}
Also used : Path(org.eclipse.core.runtime.Path) MavenKey(org.eclipse.che.maven.data.MavenKey) MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) Test(org.testng.annotations.Test)

Aggregations

MavenProject (org.eclipse.che.plugin.maven.server.core.project.MavenProject)24 IProject (org.eclipse.core.resources.IProject)16 Test (org.testng.annotations.Test)13 MavenServerManagerTest (org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)9 MavenKey (org.eclipse.che.maven.data.MavenKey)7 List (java.util.List)6 Collections (java.util.Collections)5 HashSet (java.util.HashSet)5 Set (java.util.Set)5 Inject (com.google.inject.Inject)4 Provider (com.google.inject.Provider)4 Singleton (com.google.inject.Singleton)4 ArrayList (java.util.ArrayList)4 LinkedList (java.util.LinkedList)4 Collectors (java.util.stream.Collectors)4 Path (org.eclipse.core.runtime.Path)4 Map (java.util.Map)3 ProjectRegistry (org.eclipse.che.api.project.server.ProjectRegistry)3 MavenArtifact (org.eclipse.che.maven.data.MavenArtifact)3 MavenTerminal (org.eclipse.che.maven.server.MavenTerminal)3