Search in sources :

Example 1 with Condition

use of org.fest.assertions.Condition 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();
        }
    });
}
Also used : JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) ListIterator(java.util.ListIterator) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) Test(org.testng.annotations.Test) MavenCommunication(org.eclipse.che.plugin.maven.server.core.MavenCommunication) MavenArtifact(org.eclipse.che.maven.data.MavenArtifact) Constants(org.eclipse.che.ide.ext.java.shared.Constants) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest) Assert.assertThat(org.junit.Assert.assertThat) Assertions.assertThat(org.fest.assertions.Assertions.assertThat) IPath(org.eclipse.core.runtime.IPath) Model(org.eclipse.che.ide.maven.tools.Model) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) IJavaProject(org.eclipse.jdt.core.IJavaProject) BeforeMethod(org.testng.annotations.BeforeMethod) MessageType(org.eclipse.che.plugin.maven.shared.MessageType) Set(java.util.Set) MavenExecutorService(org.eclipse.che.plugin.maven.server.core.MavenExecutorService) Collectors(java.util.stream.Collectors) RemoteException(java.rmi.RemoteException) MavenKey(org.eclipse.che.maven.data.MavenKey) List(java.util.List) Stream(java.util.stream.Stream) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) Path(org.eclipse.core.runtime.Path) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) FolderEntry(org.eclipse.che.api.project.server.FolderEntry) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) Mockito.mock(org.mockito.Mockito.mock) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) JavaProject(org.eclipse.jdt.internal.core.JavaProject) Condition(org.fest.assertions.Condition) ArrayList(java.util.ArrayList) TEST_SOURCE_FOLDER(org.eclipse.che.plugin.maven.shared.MavenAttributes.TEST_SOURCE_FOLDER) VirtualFile(org.eclipse.che.api.vfs.VirtualFile) IProject(org.eclipse.core.resources.IProject) ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) JavaCore(org.eclipse.jdt.core.JavaCore) CoreMatchers.hasItems(org.hamcrest.CoreMatchers.hasItems) Mockito.when(org.mockito.Mockito.when) File(java.io.File) Provider(com.google.inject.Provider) NotificationMessage(org.eclipse.che.plugin.maven.shared.dto.NotificationMessage) IJavaElement(org.eclipse.jdt.core.IJavaElement) MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) IJavaProject(org.eclipse.jdt.core.IJavaProject) JavaProject(org.eclipse.jdt.internal.core.JavaProject) IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) JsonObject(com.google.gson.JsonObject) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Example 2 with Condition

use of org.fest.assertions.Condition in project che by eclipse.

the class WorkspaceTest method testShouldContainsCustomTestSourceDirectory.

