Search in sources :

Example 1 with CFDomain

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

the class ManifestYamlEditorTest method reconcileRouteValidDomain.

@Test
public void reconcileRouteValidDomain() throws Exception {
    ClientRequests cfClient = cloudfoundry.client;
    CFDomain domain = Mockito.mock(CFDomain.class);
    when(domain.getName()).thenReturn("springsource.org");
    when(cfClient.getDomains()).thenReturn(ImmutableList.of(domain));
    Editor editor = harness.newEditor("applications:\n" + "- name: foo\n" + "  routes:\n" + "  - route: host.springsource.org\n");
    editor.assertProblems();
}
Also used : ClientRequests(org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests) CFDomain(org.springframework.ide.vscode.commons.cloudfoundry.client.CFDomain) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 2 with CFDomain

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

the class ManifestYamlEditorTest method contentAssistInsideRouteDomain.

@Test
public void contentAssistInsideRouteDomain() throws Exception {
    Editor editor;
    ImmutableList<CFDomain> domains = ImmutableList.of(mockDomain("cfapps.io"), mockDomain("dsyer.com"));
    when(cloudfoundry.client.getDomains()).thenReturn(domains);
    editor = harness.newEditor("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route:<*>");
    editor.assertCompletions("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: cfapps.io<*>", // ==============
    "applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: dsyer.com<*>");
    editor = harness.newEditor("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: <*>");
    editor.assertCompletions("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: cfapps.io<*>", // ==============
    "applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: dsyer.com<*>");
    editor = harness.newEditor("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: dsyer.<*>");
    editor.assertCompletions("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: dsyer.com<*>", // ==============
    "applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: dsyer.cfapps.io<*>");
    editor = harness.newEditor("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: test.<*>");
    CompletionItem c = editor.assertCompletions("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: test.cfapps.io<*>", // ==============
    "applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: test.dsyer.com<*>").get(0);
    assertEquals("cfapps.io", c.getLabel());
    editor = harness.newEditor("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: foo.bar.<*>");
    editor.assertCompletions("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: foo.bar.cfapps.io<*>", // ==============
    "applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: foo.bar.dsyer.com<*>");
    // / no content assist inside of path or port section of route:
    editor = harness.newEditor("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: foo.bar.com/<*>");
    editor.assertCompletions();
    editor = harness.newEditor("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: foo.bar.com:<*>");
    editor.assertCompletions();
    editor = harness.newEditor("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: foo.bar.com:7777/blah<*>");
    editor.assertCompletions();
    // Martin's most fancy example:
    editor = harness.newEditor("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: test.cf<*>pps.io/superpath\n" + "  memory: 1024M\n");
    editor.assertCompletions("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: test.cfapps.io<*>/superpath\n" + "  memory: 1024M\n");
    // Kris's variants of Martin's example:
    editor = harness.newEditor("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: test.ds<*>pps.io/superpath\n" + "  memory: 1024M\n");
    editor.assertCompletions("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: test.dsyer.com<*>/superpath\n" + "  memory: 1024M\n");
    editor = harness.newEditor("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: test.ds<*>pps.io:8888/superpath\n" + "  memory: 1024M\n");
    editor.assertCompletions("applications:\n" + "- name: test\n" + "  routes:\n" + "  - route: test.dsyer.com<*>:8888/superpath\n" + "  memory: 1024M\n");
}
Also used : CompletionItem(org.eclipse.lsp4j.CompletionItem) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) CFDomain(org.springframework.ide.vscode.commons.cloudfoundry.client.CFDomain) Test(org.junit.Test)

Example 3 with CFDomain

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

the class ManifestYamlEditorTest method reconcileDuplicateKeys.

@Test
public void reconcileDuplicateKeys() throws Exception {
    ImmutableList<CFDomain> domains = ImmutableList.of(mockDomain("pivotal.io"), mockDomain("otherdomain.org"));
    when(cloudfoundry.client.getDomains()).thenReturn(domains);
    Editor editor = harness.newEditor("#comment\n" + "applications:\n" + "- buildpack: zbuildpack\n" + "  name: foo\n" + "  domains:\n" + "  - pivotal.io\n" + "  domains:\n" + "  - otherdomain.org\n");
    editor.assertProblems("domains|Duplicate key", "domains|Duplicate key");
}
Also used : CFDomain(org.springframework.ide.vscode.commons.cloudfoundry.client.CFDomain) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 4 with CFDomain

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

the class ManifestYamlEditorTest method domainsContentAssist.

@Test
public void domainsContentAssist() throws Exception {
    ClientRequests cfClient = cloudfoundry.client;
    CFDomain domain = Mockito.mock(CFDomain.class);
    when(domain.getName()).thenReturn("cfapps.io");
    when(cfClient.getDomains()).thenReturn(ImmutableList.of(domain));
    CompletionItem completion = assertCompletions("domains:\n" + "- <*>", // ===>
    "domains:\n" + "- cfapps.io<*>").get(0);
    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) CFDomain(org.springframework.ide.vscode.commons.cloudfoundry.client.CFDomain) Test(org.junit.Test)

Example 5 with CFDomain

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

CFDomain (org.springframework.ide.vscode.commons.cloudfoundry.client.CFDomain)9 Test (org.junit.Test)8 Editor (org.springframework.ide.vscode.languageserver.testharness.Editor)6 ClientRequests (org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests)4 CompletionItem (org.eclipse.lsp4j.CompletionItem)3 Diagnostic (org.eclipse.lsp4j.Diagnostic)2