Add a test for when bosh cli disabled or errors.

This commit is contained in:
Kris De Volder
2017-07-26 14:56:56 -07:00
parent 5cef5f7e91
commit 12b987b49c
2 changed files with 22 additions and 1 deletions

View File

@@ -17,6 +17,7 @@ import static org.mockito.Mockito.*;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.TimeoutException;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
@@ -955,6 +956,25 @@ public class BoshEditorTest {
);
}
@Test public void contentAssistStemcellNameNoDirector() throws Exception {
Editor editor;
stemcellsProvider = mock(DynamicModelProvider.class);
when(stemcellsProvider.getModel(any())).thenThrow(new IOException("Couldn't connect to bosh"));
editor = harness.newEditor(
"stemcells:\n" +
"- alias: good\n" +
" name: <*>\n"
);
List<CompletionItem> completions = editor.getCompletions();
assertEquals(1, completions.size());
CompletionItem c = completions.get(0);
c = harness.resolveCompletionItem(c);
assertContains("Couldn't connect to bosh", c.getDocumentation());
System.out.println("label = " + c.getLabel());
System.out.println("detail = " + c.getDetail());
System.out.println("doc = " + c.getDocumentation());
}
@SuppressWarnings("unchecked")
@Test public void contentAssistStemcellVersionNoDirector() throws Exception {
Editor editor;

View File

@@ -13,6 +13,7 @@ package org.springframework.ide.vscode.bosh.models;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import java.util.Map;
@@ -37,7 +38,7 @@ public class BoshCommandStemcellsProviderTest {
public BoshCommandStemcellsProvider provider = Mockito.spy(new BoshCommandStemcellsProvider(cliConfig));
@Before
public void settup() throws Exception {
public void setup() throws Exception {
Mockito.doReturn(IOUtil.toString(BoshCommandCloudConfigProviderTest.class.getResourceAsStream(MOCK_DATA_RSRC)))
.when(provider).executeCommand(Mockito.any());
}