use of org.eclipse.core.resources.IProject in project che by eclipse.
the class PomReconcilerTest method testReconcilePomWhenPomContainsDependecyWithIncorrectGroupId.
@Test
public void testReconcilePomWhenPomContainsDependecyWithIncorrectGroupId() throws Exception {
String brokenDependency = " <dependency>\n" + " <groupId>junittttt</groupId>\n" + " <artifactId>junit</artifactId>\n" + " <version>3.8.1</version>\n" + " <scope>test</scope>\n" + " </dependency>\n";
MavenServerService serverService = new MavenServerService(null, projectRegistry, pm, projectManager, null, null);
FolderEntry testProject = createTestProject(PROJECT_NAME, getPomContentWithDependency(brokenDependency));
VirtualFileEntry pom = testProject.getChild("pom.xml");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
mavenWorkspace.update(Collections.singletonList(project));
mavenWorkspace.waitForUpdate();
List<Problem> problems = serverService.reconcilePom(String.format("/%s/pom.xml", PROJECT_NAME));
assertThat(problems).hasSize(1);
assertThat(problems.get(0).isError()).isTrue();
assertThat(pom).isNotNull();
}
use of org.eclipse.core.resources.IProject in project che by eclipse.
the class WorkspaceTest method testProjectNameShuldUseArtifactIdIfNotDeclared.
@Test
public void testProjectNameShuldUseArtifactIdIfNotDeclared() throws Exception {
String pom = "<groupId>test</groupId>" + "<artifactId>testArtifact</artifactId>" + "<version>42</version>" + "<dependencies>" + " <dependency>" + " <groupId>junit</groupId>" + " <artifactId>junit</artifactId>" + " <version>4.12</version>" + " </dependency>" + "</dependencies>";
createTestProject("test", pom);
IProject test = ResourcesPlugin.getWorkspace().getRoot().getProject("test");
mavenWorkspace.update(Collections.singletonList(test));
mavenWorkspace.waitForUpdate();
MavenProject mavenProject = mavenProjectManager.findMavenProject(test);
String name = mavenProject.getName();
assertThat(name).isNotNull().isNotEmpty().isEqualTo("testArtifact");
}
use of org.eclipse.core.resources.IProject in project che by eclipse.
the class WorkspaceTest method testClasspathMultimoduleProject.
@Test
public void testClasspathMultimoduleProject() throws Exception {
String pom = "<groupId>test</groupId>" + "<artifactId>testArtifact</artifactId>" + "<version>42</version>" + "<modules>" + " <module>module1</module>" + " <module>module2</module>" + "</modules>";
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>";
createTestProjectWithPackages("parent/module1", pomModule1, "org.eclipse.multi.module");
String pomModule2 = "<groupId>test</groupId>" + "<artifactId>testModule2</artifactId>" + "<version>2</version>" + "<dependencies>" + " <dependency>" + " <groupId>test</groupId>" + " <artifactId>testModule1</artifactId>" + " <version>1</version>" + " </dependency>" + "</dependencies>";
createTestProject("parent/module2", pomModule2);
IProject parent = ResourcesPlugin.getWorkspace().getRoot().getProject("parent");
mavenWorkspace.update(Collections.singletonList(parent));
mavenWorkspace.waitForUpdate();
IProject module2 = ResourcesPlugin.getWorkspace().getRoot().getProject("parent/module2");
JavaProject javaProject = (JavaProject) JavaCore.create(module2);
IJavaElement packageFragment = javaProject.findPackageFragment("org.eclipse.multi.module");
assertThat(packageFragment).isNotNull();
}
use of org.eclipse.core.resources.IProject in project che by eclipse.
the class WorkspaceTest method testUpdateProject.
@Test
public void testUpdateProject() throws Exception {
String pom = "<groupId>test</groupId>" + "<artifactId>testArtifact</artifactId>" + "<version>42</version>" + "<dependencies>" + " <dependency>" + " <groupId>junit</groupId>" + " <artifactId>junit</artifactId>" + " <version>4.12</version>" + " </dependency>" + "</dependencies>";
createTestProject("test", pom);
IProject test = ResourcesPlugin.getWorkspace().getRoot().getProject("test");
mavenWorkspace.update(Collections.singletonList(test));
mavenWorkspace.waitForUpdate();
MavenProject mavenProject = mavenProjectManager.findMavenProject(test);
List<MavenArtifact> dependencies = mavenProject.getDependencies();
assertThat(dependencies).isNotNull().hasSize(2);
assertThat(dependencies).onProperty("artifactId").contains("junit", "hamcrest-core");
assertThat(dependencies).onProperty("groupId").contains("junit", "org.hamcrest");
assertThat(dependencies).onProperty("version").contains("4.12", "1.3");
}
use of org.eclipse.core.resources.IProject in project che by eclipse.
the class WorkspaceTest method testSingleProjectClasspath.
@Test
public void testSingleProjectClasspath() throws Exception {
String pom = "<groupId>test</groupId>" + "<artifactId>testArtifact</artifactId>" + "<version>42</version>" + "<dependencies>" + " <dependency>" + " <groupId>junit</groupId>" + " <artifactId>junit</artifactId>" + " <version>4.12</version>" + " </dependency>" + "</dependencies>";
createTestProject("test", pom);
IProject test = ResourcesPlugin.getWorkspace().getRoot().getProject("test");
mavenWorkspace.update(Collections.singletonList(test));
mavenWorkspace.waitForUpdate();
JavaProject javaProject = (JavaProject) JavaCore.create(test);
IClasspathEntry[] classpath = javaProject.getResolvedClasspath();
assertThat(classpath).onProperty("path").is(new Condition<Object[]>() {
@Override
public boolean matches(Object[] value) {
return Stream.of(value).filter(o -> {
if (o instanceof IPath) {
return ((IPath) o).lastSegment().endsWith("junit-4.12.jar");
}
return false;
}).findFirst().isPresent();
}
});
}
Aggregations