Search in sources :

Example 1 with CFServiceInstance

use of org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance in project sts4 by spring-projects.

the class ManifestYamlEditorTest method dashedContentAssistForServices.

@Test
public void dashedContentAssistForServices() throws Exception {
    Editor editor;
    CFServiceInstance service = mock(CFServiceInstance.class);
    when(cloudfoundry.client.getServices()).thenReturn(ImmutableList.of(service));
    when(service.getName()).thenReturn("my-service");
    when(service.getPlan()).thenReturn("cheap-plan");
    editor = harness.newEditor("services:\n" + "- blah\n" + "ser<*>");
    editor.assertCompletionWithLabel((s) -> s.startsWith("- "), "services:\n" + "- blah\n" + "- my-service<*>");
    editor = harness.newEditor("services:\n" + "- blah\n" + "<*>");
    editor.assertCompletionWithLabel((s) -> s.startsWith("- "), "services:\n" + "- blah\n" + "- my-service<*>");
    editor = harness.newEditor("applications:\n" + "- name: foo\n" + "  services:<*>\n");
    editor.assertCompletions("applications:\n" + "- name: foo\n" + "  services: \n" + "  - my-service<*>\n");
    editor = harness.newEditor("applications:\n" + "- name: foo\n" + "  services: <*>\n");
    editor.assertCompletionLabels("- my-service - cheap-plan");
    editor.assertCompletions("applications:\n" + "- name: foo\n" + "  services: \n" + "  - my-service<*>\n");
    editor = harness.newEditor("applications:\n" + "- name: foo\n" + "  services: ser<*>\n");
    editor.assertCompletions("applications:\n" + "- name: foo\n" + "  services: \n" + "  - my-service<*>\n");
    editor = harness.newEditor("applications:\n" + "- name: foo\n" + "  services: \n" + "  - blah\n" + "  <*>\n");
    editor.assertCompletionWithLabel((s) -> s.startsWith("- "), "applications:\n" + "- name: foo\n" + "  services: \n" + "  - blah\n" + "  - my-service<*>\n");
}
Also used : Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) CFServiceInstance(org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance) Test(org.junit.Test)

Example 2 with CFServiceInstance

use of org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance in project sts4 by spring-projects.

the class ManifestYamlEditorTest method serviceContentAssist.

@Test
public void serviceContentAssist() throws Exception {
    ClientRequests cfClient = cloudfoundry.client;
    CFServiceInstance service = Mockito.mock(CFServiceInstance.class);
    when(service.getName()).thenReturn("mysql");
    when(service.getPlan()).thenReturn("medium");
    when(cfClient.getServices()).thenReturn(ImmutableList.of(service));
    CompletionItem completion = assertCompletions("services:\n" + "  - <*>", // ==>
    "services:\n" + "  - mysql<*>").get(0);
    assertEquals("mysql - medium", completion.getLabel());
    assertEquals("an-org : a-space [test.io]", completion.getDocumentation());
}
Also used : CompletionItem(org.eclipse.lsp4j.CompletionItem) ClientRequests(org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests) CFServiceInstance(org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance) Test(org.junit.Test)

Example 3 with CFServiceInstance

use of org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance in project sts4 by spring-projects.

the class ManifestYamlEditorTest method reconcileCFService.

@Test
public void reconcileCFService() 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" + "  - myservice\n");
    // Should have no problems
    editor.assertProblems();
}
Also used : 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 4 with CFServiceInstance

use of org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance 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 5 with CFServiceInstance

use of org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance in project sts4 by spring-projects.

the class ManifestYamlEditorTest method noRelaxedValueCompletionsInListItemContexts.

@Test
public void noRelaxedValueCompletionsInListItemContexts() throws Exception {
    // See: https://www.pivotaltracker.com/story/show/144393355
    CFServiceInstance service = mock(CFServiceInstance.class);
    when(cloudfoundry.client.getServices()).thenReturn(ImmutableList.of(service));
    when(service.getName()).thenReturn("my-service");
    when(service.getPlan()).thenReturn("cheap-plan");
    Editor editor = harness.newEditor("services:\n" + "- some-service\n" + "<*>");
    editor.assertCompletions((c) -> c.getLabel().contains("my-service"), "services:\n" + "- some-service\n" + "- my-service<*>");
}
Also used : CFServiceInstance(org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 CFServiceInstance (org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance)5 Editor (org.springframework.ide.vscode.languageserver.testharness.Editor)4 ClientRequests (org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests)3 CompletionItem (org.eclipse.lsp4j.CompletionItem)1 Diagnostic (org.eclipse.lsp4j.Diagnostic)1