Search in sources :

Example 6 with ClientRequests

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

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

the class ManifestYamlEditorTest method buildbackContentAssistNoTargets.

@Test
public void buildbackContentAssistNoTargets() throws Exception {
    ClientRequests cfClient = cloudfoundry.client;
    CFBuildpack buildPack = Mockito.mock(CFBuildpack.class);
    when(buildPack.getName()).thenReturn("java_buildpack");
    when(cfClient.getBuildpacks()).thenReturn(ImmutableList.of(buildPack));
    String title = "No targets";
    String description = "Use CLI to login";
    when(cloudfoundry.defaultParamsProvider.getParams()).thenThrow(new NoTargetsException(title + ": " + description));
    CompletionItem completion = assertCompletions("buildpack: <*>", "buildpack: <*>").get(0);
    assertEquals(title, completion.getLabel());
    assertEquals(description, completion.getDocumentation());
}
Also used : NoTargetsException(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException) CompletionItem(org.eclipse.lsp4j.CompletionItem) CFBuildpack(org.springframework.ide.vscode.commons.cloudfoundry.client.CFBuildpack) ClientRequests(org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests) Test(org.junit.Test)

Example 8 with ClientRequests

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

the class ManifestYamlEditorTest method reconcileShowsWarningOnNoService.

@Test
public void reconcileShowsWarningOnNoService() throws Exception {
    ClientRequests cfClient = cloudfoundry.client;
    when(cfClient.getServices()).thenReturn(ImmutableList.of());
    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) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 9 with ClientRequests

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

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

Test (org.junit.Test)11 ClientRequests (org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests)11 Editor (org.springframework.ide.vscode.languageserver.testharness.Editor)6 CompletionItem (org.eclipse.lsp4j.CompletionItem)5 CFDomain (org.springframework.ide.vscode.commons.cloudfoundry.client.CFDomain)4 CFServiceInstance (org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance)3 Diagnostic (org.eclipse.lsp4j.Diagnostic)2 CFBuildpack (org.springframework.ide.vscode.commons.cloudfoundry.client.CFBuildpack)2 IOException (java.io.IOException)1 NoTargetsException (org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException)1