Search in sources :

Example 1 with CodeAction

use of org.springframework.ide.vscode.languageserver.testharness.CodeAction in project sts4 by spring-projects.

the class BoshEditorTest method missingPropertiesQuickfix.

@Test
public void missingPropertiesQuickfix() throws Exception {
    Editor editor = harness.newEditor("name: blah\n" + "stemcells:\n" + "- alias: ubuntu\n" + "  os: ubuntu-trusty\n" + "  version: 3421.11\n" + "- alias: centos\n" + "  os: centos-7\n" + "  version: latest");
    Diagnostic problem = editor.assertProblems("t|Properties [instance_groups, releases, update] are required").get(0);
    CodeAction quickfix = editor.assertCodeAction(problem);
    assertEquals("Add properties: [instance_groups, releases, update]", quickfix.getLabel());
    quickfix.perform();
    editor.assertText("name: blah\n" + "stemcells:\n" + "- alias: ubuntu\n" + "  os: ubuntu-trusty\n" + "  version: 3421.11\n" + "- alias: centos\n" + "  os: centos-7\n" + "  version: latest\n" + "releases:\n" + "- name: <*>\n" + "  version: \n" + "update:\n" + "  canaries: \n" + "  max_in_flight: \n" + "  canary_watch_time: \n" + "  update_watch_time: \n" + "instance_groups:\n" + "- name: \n" + "  azs:\n" + "  - \n" + "  instances: \n" + "  jobs:\n" + "  - name: \n" + "    release: \n" + "  vm_type: \n" + "  stemcell: \n" + "  networks:\n" + "  - name: ");
}
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)

Example 2 with CodeAction

use of org.springframework.ide.vscode.languageserver.testharness.CodeAction in project sts4 by spring-projects.

the class ConcourseEditorTest method addSingleRequiredPropertiesQuickfix.

@Test
public void addSingleRequiredPropertiesQuickfix() throws Exception {
    Editor editor = harness.newEditor("resources:\n" + "- name: foo\n" + "  source:\n" + "    username: someone\n" + "# Confuse");
    Diagnostic problem = editor.assertProblems("-|'type' is required", "foo|Unused").get(0);
    CodeAction quickfix = editor.assertCodeAction(problem);
    assertEquals("Add property 'type'", quickfix.getLabel());
    quickfix.perform();
    editor.assertText("resources:\n" + "- name: foo\n" + "  source:\n" + "    username: someone\n" + "  type: <*>\n" + "# Confuse");
}
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)

Example 3 with CodeAction

use of org.springframework.ide.vscode.languageserver.testharness.CodeAction in project sts4 by spring-projects.

the class ConcourseEditorTest method addMultipleRequiredPropertiesQuickfix.

@Test
public void addMultipleRequiredPropertiesQuickfix() throws Exception {
    Editor editor = harness.newEditor("resources:\n" + "- name: foo\n" + "  type: pool\n" + "  source:\n" + "    username: someone\n");
    Diagnostic problem = editor.assertProblems("foo|Unused", "source|[branch, pool, uri] are required").get(1);
    CodeAction quickfix = editor.assertCodeAction(problem);
    assertEquals("Add properties: [branch, pool, uri]", quickfix.getLabel());
    quickfix.perform();
    editor.assertText("resources:\n" + "- name: foo\n" + "  type: pool\n" + "  source:\n" + "    username: someone\n" + "    uri: <*>\n" + "    branch: \n" + "    pool: \n");
}
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)

Example 4 with CodeAction

use of org.springframework.ide.vscode.languageserver.testharness.CodeAction in project sts4 by spring-projects.

the class ConcourseEditorTest method quickfixForOneOfMultipleMarkersOnSameRange.

@Test
public void quickfixForOneOfMultipleMarkersOnSameRange() throws Exception {
    Editor editor = harness.newEditor("jobs:\n" + "- name: myjob\n" + "  plan:\n" + "  - task: foo\n" + "    config:\n" + "      inputs:\n" + "      - name: foo");
    List<Diagnostic> problems = editor.assertProblems("config|[image_resource, rootfs_uri, image] is required", "config|[platform, run] are required");
    assertTrue(editor.getCodeActions(problems.get(0)).isEmpty());
    CodeAction quickfix = editor.assertCodeAction(problems.get(1));
    assertEquals("Add properties: [platform, run]", quickfix.getLabel());
    quickfix.perform();
    editor.assertText("jobs:\n" + "- name: myjob\n" + "  plan:\n" + "  - task: foo\n" + "    config:\n" + "      inputs:\n" + "      - name: foo\n" + "      platform: <*>\n" + "      run:\n" + "        path: ");
}
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)

Example 5 with CodeAction

use of org.springframework.ide.vscode.languageserver.testharness.CodeAction 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)5 Test (org.junit.Test)5 CodeAction (org.springframework.ide.vscode.languageserver.testharness.CodeAction)5 Editor (org.springframework.ide.vscode.languageserver.testharness.Editor)5