Search in sources :

Example 1 with NoTargetsException

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

the class CFClientTest method testNoTarget.

@Test
public void testNoTarget() throws Exception {
    when(cloudfoundry.paramsProvider.getParams()).thenThrow(new NoTargetsException(expectedMessages.noTargetsFound()));
    assertError(() -> targetCache.getOrCreate(), NoTargetsException.class, expectedMessages.noTargetsFound());
}
Also used : NoTargetsException(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException) Test(org.junit.Test)

Example 2 with NoTargetsException

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

the class ManifestYamlEditorTest method servicesContentAssistWhenNotLoggedIn_ErrorProposalsDisabled.

@Test
public void servicesContentAssistWhenNotLoggedIn_ErrorProposalsDisabled() throws Exception {
    System.setProperty("lsp.yaml.completions.errors.disable", "true");
    reset(cloudfoundry.defaultParamsProvider);
    when(cloudfoundry.defaultParamsProvider.getParams()).thenThrow(new NoTargetsException("No Cloudfoundry Targets: Please login"));
    String textBefore = "applications:\n" + "- name: foo\n" + "  services:\n" + "  - <*>";
    Editor editor = harness.newEditor(textBefore);
    // Applying the single completion should do nothing in the editor:
    assertEquals(0, editor.assertCompletions().size());
}
Also used : NoTargetsException(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 3 with NoTargetsException

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

the class ManifestYamlEditorTest method servicesContentAssistShowErrorMessageWhenNotLoggedIn.

@Test
public void servicesContentAssistShowErrorMessageWhenNotLoggedIn() throws Exception {
    reset(cloudfoundry.defaultParamsProvider);
    when(cloudfoundry.defaultParamsProvider.getParams()).thenThrow(new NoTargetsException("No Cloudfoundry Targets: Please login"));
    String textBefore = "applications:\n" + "- name: foo\n" + "  services:\n" + "  - <*>";
    Editor editor = harness.newEditor(textBefore);
    // Applying the single completion should do nothing in the editor:
    editor.assertCompletions(textBefore);
    // The message from the exception should appear in the 'doc string':
    editor.assertCompletionDetails("No Cloudfoundry Targets", "Error", "Please login");
}
Also used : NoTargetsException(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 4 with NoTargetsException

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

the class ManifestYamlEditorTest method servicesContentAssistShowErrorMessageWhenNotLoggedIn_nonEmptyQueryString.

@Test
public void servicesContentAssistShowErrorMessageWhenNotLoggedIn_nonEmptyQueryString() throws Exception {
    reset(cloudfoundry.defaultParamsProvider);
    when(cloudfoundry.defaultParamsProvider.getParams()).thenThrow(new NoTargetsException("No Cloudfoundry Targets: Please login"));
    String textBefore = "applications:\n" + "- name: foo\n" + "  services:\n" + "  - something<*>";
    Editor editor = harness.newEditor(textBefore);
    // Applying the single completion should do nothing in the editor:
    editor.assertCompletions(textBefore);
    // The message from the exception should appear in the 'doc string':
    CompletionItem completion = editor.assertCompletionDetails("No Cloudfoundry Targets", "Error", "Please login");
    // query string should match the 'filter text' otherwise vscode will filter the item and it will be gone!
    assertEquals("something", completion.getFilterText());
}
Also used : NoTargetsException(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException) CompletionItem(org.eclipse.lsp4j.CompletionItem) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 5 with NoTargetsException

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

Aggregations

NoTargetsException (org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException)7 Test (org.junit.Test)5 Editor (org.springframework.ide.vscode.languageserver.testharness.Editor)3 CompletionItem (org.eclipse.lsp4j.CompletionItem)2 ImmutableList (com.google.common.collect.ImmutableList)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 CFBuildpack (org.springframework.ide.vscode.commons.cloudfoundry.client.CFBuildpack)1 CFRoute (org.springframework.ide.vscode.commons.cloudfoundry.client.CFRoute)1 ClientRequests (org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests)1 CFParamsProviderMessages (org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFParamsProviderMessages)1 Target (org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CfTargetsInfo.Target)1 CfTargetsInfoProvder (org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CfTargetsInfoProvder)1 ClientParamsProvider (org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.ClientParamsProvider)1 ConnectionException (org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.ConnectionException)1 ReconcileException (org.springframework.ide.vscode.commons.languageserver.reconcile.ReconcileException)1 ValueParseException (org.springframework.ide.vscode.commons.util.ValueParseException)1