Allow CF Client Params provider to be set into language server

This is to allow the params provider to be mocked or to support any
other type of params provider in the language server
This commit is contained in:
nsingh
2017-01-23 11:04:47 -08:00
parent 2e3f4f8cb8
commit 71d68bb58a
2 changed files with 9 additions and 4 deletions

View File

@@ -50,13 +50,15 @@ public class ManifestYamlLanguageServer extends SimpleLanguageServer {
private YamlSchema schema;
private CFTargetCache cfTargetCache;
private final CloudFoundryClientFactory cfClientFactory;
private final ClientParamsProvider cfParamsProvider;
public ManifestYamlLanguageServer() {
this(DefaultCloudFoundryClientFactoryV2.INSTANCE);
this(DefaultCloudFoundryClientFactoryV2.INSTANCE, new CfCliParamsProvider());
}
public ManifestYamlLanguageServer(CloudFoundryClientFactory cfClientFactory) {
public ManifestYamlLanguageServer(CloudFoundryClientFactory cfClientFactory, ClientParamsProvider cfParamsProvider) {
this.cfClientFactory = cfClientFactory;
this.cfParamsProvider=cfParamsProvider;
SimpleTextDocumentService documents = getTextDocumentService();
YamlASTProvider parser = new YamlParser(yaml);
@@ -98,7 +100,7 @@ public class ManifestYamlLanguageServer extends SimpleLanguageServer {
private CFTargetCache getCfTargetCache() {
if (cfTargetCache == null) {
ClientParamsProvider paramsProvider = new CfCliParamsProvider();
ClientParamsProvider paramsProvider = cfParamsProvider;
CloudFoundryClientFactory clientFactory = cfClientFactory;
cfTargetCache = new CFTargetCache(paramsProvider, clientFactory, new ClientTimeouts());
}

View File

@@ -19,6 +19,8 @@ import org.eclipse.lsp4j.Diagnostic;
import org.junit.Before;
import org.junit.Test;
import org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests;
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CfCliParamsProvider;
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.ClientParamsProvider;
import org.springframework.ide.vscode.languageserver.testharness.Editor;
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
@@ -26,9 +28,10 @@ public class ManifestYamlEditorTest {
LanguageServerHarness harness;
MockCloudfoundry cfClientFactory = new MockCloudfoundry();
ClientParamsProvider cfParamsProvider = new CfCliParamsProvider();
@Before public void setup() throws Exception {
harness = new LanguageServerHarness(()-> new ManifestYamlLanguageServer(cfClientFactory));
harness = new LanguageServerHarness(()-> new ManifestYamlLanguageServer(cfClientFactory, cfParamsProvider));
harness.intialize(null);
}