Search in sources :

Example 6 with CFDomain

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

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

the class ManifestYamlEditorTest method mockDomain.

private CFDomain mockDomain(String name) {
    CFDomain domain = mock(CFDomain.class);
    when(domain.getName()).thenReturn(name);
    return domain;
}
Also used : CFDomain(org.springframework.ide.vscode.commons.cloudfoundry.client.CFDomain)

Example 8 with CFDomain

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

the class ManifestYamlEditorTest method domainContentAssist.

@Test
public void domainContentAssist() 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("domain: <*>", "domain: 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 9 with CFDomain

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

the class ManifestYamlEditorTest method delayedConstraints.

@Test
public void delayedConstraints() throws Exception {
    // This tests the two different types of delayed constraints:
    // Slow delayed constraints that require CF connection (services
    // and "faster" delayed constraints that check that 'routes' property
    // cannot exist with 'domain' and 'host'
    ClientRequests cfClient = cloudfoundry.client;
    when(cfClient.getServices()).thenReturn(ImmutableList.of());
    List<CFDomain> domains = ImmutableList.of(mockDomain("test.cfapps.io"));
    when(cloudfoundry.client.getDomains()).thenReturn(domains);
    Editor editor = harness.newEditor("applications:\n" + "- name: foo\n" + "  host: foosite\n" + "  domain: test.cfapps.io\n" + "  routes:\n" + "  - route: test.cfapps.io/path\n" + "  services:\n" + "  - bad-service\n");
    editor.assertProblems(// These are the "fast" delayed constraints
    "host|Property cannot co-exist with property 'routes'", "domain|Property cannot co-exist with property 'routes'", "routes|Property cannot co-exist with properties [domain, host]", // This is the "slow" delayed constraint
    "bad-service|There is no service instance called");
}
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)

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