Search in sources :

Example 26 with Diagnostic

use of org.eclipse.lsp4j.Diagnostic in project sts4 by spring-projects.

the class ConcourseEditorTest method emptyInputPathWarning.

@Test
public void emptyInputPathWarning() throws Exception {
    Editor editor = harness.newEditor(LanguageId.CONCOURSE_TASK, "platform: linux\n" + "run:\n" + "  path: blah\n" + "inputs:\n" + "- name: foo\n" + "  path: \"\"\n" + "outputs:\n" + "- name: bar\n" + "  path: \"\"\n");
    List<Diagnostic> problems = editor.assertProblems("\"\"|Empty optional String attribute is useless and can be omitted", "\"\"|Empty optional String attribute is useless and can be omitted");
    for (Diagnostic problem : problems) {
        assertEquals(DiagnosticSeverity.Warning, problem.getSeverity());
    }
}
Also used : Diagnostic(org.eclipse.lsp4j.Diagnostic) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 27 with Diagnostic

use of org.eclipse.lsp4j.Diagnostic in project sts4 by spring-projects.

the class ConcourseEditorTest method githubUriReconciling.

@Test
public void githubUriReconciling() throws Exception {
    when(github.getReposForOwner("the-owner")).thenReturn(ImmutableList.of("nice-repo", "cool-project", "good-stuff"));
    when(github.getReposForOwner("owner-no-exist")).thenReturn(null);
    String editorText = "resources:\n" + "- name: my-repo\n" + "  type: git\n" + "  source:\n" + "    uri: $$github$$the-owner/cool-project.git\n" + "- name: other-repo\n" + "  type: git\n" + "  source:\n" + "    uri: $$github$$the-owner/repo-no-exist.git\n" + "- name: different-repo\n" + "  type: git\n" + "  source:\n" + "    uri: $$github$$owner-no-exist/who-cares.git\n";
    for (String githubUriPrefix : GithubRepoContentAssistant.URI_PREFIXES) {
        Editor editor = harness.newEditor(editorText.replace("$$github$$", githubUriPrefix));
        editor.ignoreProblem(PipelineYmlSchemaProblems.UNUSED_RESOURCE);
        List<Diagnostic> problems = editor.assertProblems("repo-no-exist|Repo not found: 'repo-no-exist'", "owner-no-exist|User or Organization not found: 'owner-no-exist'");
        for (Diagnostic d : problems) {
            assertEquals(DiagnosticSeverity.Warning, d.getSeverity());
        }
    }
}
Also used : Diagnostic(org.eclipse.lsp4j.Diagnostic) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 28 with Diagnostic

use of org.eclipse.lsp4j.Diagnostic in project sts4 by spring-projects.

the class ManifestYamlEditorTest method reconcileHealthHttpEndPointIgnoredWarning.

@Test
public void reconcileHealthHttpEndPointIgnoredWarning() throws Exception {
    Editor editor;
    Diagnostic problem;
    editor = harness.newEditor("applications:\n" + "- name: my-app\n" + "  health-check-type: process\n" + "  health-check-http-endpoint: /health");
    editor.assertProblems("health-check-http-endpoint|This has no effect unless `health-check-type` is `http` (but it is currently set to `process`)");
    editor = harness.newEditor("health-check-type: http\n" + "applications:\n" + "- name: my-app\n" + "  health-check-http-endpoint: /health");
    editor.assertProblems();
    editor = harness.newEditor("applications:\n" + "- name: my-app\n" + "  health-check-http-endpoint: /health");
    problem = editor.assertProblems("health-check-http-endpoint|This has no effect unless `health-check-type` is `http` (but it is currently set to `port`)").get(0);
    assertEquals(DiagnosticSeverity.Warning, problem.getSeverity());
    editor = harness.newEditor("applications:\n" + "- name: my-app\n" + "  health-check-type: http\n" + "  health-check-http-endpoint: /health");
    editor.assertProblems();
    editor = harness.newEditor("health-check-type: http\n" + "applications:\n" + "- name: my-app\n" + "  health-check-type: process\n" + "  health-check-http-endpoint: /health");
    editor.assertProblems("health-check-http-endpoint|This has no effect unless `health-check-type` is `http` (but it is currently set to `process`)");
    editor = harness.newEditor("health-check-http-endpoint: /health");
    editor.assertProblems("health-check-http-endpoint|This has no effect unless `health-check-type` is `http` (but it is currently set to `port`)");
    editor = harness.newEditor("health-check-type: process\n" + "health-check-http-endpoint: /health");
    editor.assertProblems("health-check-http-endpoint|This has no effect unless `health-check-type` is `http` (but it is currently set to `process`)");
}
Also used : Diagnostic(org.eclipse.lsp4j.Diagnostic) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 29 with Diagnostic

use of org.eclipse.lsp4j.Diagnostic in project sts4 by spring-projects.

the class ManifestYamlEditorTest method reconcileHealthHttpEndpointValidation.