@Test
public void testShouldContainsCustomTestSourceDirectory() 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>" + "<build>" + "<testSourceDirectory>/mytest</testSourceDirectory>" + "</build>";
    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).toOSString().endsWith("test");
                }
                return false;
            }).findFirst().isPresent();
        }
    });
}
Also used : JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) ListIterator(java.util.ListIterator) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) Test(org.testng.annotations.Test) MavenCommunication(org.eclipse.che.plugin.maven.server.core.MavenCommunication) MavenArtifact(org.eclipse.che.maven.data.MavenArtifact) Constants(org.eclipse.che.ide.ext.java.shared.Constants) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest) Assert.assertThat(org.junit.Assert.assertThat) Assertions.assertThat(org.fest.assertions.Assertions.assertThat) IPath(org.eclipse.core.runtime.IPath) Model(org.eclipse.che.ide.maven.tools.Model) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) IJavaProject(org.eclipse.jdt.core.IJavaProject) BeforeMethod(org.testng.annotations.BeforeMethod) MessageType(org.eclipse.che.plugin.maven.shared.MessageType) Set(java.util.Set) MavenExecutorService(org.eclipse.che.plugin.maven.server.core.MavenExecutorService) Collectors(java.util.stream.Collectors) RemoteException(java.rmi.RemoteException) MavenKey(org.eclipse.che.maven.data.MavenKey) List(java.util.List) Stream(java.util.stream.Stream) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) Path(org.eclipse.core.runtime.Path) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) FolderEntry(org.eclipse.che.api.project.server.FolderEntry) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) Mockito.mock(org.mockito.Mockito.mock) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) JavaProject(org.eclipse.jdt.internal.core.JavaProject) Condition(org.fest.assertions.Condition) ArrayList(java.util.ArrayList) TEST_SOURCE_FOLDER(org.eclipse.che.plugin.maven.shared.MavenAttributes.TEST_SOURCE_FOLDER) VirtualFile(org.eclipse.che.api.vfs.VirtualFile) IProject(org.eclipse.core.resources.IProject) ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) JavaCore(org.eclipse.jdt.core.JavaCore) CoreMatchers.hasItems(org.hamcrest.CoreMatchers.hasItems) Mockito.when(org.mockito.Mockito.when) File(java.io.File) Provider(com.google.inject.Provider) NotificationMessage(org.eclipse.che.plugin.maven.shared.dto.NotificationMessage) IJavaElement(org.eclipse.jdt.core.IJavaElement) MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) IJavaProject(org.eclipse.jdt.core.IJavaProject) JavaProject(org.eclipse.jdt.internal.core.JavaProject) IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) JsonObject(com.google.gson.JsonObject) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Example 3 with Condition

use of org.fest.assertions.Condition in project che by eclipse.

the class WorkspaceTest method testShouldContainsDefaultTestSourceDirectory.

@Test
public void testShouldContainsDefaultTestSourceDirectory() 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>" + "<build>" + "</build>";
    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).toOSString().endsWith("src/test/java");
                }
                return false;
            }).findFirst().isPresent();
        }
    });
}
Also used : JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) ListIterator(java.util.ListIterator) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) Test(org.testng.annotations.Test) MavenCommunication(org.eclipse.che.plugin.maven.server.core.MavenCommunication) MavenArtifact(org.eclipse.che.maven.data.MavenArtifact) Constants(org.eclipse.che.ide.ext.java.shared.Constants) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest) Assert.assertThat(org.junit.Assert.assertThat) Assertions.assertThat(org.fest.assertions.Assertions.assertThat) IPath(org.eclipse.core.runtime.IPath) Model(org.eclipse.che.ide.maven.tools.Model) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) IJavaProject(org.eclipse.jdt.core.IJavaProject) BeforeMethod(org.testng.annotations.BeforeMethod) MessageType(org.eclipse.che.plugin.maven.shared.MessageType) Set(java.util.Set) MavenExecutorService(org.eclipse.che.plugin.maven.server.core.MavenExecutorService) Collectors(java.util.stream.Collectors) RemoteException(java.rmi.RemoteException) MavenKey(org.eclipse.che.maven.data.MavenKey) List(java.util.List) Stream(java.util.stream.Stream) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) Path(org.eclipse.core.runtime.Path) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) FolderEntry(org.eclipse.che.api.project.server.FolderEntry) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) Mockito.mock(org.mockito.Mockito.mock) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) JavaProject(org.eclipse.jdt.internal.core.JavaProject) Condition(org.fest.assertions.Condition) ArrayList(java.util.ArrayList) TEST_SOURCE_FOLDER(org.eclipse.che.plugin.maven.shared.MavenAttributes.TEST_SOURCE_FOLDER) VirtualFile(org.eclipse.che.api.vfs.VirtualFile) IProject(org.eclipse.core.resources.IProject) ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) JavaCore(org.eclipse.jdt.core.JavaCore) CoreMatchers.hasItems(org.hamcrest.CoreMatchers.hasItems) Mockito.when(org.mockito.Mockito.when) File(java.io.File) Provider(com.google.inject.Provider) NotificationMessage(org.eclipse.che.plugin.maven.shared.dto.NotificationMessage) IJavaElement(org.eclipse.jdt.core.IJavaElement) MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) IJavaProject(org.eclipse.jdt.core.IJavaProject) JavaProject(org.eclipse.jdt.internal.core.JavaProject) IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) JsonObject(com.google.gson.JsonObject) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Example 4 with Condition

