Added support for CF dynamic values for domains
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.cloudfoundry.client;
|
||||
|
||||
public interface CFDomain {
|
||||
|
||||
String getName();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.commons.cloudfoundry.client;
|
||||
|
||||
class CFDomainImpl implements CFDomain {
|
||||
|
||||
private final String name;
|
||||
|
||||
public CFDomainImpl(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CFDomainImpl other = (CFDomainImpl) obj;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -29,4 +29,7 @@ public class CFEntities {
|
||||
/* dasboard Url */ null);
|
||||
}
|
||||
|
||||
public static CFDomain createDomain(String name) {
|
||||
return new CFDomainImpl(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,6 @@ public interface ClientRequests {
|
||||
|
||||
List<CFBuildpack> getBuildpacks() throws Exception;
|
||||
List<CFServiceInstance> getServices() throws Exception;
|
||||
List<CFDomain> getDomains() throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFBuildpack;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFDomain;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests;
|
||||
|
||||
@@ -37,15 +38,21 @@ public class CFTarget {
|
||||
/*
|
||||
* Cached information
|
||||
*/
|
||||
private final LoadingCache<String, List<CFBuildpack>> buildpacksCache;
|
||||
private final LoadingCache<String, List<CFServiceInstance>> servicesCache;
|
||||
private LoadingCache<String, List<CFBuildpack>> buildpacksCache;
|
||||
private LoadingCache<String, List<CFServiceInstance>> servicesCache;
|
||||
private LoadingCache<String, List<CFDomain>> domainCache;
|
||||
private CFCallableContext callableContext;
|
||||
|
||||
public CFTarget(String targetName, CFClientParams params, ClientRequests requests, CFCallableContext callableContext) {
|
||||
public CFTarget(String targetName, CFClientParams params, ClientRequests requests,
|
||||
CFCallableContext callableContext) {
|
||||
this.params = params;
|
||||
this.requests = requests;
|
||||
this.targetName = targetName;
|
||||
this.callableContext = callableContext;
|
||||
initCache(requests);
|
||||
}
|
||||
|
||||
private void initCache(ClientRequests requests) {
|
||||
CacheLoader<String, List<CFServiceInstance>> servicesLoader = new CacheLoader<String, List<CFServiceInstance>>() {
|
||||
|
||||
@Override
|
||||
@@ -71,12 +78,23 @@ public class CFTarget {
|
||||
};
|
||||
this.buildpacksCache = CacheBuilder.newBuilder()
|
||||
.expireAfterAccess(CFTargetCache.TARGET_EXPIRATION, TimeUnit.HOURS).build(buildpacksLoader);
|
||||
|
||||
CacheLoader<String, List<CFDomain>> domainLoader = new CacheLoader<String, List<CFDomain>>() {
|
||||
|
||||
@Override
|
||||
public List<CFDomain> load(String key) throws Exception {
|
||||
return runAndCheckForFailure(() -> requests.getDomains());
|
||||
}
|
||||
|
||||
};
|
||||
this.domainCache = CacheBuilder.newBuilder()
|
||||
.expireAfterAccess(CFTargetCache.TARGET_EXPIRATION, TimeUnit.HOURS).build(domainLoader);
|
||||
}
|
||||
|
||||
|
||||
protected <T> T runAndCheckForFailure(Callable<T> callable) throws Exception {
|
||||
return callableContext.checkConnection(callable);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasConnectionError() {
|
||||
return callableContext.hasConnectionError();
|
||||
}
|
||||
@@ -102,6 +120,11 @@ public class CFTarget {
|
||||
String key = getName();
|
||||
return this.servicesCache.get(key);
|
||||
}
|
||||
|
||||
public List<CFDomain> getDomains() throws Exception {
|
||||
String key = getName();
|
||||
return this.domainCache.get(key);
|
||||
}
|
||||
|
||||
public ClientRequests getClientRequests() {
|
||||
return requests;
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
package org.springframework.ide.vscode.commons.cloudfoundry.client.v2;
|
||||
|
||||
import org.cloudfoundry.operations.buildpacks.Buildpack;
|
||||
import org.cloudfoundry.operations.services.ServiceInstance;
|
||||
import org.cloudfoundry.operations.domains.Domain;
|
||||
import org.cloudfoundry.operations.services.ServiceInstanceSummary;
|
||||
import org.cloudfoundry.operations.services.ServiceInstanceType;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFBuildpack;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFDomain;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFEntities;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance;
|
||||
|
||||
@@ -32,6 +33,11 @@ public class CFWrappingV2 {
|
||||
return CFEntities.createBuildpack(name);
|
||||
}
|
||||
|
||||
public static CFDomain wrap(Domain domain) {
|
||||
String name = domain.getName();
|
||||
return CFEntities.createDomain(name);
|
||||
}
|
||||
|
||||
public static CFServiceInstance wrap(ServiceInstanceSummary serviceInstance) {
|
||||
String name = serviceInstance.getName();
|
||||
String plan = serviceInstance.getPlan();
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.cloudfoundry.client.CloudFoundryClient;
|
||||
import org.cloudfoundry.operations.CloudFoundryOperations;
|
||||
import org.cloudfoundry.operations.DefaultCloudFoundryOperations;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFBuildpack;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFDomain;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.ClientTimeouts;
|
||||
@@ -82,7 +83,22 @@ public class DefaultClientRequestsV2 implements ClientRequests {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CFDomain> getDomains() throws Exception {
|
||||
|
||||
return ReactorUtils.get(timeouts.getBuildpacksTimeout(), CancelationTokens.NULL,
|
||||
log("operations.domains.list",
|
||||
_operations
|
||||
.domains()
|
||||
.list()
|
||||
.map(CFWrappingV2::wrap)
|
||||
.collectList()
|
||||
.map(ImmutableList::copyOf)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CFBuildpack> getBuildpacks() throws Exception {
|
||||
return ReactorUtils.get(timeouts.getBuildpacksTimeout(), CancelationTokens.NULL,
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.concurrent.Callable;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFParamsProviderMessages;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTargetCache;
|
||||
@@ -28,6 +29,8 @@ import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.Conne
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException;
|
||||
import org.springframework.ide.vscode.commons.util.ExceptionUtil;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class CFClientTest {
|
||||
|
||||
MockCfCli cloudfoundry = new MockCfCli();
|
||||
@@ -71,6 +74,54 @@ public class CFClientTest {
|
||||
assertError(() -> target.getBuildpacks(), ConnectionException.class, expectedMessages.noNetworkConnection());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildpacksFromTarget() throws Exception {
|
||||
ClientRequests client = cloudfoundry.client;
|
||||
CFBuildpack buildpack = Mockito.mock(CFBuildpack.class);
|
||||
when(buildpack.getName()).thenReturn("java_buildpack");
|
||||
when(client.getBuildpacks()).thenReturn(ImmutableList.of(buildpack));
|
||||
|
||||
CFTarget target = targetCache.getOrCreate().get(0);
|
||||
assertEquals("java_buildpack", target.getBuildpacks().get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDomainsFromTarget() throws Exception {
|
||||
ClientRequests client = cloudfoundry.client;
|
||||
CFDomain domain = Mockito.mock(CFDomain.class);
|
||||
when(domain.getName()).thenReturn("cfapps.io");
|
||||
when(client.getDomains()).thenReturn(ImmutableList.of(domain));
|
||||
|
||||
CFTarget target = targetCache.getOrCreate().get(0);
|
||||
assertEquals("cfapps.io", target.getDomains().get(0).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testServicesFromTarget() throws Exception {
|
||||
ClientRequests client = cloudfoundry.client;
|
||||
CFServiceInstance service = Mockito.mock(CFServiceInstance.class);
|
||||
when(service.getName()).thenReturn("appdb");
|
||||
when(service.getPlan()).thenReturn("spark");
|
||||
when(service.getService()).thenReturn("cleardb");
|
||||
|
||||
when(client.getServices()).thenReturn(ImmutableList.of(service));
|
||||
|
||||
CFTarget target = targetCache.getOrCreate().get(0);
|
||||
assertEquals("appdb", target.getServices().get(0).getName());
|
||||
assertEquals("spark", target.getServices().get(0).getPlan());
|
||||
assertEquals("cleardb", target.getServices().get(0).getService());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoServicesFromTarget() throws Exception {
|
||||
ClientRequests client = cloudfoundry.client;
|
||||
|
||||
when(client.getServices()).thenReturn(ImmutableList.of());
|
||||
|
||||
CFTarget target = targetCache.getOrCreate().get(0);
|
||||
assertTrue(target.getServices().isEmpty());
|
||||
}
|
||||
|
||||
protected void assertError(Callable<?> callable, Class<? extends Throwable> expected, String expectedMessage)
|
||||
throws Exception {
|
||||
Throwable error = null;
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.manifest.yaml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFDomain;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTargetCache;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.BasicYValueHint;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YValueHint;
|
||||
|
||||
public class ManifestYamlCFDomainProvider extends AbstractCFHintsProvider {
|
||||
|
||||
public ManifestYamlCFDomainProvider(CFTargetCache cache) {
|
||||
super(cache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<YValueHint> getHints(List<CFTarget> targets) throws Exception {
|
||||
|
||||
List<YValueHint> hints = new ArrayList<>();
|
||||
|
||||
for (CFTarget cfTarget : targets) {
|
||||
|
||||
List<CFDomain> domains = cfTarget.getDomains();
|
||||
if (domains != null && !domains.isEmpty()) {
|
||||
|
||||
for (CFDomain domain : domains) {
|
||||
String name = domain.getName();
|
||||
String label = getBuildpackLabel(cfTarget, domain);
|
||||
YValueHint hint = new BasicYValueHint(name, label);
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint);
|
||||
}
|
||||
}
|
||||
return hints;
|
||||
}
|
||||
}
|
||||
// Contract for the reconciler: return null if values cannot be
|
||||
// resolved. Otherwise
|
||||
// return non-empty list
|
||||
return !hints.isEmpty() ? hints : null;
|
||||
}
|
||||
|
||||
protected String getBuildpackLabel(CFTarget target, CFDomain domain) {
|
||||
return domain.getName() + " (" + target.getName() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return "Domain";
|
||||
}
|
||||
}
|
||||
@@ -63,10 +63,7 @@ public class ManifestYamlLanguageServer extends SimpleLanguageServer {
|
||||
|
||||
YamlASTProvider parser = new YamlParser(yaml);
|
||||
|
||||
Callable<Collection<YValueHint>> buildPacksProvider = getBuildpacksProvider();
|
||||
Callable<Collection<YValueHint>> servicesProvider = getServicesProvider();
|
||||
|
||||
schema = new ManifestYmlSchema(buildPacksProvider, servicesProvider);
|
||||
schema = new ManifestYmlSchema(getHintProviders());
|
||||
|
||||
YamlStructureProvider structureProvider = YamlStructureProvider.DEFAULT;
|
||||
YamlAssistContextProvider contextProvider = new SchemaBasedYamlAssistContextProvider(schema);
|
||||
@@ -98,6 +95,30 @@ public class ManifestYamlLanguageServer extends SimpleLanguageServer {
|
||||
documents.onHover(hoverEngine ::getHover);
|
||||
}
|
||||
|
||||
protected ManifestYmlHintProviders getHintProviders() {
|
||||
Callable<Collection<YValueHint>> buildPacksProvider = getBuildpacksProvider();
|
||||
Callable<Collection<YValueHint>> servicesProvider = getServicesProvider();
|
||||
Callable<Collection<YValueHint>> domainsProvider = getDomainsProvider();
|
||||
|
||||
return new ManifestYmlHintProviders() {
|
||||
|
||||
@Override
|
||||
public Callable<Collection<YValueHint>> getServicesProvider() {
|
||||
return servicesProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Callable<Collection<YValueHint>> getDomainsProvider() {
|
||||
return domainsProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Callable<Collection<YValueHint>> getBuildpackProviders() {
|
||||
return buildPacksProvider;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private CFTargetCache getCfTargetCache() {
|
||||
if (cfTargetCache == null) {
|
||||
ClientParamsProvider paramsProvider = cfParamsProvider;
|
||||
@@ -114,6 +135,10 @@ public class ManifestYamlLanguageServer extends SimpleLanguageServer {
|
||||
private Callable<Collection<YValueHint>> getServicesProvider() {
|
||||
return new ManifestYamlCFServicesProvider(getCfTargetCache());
|
||||
}
|
||||
|
||||
private Callable<Collection<YValueHint>> getDomainsProvider() {
|
||||
return new ManifestYamlCFDomainProvider(getCfTargetCache());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ServerCapabilities getServerCapabilities() {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.manifest.yaml;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YValueHint;
|
||||
|
||||
public interface ManifestYmlHintProviders {
|
||||
|
||||
Callable<Collection<YValueHint>> getBuildpackProviders();
|
||||
|
||||
Callable<Collection<YValueHint>> getServicesProvider();
|
||||
|
||||
Callable<Collection<YValueHint>> getDomainsProvider();
|
||||
|
||||
}
|
||||
@@ -47,8 +47,13 @@ public class ManifestYmlSchema implements YamlSchema {
|
||||
return IntegerRange.exactly(1);
|
||||
}
|
||||
|
||||
public ManifestYmlSchema(Callable<Collection<YValueHint>> buildpackProvider, Callable<Collection<YValueHint>> servicesProvider) {
|
||||
this.buildpackProvider = buildpackProvider;
|
||||
|
||||
public ManifestYmlSchema(ManifestYmlHintProviders providers) {
|
||||
this.buildpackProvider = providers.getBuildpackProviders();
|
||||
Callable<Collection<YValueHint>> servicesProvider = providers.getServicesProvider();
|
||||
Callable<Collection<YValueHint>> domainsProvider = providers.getDomainsProvider();
|
||||
|
||||
|
||||
YTypeFactory f = new YTypeFactory();
|
||||
TYPE_UTIL = f.TYPE_UTIL;
|
||||
|
||||
@@ -63,7 +68,17 @@ public class ManifestYmlSchema implements YamlSchema {
|
||||
t_buildpack.addHintProvider(this.buildpackProvider);
|
||||
// t_buildpack.parseWith(ManifestYmlValueParsers.fromHints(t_buildpack.toString(), buildpackProvider));
|
||||
}
|
||||
|
||||
YAtomicType t_domain = f.yatomic("Domain");
|
||||
YAtomicType t_domains_string = f.yatomic("Domains");
|
||||
|
||||
if (domainsProvider != null) {
|
||||
t_domain.addHintProvider(domainsProvider);
|
||||
t_domains_string.addHintProvider(domainsProvider);
|
||||
}
|
||||
|
||||
YType t_domains = f.yseq(t_domains_string);
|
||||
|
||||
YAtomicType t_service_string = f.yatomic("Service");
|
||||
if (servicesProvider != null) {
|
||||
t_service_string.addHintProvider(servicesProvider);
|
||||
@@ -112,8 +127,8 @@ public class ManifestYmlSchema implements YamlSchema {
|
||||
f.yprop("buildpack", t_buildpack),
|
||||
f.yprop("command", t_string),
|
||||
f.yprop("disk_quota", t_memory),
|
||||
f.yprop("domain", t_string),
|
||||
f.yprop("domains", t_strings),
|
||||
f.yprop("domain", t_domain),
|
||||
f.yprop("domains", t_domains),
|
||||
f.yprop("env", t_env),
|
||||
f.yprop("host", t_string),
|
||||
f.yprop("hosts", t_strings),
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFBuildpack;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFDomain;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.ClientRequests;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException;
|
||||
@@ -936,6 +937,44 @@ public class ManifestYamlEditorTest {
|
||||
when(cfClient.getBuildpacks()).thenReturn(ImmutableList.of(buildPack));
|
||||
assertDoesNotContainCompletions("buildpack: <*>", "buildpack: wrong_buildpack<*>");
|
||||
}
|
||||
|
||||
@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));
|
||||
|
||||
assertContainsCompletions("domain: <*>", "domain: cfapps.io<*>");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void domainContentAssistDoesNotContainCompletion() 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));
|
||||
assertDoesNotContainCompletions("domain: <*>", "domain: wrong.cfapps.io<*>");
|
||||
}
|
||||
|
||||
@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));
|
||||
|
||||
assertContainsCompletions("domains:\n" + " - <*>", "cfapps.io");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void domainsContentAssistWrongDomain() 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));
|
||||
assertDoesNotContainCompletions("domains:\n" + " - <*>", "wrong.cfapps.io");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -14,13 +14,16 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.commons.util.Renderables;
|
||||
import org.springframework.ide.vscode.commons.util.StringUtil;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YTypedProperty;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YValueHint;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.AbstractType;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.YSeqType;
|
||||
import org.springframework.ide.vscode.manifest.yaml.ManifestYmlSchema;
|
||||
@@ -81,7 +84,7 @@ public class ManifestYmlSchemaTest {
|
||||
"timeout"
|
||||
};
|
||||
|
||||
ManifestYmlSchema schema = new ManifestYmlSchema(null, null);
|
||||
ManifestYmlSchema schema = new ManifestYmlSchema(EMPTY_PROVIDERS);
|
||||
|
||||
@Test
|
||||
public void toplevelProperties() throws Exception {
|
||||
@@ -150,5 +153,22 @@ public class ManifestYmlSchemaTest {
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
||||
private static final ManifestYmlHintProviders EMPTY_PROVIDERS = new ManifestYmlHintProviders() {
|
||||
|
||||
@Override
|
||||
public Callable<Collection<YValueHint>> getServicesProvider() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Callable<Collection<YValueHint>> getDomainsProvider() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Callable<Collection<YValueHint>> getBuildpackProviders() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user