Search in sources :

Example 1 with ClientRequests

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

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

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

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

the class ManifestYamlEditorTest method noReconcileErrorsWhenClientThrows.

@Test
public void noReconcileErrorsWhenClientThrows() throws Exception {
    ClientRequests cfClient = cloudfoundry.client;
    when(cfClient.getBuildpacks()).thenThrow(new IOException("Can't get buildpacks"));
    when(cfClient.getServices()).thenThrow(new IOException("Can't get services"));
    when(cfClient.getStacks()).thenThrow(new IOException("Can't get stacks"));
    Editor editor = harness.newEditor("applications:\n" + "- name: foo\n" + "  buildpack: bad-buildpack\n" + "  stack: bad-stack\n" + "  services:\n" + "  - bad-service\n" + // a token error to make sure reconciler is actually running!
    "  bogus: bad");
    editor.assertProblems("bogus|Unknown property");
}
Also used : ClientRequests(org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests) IOException(java.io.IOException) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 5 with ClientRequests

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

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