Search in sources :

Example 6 with Problem

use of org.eclipse.che.ide.ext.java.shared.dto.Problem in project che by eclipse.

the class PomReconcilerTest method testReconcilePomWhenMavenProjectIsNotFound.

@Test
public void testReconcilePomWhenMavenProjectIsNotFound() throws Exception {
    MavenServerService serverService = new MavenServerService(null, projectRegistry, pm, projectManager, null, null);
    FolderEntry testProject = createTestProject(PROJECT_NAME, "");
    VirtualFileEntry pom = testProject.getChild("pom.xml");
    List<Problem> problems = serverService.reconcilePom(String.format("/%s/pom.xml", PROJECT_NAME));
    assertThat(problems).isEmpty();
    assertThat(pom).isNotNull();
}
Also used : FolderEntry(org.eclipse.che.api.project.server.FolderEntry) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) MavenServerService(org.eclipse.che.plugin.maven.server.rest.MavenServerService) Problem(org.eclipse.che.ide.ext.java.shared.dto.Problem) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Example 7 with Problem

use of org.eclipse.che.ide.ext.java.shared.dto.Problem in project che by eclipse.

the class PomReconcilerTest method testReconcilePomWhenPomContainsCorrectDependency.

@Test
public void testReconcilePomWhenPomContainsCorrectDependency() throws Exception {
    String dependency = "    <dependency>\n" + "        <groupId>junit</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(dependency));
    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).isEmpty();
    assertThat(pom).isNotNull();
}
Also used : FolderEntry(org.eclipse.che.api.project.server.FolderEntry) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) MavenServerService(org.eclipse.che.plugin.maven.server.rest.MavenServerService) Problem(org.eclipse.che.ide.ext.java.shared.dto.Problem) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Example 8 with Problem

use of org.eclipse.che.ide.ext.java.shared.dto.Problem in project che by eclipse.

the class PomReconcilerTest method testProblemPosition.

@Test
public void testProblemPosition() throws Exception {
    MavenServerService serverService = new MavenServerService(null, projectRegistry, pm, projectManager, null, null);
    FolderEntry testProject = createTestProject("A", "");
    VirtualFileEntry child = testProject.getChild("pom.xml");
    String newContent = getPomContent("<ss");
    child.getVirtualFile().updateContent(newContent);
    List<Problem> problems = serverService.reconcilePom("/A/pom.xml");
    assertThat(problems).isNotEmpty();
    Problem problem = problems.get(0);
    assertThat(problem.getSourceStart()).isEqualTo(newContent.indexOf("<ss") + 3);
    assertThat(problem.getSourceEnd()).isEqualTo(newContent.indexOf("<ss") + 4);
}
Also used : FolderEntry(org.eclipse.che.api.project.server.FolderEntry) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) MavenServerService(org.eclipse.che.plugin.maven.server.rest.MavenServerService) Problem(org.eclipse.che.ide.ext.java.shared.dto.Problem) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Example 9 with Problem

use of org.eclipse.che.ide.ext.java.shared.dto.Problem 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();
}
Also used : FolderEntry(org.eclipse.che.api.project.server.FolderEntry) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) MavenServerService(org.eclipse.che.plugin.maven.server.rest.MavenServerService) Problem(org.eclipse.che.ide.ext.java.shared.dto.Problem) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Example 10 with Problem

use of org.eclipse.che.ide.ext.java.shared.dto.Problem in project che by eclipse.

the class JavaReconcilerStrategy method doReconcile.

private void doReconcile(final List<Problem> problems) {
    if (this.annotationModel == null) {
        return;
    }
    ProblemRequester problemRequester;
    if (this.annotationModel instanceof ProblemRequester) {
        problemRequester = (ProblemRequester) this.annotationModel;
        problemRequester.beginReporting();
    } else {
        if (editorWithErrors != null) {
            editorWithErrors.setErrorState(EditorWithErrors.EditorState.NONE);
        }
        return;
    }
    try {
        boolean error = false;
        boolean warning = false;
        for (Problem problem : problems) {
            if (!error) {
                error = problem.isError();
            }
            if (!warning) {
                warning = problem.isWarning();
            }
            problemRequester.acceptProblem(problem);
        }
        if (editorWithErrors != null) {
            if (error) {
                editorWithErrors.setErrorState(EditorWithErrors.EditorState.ERROR);
            } else if (warning) {
                editorWithErrors.setErrorState(EditorWithErrors.EditorState.WARNING);
            } else {
                editorWithErrors.setErrorState(EditorWithErrors.EditorState.NONE);
            }
        }
    } catch (final Exception e) {
        Log.error(getClass(), e);
    } finally {
        problemRequester.endReporting();
    }
}
Also used : Problem(org.eclipse.che.ide.ext.java.shared.dto.Problem)

Aggregations

Problem (org.eclipse.che.ide.ext.java.shared.dto.Problem)15 VirtualFileEntry (org.eclipse.che.api.project.server.VirtualFileEntry)7 FolderEntry (org.eclipse.che.api.project.server.FolderEntry)6 MavenServerService (org.eclipse.che.plugin.maven.server.rest.MavenServerService)6 MavenServerManagerTest (org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)6 Test (org.testng.annotations.Test)6 IProject (org.eclipse.core.resources.IProject)5 ArrayList (java.util.ArrayList)3 ForbiddenException (org.eclipse.che.api.core.ForbiddenException)2 ServerException (org.eclipse.che.api.core.ServerException)2 MavenProjectProblem (org.eclipse.che.maven.data.MavenProjectProblem)2 BadLocationException (org.eclipse.jface.text.BadLocationException)2 Document (org.eclipse.jface.text.Document)2 Inject (com.google.inject.Inject)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiParam (io.swagger.annotations.ApiParam)1 ApiResponse (io.swagger.annotations.ApiResponse)1 ApiResponses (io.swagger.annotations.ApiResponses)1 IOException (java.io.IOException)1 Collections (java.util.Collections)1