use of org.springframework.ide.vscode.commons.yaml.schema.DynamicSchemaContext in project sts4 by spring-projects.
the class BoshCommandCloudConfigProvider method getModel.
@Override
public CloudConfigModel getModel(DynamicSchemaContext dc) throws Exception {
String block = getBlock();
YamlFileAST ast = parseYaml(block);
return new CloudConfigModel() {
@Override
public Collection<String> getVMTypes() {
return getNames(VM_TYPE_NAMES);
}
@Override
public Collection<String> getNetworkNames() {
return getNames(NETWORK_NAMES);
}
@Override
public Collection<String> getAvailabilityZones() {
return getNames(AVAILABILITY_ZONES);
}
@Override
public Collection<String> getDiskTypes() {
return getNames(DISK_TYPES);
}
@Override
public Collection<String> getVMExtensions() {
return getNames(VM_EXTENSIONS);
}
private Collection<String> getNames(YamlTraversal namesPath) {
return namesPath.traverseAmbiguously(ast).flatMap(nameNode -> {
String name = NodeUtil.asScalar(nameNode);
return StringUtil.hasText(name) ? Stream.of(name) : Stream.empty();
}).collect(CollectorUtil.toMultiset());
}
};
}
use of org.springframework.ide.vscode.commons.yaml.schema.DynamicSchemaContext in project sts4 by spring-projects.
the class BoshCommandCloudConfigProviderTest method getStuff.
// For local testing only... in CI builds we don't have the means to use a real bosh director and cli.
// private BoshCommandCloudConfigProvider realProvider = new BoshCommandCloudConfigProvider();
@Test
public void getStuff() throws Exception {
DynamicSchemaContext dc = Mockito.mock(DynamicSchemaContext.class);
CloudConfigModel cloudConfig = provider.getModel(dc);
assertEquals(ImmutableMultiset.of("default", "large"), cloudConfig.getVMTypes());
assertEquals(ImmutableMultiset.of("default"), cloudConfig.getNetworkNames());
assertEquals(ImmutableMultiset.of("default", "large"), cloudConfig.getDiskTypes());
assertEquals(ImmutableMultiset.of("default", "large"), cloudConfig.getVMTypes());
assertEquals(ImmutableMultiset.of(), cloudConfig.getVMExtensions());
assertEquals(ImmutableMultiset.of("z1", "z2", "z3"), cloudConfig.getAvailabilityZones());
}
Aggregations