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