@Test
public void reconcileHealthHttpEndpointValidation() throws Exception {
    Editor editor;
    Diagnostic problem;
    editor = harness.newEditor("applications:\n" + "- name: my-app\n" + "  health-check-type: http\n" + "  health-check-http-endpoint: /health");
    editor.assertProblems();
    editor = harness.newEditor("applications:\n" + "- name: my-app\n" + "  health-check-type: http\n" + "  health-check-http-endpoint: /health/additionalpath");
    editor.assertProblems();
    editor = harness.newEditor("applications:\n" + "- name: my-app\n" + "  health-check-type: http\n" + "  health-check-http-endpoint: /health/applog.txt");
    editor.assertProblems();
    editor = harness.newEditor("applications:\n" + "- name: my-app\n" + "  health-check-type: http\n" + "  health-check-http-endpoint: /health?check=true");
    editor.assertProblems();
    editor = harness.newEditor("applications:\n" + "- name: my-app\n" + "  health-check-type: http\n" + "  health-check-http-endpoint: /?check=true");
    editor.assertProblems();
    editor = harness.newEditor("applications:\n" + "- name: my-app\n" + "  health-check-type: http\n" + "  health-check-http-endpoint:");
    problem = editor.assertProblems("|Path requires a value staring with '/'").get(0);
    assertEquals(DiagnosticSeverity.Error, problem.getSeverity());
    editor = harness.newEditor("applications:\n" + "- name: my-app\n" + "  health-check-type: http\n" + "  health-check-http-endpoint: health");
    problem = editor.assertProblems("health|Path must start with a '/'").get(0);
    assertEquals(DiagnosticSeverity.Error, problem.getSeverity());
    editor = harness.newEditor("applications:\n" + "- name: my-app\n" + "  health-check-type: http\n" + "  health-check-http-endpoint: ?check=true");
    problem = editor.assertProblems("?check=true|Path must start with a '/'").get(0);
    assertEquals(DiagnosticSeverity.Error, problem.getSeverity());
    editor = harness.newEditor("applications:\n" + "- name: my-app\n" + "  health-check-type: http\n" + "  health-check-http-endpoint: health/additionalpath");
    problem = editor.assertProblems("health/additionalpath|Path must start with a '/'").get(0);
    assertEquals(DiagnosticSeverity.Error, problem.getSeverity());
    editor = harness.newEditor("applications:\n" + "- name: my-app\n" + "  health-check-type: http\n" + "  health-check-http-endpoint: http://health/additionalpath");
    problem = editor.assertProblems("http://health/additionalpath|Path contains scheme").get(0);
    assertEquals(DiagnosticSeverity.Error, problem.getSeverity());
    editor = harness.newEditor("applications:\n" + "- name: my-app\n" + "  health-check-type: http\n" + "  health-check-http-endpoint: /health/ additionalpath");
    problem = editor.assertProblems("/health/ additionalpath|Illegal character in path").get(0);
    assertEquals(DiagnosticSeverity.Error, problem.getSeverity());
}
Also used : Diagnostic(org.eclipse.lsp4j.Diagnostic) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 30 with Diagnostic

use of org.eclipse.lsp4j.Diagnostic in project sts4 by spring-projects.

the class ManifestYamlEditorTest method reconcileRoute_Advanced.

@Test
public void reconcileRoute_Advanced() throws Exception {
    ImmutableList<CFDomain> domains = ImmutableList.of(mockDomain("somedomain.com"));
    when(cloudfoundry.client.getDomains()).thenReturn(domains);
    Editor editor = harness.newEditor("applications:\n" + "- name: foo\n" + "  routes:\n" + "  - route: springsource.org:8765/path\n");
    editor.assertProblems("springsource.org:8765/path|Unable to determine type of route");
    Diagnostic problem = editor.assertProblem("springsource.org:8765/path");
    assertEquals(DiagnosticSeverity.Error, problem.getSeverity());
    editor = harness.newEditor("applications:\n" + "- name: foo\n" + "  routes:\n" + "  - route: host.springsource.org:66000\n");
    editor.assertProblems("66000|Invalid port");
    problem = editor.assertProblem("66000");
    assertEquals(DiagnosticSeverity.Error, problem.getSeverity());
    editor = harness.newEditor("applications:\n" + "- name: foo\n" + "  routes:\n" + "  - route: host.springsource.org\n");
    editor.assertProblems("springsource.org|Unknown 'Domain'. Valid domains are: [somedomain.com]");
    problem = editor.assertProblem("springsource.org");
    assertEquals(DiagnosticSeverity.Warning, problem.getSeverity());
}
Also used : Diagnostic(org.eclipse.lsp4j.Diagnostic) CFDomain(org.springframework.ide.vscode.commons.cloudfoundry.client.CFDomain) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Aggregations

Diagnostic (org.eclipse.lsp4j.Diagnostic)56 Test (org.junit.Test)31 Editor (org.springframework.ide.vscode.languageserver.testharness.Editor)22 Range (org.eclipse.lsp4j.Range)13 ArrayList (java.util.ArrayList)12 PublishDiagnosticsParams (org.eclipse.lsp4j.PublishDiagnosticsParams)11 List (java.util.List)8 Position (org.eclipse.lsp4j.Position)8 DiagnosticSeverity (org.eclipse.lsp4j.DiagnosticSeverity)7 URI (java.net.URI)5 Path (java.nio.file.Path)5 Map (java.util.Map)5 AbstractProjectsManagerBasedTest (org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)5 Command (org.eclipse.lsp4j.Command)5 MarkedString (org.eclipse.lsp4j.MarkedString)5 CodeAction (org.springframework.ide.vscode.languageserver.testharness.CodeAction)5 IOException (java.io.IOException)4 Collections (java.util.Collections)4 HashMap (java.util.HashMap)4 ImmutableList (com.google.common.collect.ImmutableList)3