Search in sources :

Example 6 with Editor

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

the class BoshEditorTest method cloudconfig_vm_types_subproperties.

@Test
public void cloudconfig_vm_types_subproperties() throws Exception {
    Editor editor;
    editor = harness.newEditor(LanguageId.BOSH_CLOUD_CONFIG, "vm_types:\n" + "- <*>");
    editor.assertContextualCompletions("<*>", "name: <*>");
    editor = harness.newEditor(LanguageId.BOSH_CLOUD_CONFIG, "vm_types:\n" + "- name: nice-vm\n" + "  <*>");
    editor.assertContextualCompletions(PLAIN_COMPLETION, "<*>", "cloud_properties:\n    <*>");
    editor = harness.newEditor(LanguageId.BOSH_CLOUD_CONFIG, "vm_types:\n" + "- name: nice-vm\n" + "- name: dup\n" + "- name: dup\n");
    editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
    editor.assertProblems("dup|Duplicate 'VMTypeName'", "dup|Duplicate 'VMTypeName'");
    editor = harness.newEditor(LanguageId.BOSH_CLOUD_CONFIG, "vm_types:\n" + "- name: default\n" + "  cloud_properties:\n" + "    instance_type: m1.small\n");
    editor.assertHoverContains("name", "A unique name used to identify and reference the VM type");
    editor.assertHoverContains("cloud_properties", "Describes any IaaS-specific properties needed to create VMs");
}
Also used : Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 7 with Editor

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

the class BoshEditorTest method contentAssistStemcellVersionFromDirector.

@Test
public void contentAssistStemcellVersionFromDirector() throws Exception {
    Editor editor;
    stemcellsProvider = provideStemcellsFrom(new StemcellData("ubuntu-agent", "123.4", "ubuntu"), new StemcellData("ubuntu-agent", "222.2", "ubuntu"), new StemcellData("centos-agent", "222.2", "centos"), new StemcellData("centos-agent", "333.3", "centos"));
    editor = harness.newEditor("stemcells:\n" + "- alias: good\n" + "  name: centos-agent\n" + "  version: <*>\n");
    editor.assertContextualCompletions("<*>", "222.2<*>", "333.3<*>", "latest<*>");
    editor = harness.newEditor("stemcells:\n" + "- alias: good\n" + "  os: ubuntu\n" + "  version: <*>\n");
    editor.assertContextualCompletions("<*>", "123.4<*>", "222.2<*>", "latest<*>");
    editor = harness.newEditor("stemcells:\n" + "- alias: good\n" + "  version: <*>\n");
    editor.assertContextualCompletions("<*>", "123.4<*>", "222.2<*>", "333.3<*>", "latest<*>");
    // when os and name are 'bogus' at least suggest proposals based on other prop
    editor = harness.newEditor("stemcells:\n" + "- alias: good\n" + "  name: centos-agent\n" + "  os: bogus\n" + "  version: <*>\n");
    editor.assertContextualCompletions("<*>", "222.2<*>", "333.3<*>", "latest<*>");
    editor = harness.newEditor("stemcells:\n" + "- alias: good\n" + "  os: centos\n" + "  name: bogus\n" + "  version: <*>\n");
    editor.assertContextualCompletions("<*>", "222.2<*>", "333.3<*>", "latest<*>");
    // when the os and name disagree, merge the proposals for both:
    editor = harness.newEditor("stemcells:\n" + "- alias: good\n" + // Contradicts the name
    "  os: centos\n" + // Contradicts the os
    "  name: ubuntu-agent\n" + "  version: <*>\n");
    editor.assertContextualCompletions("<*>", "123.4<*>", "222.2<*>", "333.3<*>", "latest<*>");
}
Also used : StemcellData(org.springframework.ide.vscode.bosh.models.StemcellData) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 8 with Editor

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

the class BoshEditorTest method contentAssistStemcellVersionNoDirector.

@SuppressWarnings("unchecked")
@Test
public void contentAssistStemcellVersionNoDirector() throws Exception {
    Editor editor;
    stemcellsProvider = mock(DynamicModelProvider.class);
    when(stemcellsProvider.getModel(any())).thenThrow(new IOException("Couldn't connect to bosh"));
    editor = harness.newEditor("stemcells:\n" + "- alias: good\n" + "  name: centos-agent\n" + "  version: <*>\n");
    editor.assertContextualCompletions("<*>", "latest<*>");
}
Also used : DynamicModelProvider(org.springframework.ide.vscode.bosh.models.DynamicModelProvider) IOException(java.io.IOException) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 9 with Editor

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

the class BoshEditorTest method reconcileVMtype.

@Test
public void reconcileVMtype() throws Exception {
    Editor editor = harness.newEditor("name: foo\n" + "instance_groups: \n" + "- name: some-server\n" + "  vm_type: bogus-vm\n" + "- name: other-server\n" + "  vm_type: large");
    editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
    editor.assertProblems("bogus-vm|unknown 'VMType'. Valid values are: [default, large]");
    assertEquals(1, cloudConfigProvider.getReadCount());
}
Also used : Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 10 with Editor

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

the class BoshEditorTest method reconcilePersistentDiskType2.

@Test
public void reconcilePersistentDiskType2() throws Exception {
    cloudConfigProvider.readWith(() -> "disk_types:\n" + "- name: small-disk\n" + "- name: large-disk\n");
    Editor editor = harness.newEditor("name: my-first-deployment\n" + "instance_groups:\n" + "- name: my-server1\n" + "  persistent_disk_type: small-disk\n" + "- name: my-server2\n" + "  persistent_disk_type: bogus\n" + "- name: my-server3\n" + "  persistent_disk_type: large-disk\n");
    editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
    editor.assertProblems("bogus|unknown 'DiskType'. Valid values are: [small-disk, large-disk]");
}
Also used : Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Aggregations

Editor (org.springframework.ide.vscode.languageserver.testharness.Editor)402 Test (org.junit.Test)385 AbstractPropsEditorTest (org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest)81 LiveBeansModel (org.springframework.ide.vscode.commons.boot.app.cli.livebean.LiveBeansModel)29 File (java.io.File)27 IJavaProject (org.springframework.ide.vscode.commons.java.IJavaProject)24 Diagnostic (org.eclipse.lsp4j.Diagnostic)22 Ignore (org.junit.Ignore)15 CompletionItem (org.eclipse.lsp4j.CompletionItem)13 IOException (java.io.IOException)9 CFDomain (org.springframework.ide.vscode.commons.cloudfoundry.client.CFDomain)6 ClientRequests (org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests)6 CodeAction (org.springframework.ide.vscode.languageserver.testharness.CodeAction)5 ReleaseData (org.springframework.ide.vscode.bosh.models.ReleaseData)4 CFServiceInstance (org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance)4 DynamicModelProvider (org.springframework.ide.vscode.bosh.models.DynamicModelProvider)3 NoTargetsException (org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException)3 InputStream (java.io.InputStream)2 TimeoutException (java.util.concurrent.TimeoutException)2 StemcellData (org.springframework.ide.vscode.bosh.models.StemcellData)2