Search in sources :

Example 51 with Diagnostic

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

the class ManifestYamlEditorTest method reconcileHealthCheckType.

@Test
public void reconcileHealthCheckType() 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: foo\n" + "  health-check-type: none");
    problem = editor.assertProblems("none|'none' is deprecated in favor of 'process'").get(0);
    assertEquals(DiagnosticSeverity.Warning, problem.getSeverity());
    editor = harness.newEditor("applications:\n" + "- name: foo\n" + "  health-check-type: port");
    editor.assertProblems();
    editor = harness.newEditor("applications:\n" + "- name: foo\n" + "  health-check-type: process");
    editor.assertProblems();
}
Also used : Diagnostic(org.eclipse.lsp4j.Diagnostic) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 52 with Diagnostic

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

the class ManifestYamlEditorTest method reconcileShowsWarningOnUnknownService.

@Test
public void reconcileShowsWarningOnUnknownService() throws Exception {
    ClientRequests cfClient = cloudfoundry.client;
    CFServiceInstance service = Mockito.mock(CFServiceInstance.class);
    when(service.getName()).thenReturn("myservice");
    when(cfClient.getServices()).thenReturn(ImmutableList.of(service));
    Editor editor = harness.newEditor("applications:\n" + "- name: foo\n" + "  services:\n" + "  - bad-service\n");
    editor.assertProblems("bad-service|There is no service instance called");
    Diagnostic problem = editor.assertProblem("bad-service");
    assertEquals(DiagnosticSeverity.Warning, problem.getSeverity());
}
Also used : Diagnostic(org.eclipse.lsp4j.Diagnostic) ClientRequests(org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests) CFServiceInstance(org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 53 with Diagnostic

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

the class ManifestYamlEditorTest method domainReconcile.

@Test
public void domainReconcile() throws Exception {
    List<CFDomain> domains = ImmutableList.of(mockDomain("one.com"), mockDomain("two.com"));
    when(cloudfoundry.client.getDomains()).thenReturn(domains);
    Editor editor;
    Diagnostic p;
    editor = harness.newEditor("domain: bad.com");
    p = editor.assertProblems("bad.com|unknown 'Domain'. Valid values are: [one.com, two.com]").get(0);
    assertEquals(DiagnosticSeverity.Warning, p.getSeverity());
    editor = harness.newEditor("domains:\n" + "- one.com\n" + "- bad.com\n" + "- two.com");
    editor.assertProblems("bad.com|unknown 'Domain'. Valid values are: [one.com, two.com]");
}
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)

Example 54 with Diagnostic

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

the class ManifestYamlEditorTest method reconcileShowsWarningOnNoService.

@Test
public void reconcileShowsWarningOnNoService() throws Exception {
    ClientRequests cfClient = cloudfoundry.client;
    when(cfClient.getServices()).thenReturn(ImmutableList.of());
    Editor editor = harness.newEditor("applications:\n" + "- name: foo\n" + "  services:\n" + "  - bad-service\n");
    editor.assertProblems("bad-service|There is no service instance called");
    Diagnostic problem = editor.assertProblem("bad-service");
    assertEquals(DiagnosticSeverity.Warning, problem.getSeverity());
}
Also used : Diagnostic(org.eclipse.lsp4j.Diagnostic) ClientRequests(org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 55 with Diagnostic

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

the class ManifestYamlEditorTest method deprecatedHealthCheckTypeQuickfix.

@Test
public void deprecatedHealthCheckTypeQuickfix() throws Exception {
    Editor editor = harness.newEditor("applications:\n" + "- name: foo\n" + "  health-check-type: none");
    Diagnostic problem = editor.assertProblems("none|'none' is deprecated in favor of 'process'").get(0);
    assertEquals(DiagnosticSeverity.Warning, problem.getSeverity());
    CodeAction quickfix = editor.assertCodeAction(problem);
    assertEquals("Replace deprecated value 'none' by 'process'", quickfix.getLabel());
    quickfix.perform();
    editor.assertRawText("applications:\n" + "- name: foo\n" + "  health-check-type: process");
}
Also used : CodeAction(org.springframework.ide.vscode.languageserver.testharness.CodeAction) Diagnostic(org.eclipse.lsp4j.Diagnostic) 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