use of org.fest.assertions.Condition in project che by eclipse.

the class WorkspaceTest method testProjectHasBuildWithoutSources.

@Test
public void testProjectHasBuildWithoutSources() 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>" + "<build>" + "</build>";
    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).toOSString().endsWith("src/main/java");
                }
                return false;
            }).findFirst().isPresent();
        }
    });
}
Also used : JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) ListIterator(java.util.ListIterator) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) Test(org.testng.annotations.Test) MavenCommunication(org.eclipse.che.plugin.maven.server.core.MavenCommunication) MavenArtifact(org.eclipse.che.maven.data.MavenArtifact) Constants(org.eclipse.che.ide.ext.java.shared.Constants) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest) Assert.assertThat(org.junit.Assert.assertThat) Assertions.assertThat(org.fest.assertions.Assertions.assertThat) IPath(org.eclipse.core.runtime.IPath) Model(org.eclipse.che.ide.maven.tools.Model) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) IJavaProject(org.eclipse.jdt.core.IJavaProject) BeforeMethod(org.testng.annotations.BeforeMethod) MessageType(org.eclipse.che.plugin.maven.shared.MessageType) Set(java.util.Set) MavenExecutorService(org.eclipse.che.plugin.maven.server.core.MavenExecutorService) Collectors(java.util.stream.Collectors) RemoteException(java.rmi.RemoteException) MavenKey(org.eclipse.che.maven.data.MavenKey) List(java.util.List) Stream(java.util.stream.Stream) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) Path(org.eclipse.core.runtime.Path) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) FolderEntry(org.eclipse.che.api.project.server.FolderEntry) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) Mockito.mock(org.mockito.Mockito.mock) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) JavaProject(org.eclipse.jdt.internal.core.JavaProject) Condition(org.fest.assertions.Condition) ArrayList(java.util.ArrayList) TEST_SOURCE_FOLDER(org.eclipse.che.plugin.maven.shared.MavenAttributes.TEST_SOURCE_FOLDER) VirtualFile(org.eclipse.che.api.vfs.VirtualFile) IProject(org.eclipse.core.resources.IProject) ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) JavaCore(org.eclipse.jdt.core.JavaCore) CoreMatchers.hasItems(org.hamcrest.CoreMatchers.hasItems) Mockito.when(org.mockito.Mockito.when) File(java.io.File) Provider(com.google.inject.Provider) NotificationMessage(org.eclipse.che.plugin.maven.shared.dto.NotificationMessage) IJavaElement(org.eclipse.jdt.core.IJavaElement) MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) IJavaProject(org.eclipse.jdt.core.IJavaProject) JavaProject(org.eclipse.jdt.internal.core.JavaProject) IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) JsonObject(com.google.gson.JsonObject) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Aggregations

JsonObject (com.google.gson.JsonObject)4 Provider (com.google.inject.Provider)4 File (java.io.File)4 RemoteException (java.rmi.RemoteException)4 ArrayList (java.util.ArrayList)4 Arrays (java.util.Arrays)4 Collections (java.util.Collections)4 List (java.util.List)4 ListIterator (java.util.ListIterator)4 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 Stream (java.util.stream.Stream)4 FolderEntry (org.eclipse.che.api.project.server.FolderEntry)4 ProjectRegistry (org.eclipse.che.api.project.server.ProjectRegistry)4 RegisteredProject (org.eclipse.che.api.project.server.RegisteredProject)4 VirtualFile (org.eclipse.che.api.vfs.VirtualFile)4 Constants (org.eclipse.che.ide.ext.java.shared.Constants)4 Model (org.eclipse.che.ide.maven.tools.Model)4 MavenArtifact (org.eclipse.che.maven.data.MavenArtifact)4 MavenKey (org.eclipse.che.maven.data.MavenKey)4