use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceBrokerPropertiesTest method bindProperties.
private ServiceBrokerProperties bindProperties() {
ConfigurationPropertySource source = new MapConfigurationPropertySource(this.map);
Binder binder = new Binder(source);
ServiceBrokerProperties serviceBrokerProperties = new ServiceBrokerProperties();
binder.bind(PREFIX, Bindable.ofInstance(serviceBrokerProperties));
return serviceBrokerProperties;
}
use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-cloud-stream by spring-cloud.
the class BindingServiceTests method createBindingServiceProperties.
private BindingServiceProperties createBindingServiceProperties(HashMap<String, String> properties) {
BindingServiceProperties bindingServiceProperties = new BindingServiceProperties();
org.springframework.boot.context.properties.bind.Binder propertiesBinder = new org.springframework.boot.context.properties.bind.Binder(new MapConfigurationPropertySource(properties));
propertiesBinder.bind("spring.cloud.stream", org.springframework.boot.context.properties.bind.Bindable.ofInstance(bindingServiceProperties));
return bindingServiceProperties;
}
use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-cloud-open-service-broker by spring-cloud.
the class ServiceBrokerPropertiesTest method fullCatalog.
@Test
public void fullCatalog() {
Map<String, String> map = new HashMap<>();
map.put("spring.cloud.openservicebroker.catalog.services[0].id", "service-one-id");
map.put("spring.cloud.openservicebroker.catalog.services[0].name", "Service One");
map.put("spring.cloud.openservicebroker.catalog.services[0].description", "Description for Service One");
map.put("spring.cloud.openservicebroker.catalog.services[0].bindable", "true");
map.put("spring.cloud.openservicebroker.catalog.services[0].bindings-retrievable", "true");
map.put("spring.cloud.openservicebroker.catalog.services[0].instances-retrievable", "true");
map.put("spring.cloud.openservicebroker.catalog.services[0].plan-updateable", "true");
map.put("spring.cloud.openservicebroker.catalog.services[0].metadata[key1]", "value1");
map.put("spring.cloud.openservicebroker.catalog.services[0].metadata[key2]", "value2");
map.put("spring.cloud.openservicebroker.catalog.services[0].requires[0]", "syslog_drain");
map.put("spring.cloud.openservicebroker.catalog.services[0].requires[1]", "route_forwarding");
map.put("spring.cloud.openservicebroker.catalog.services[0].tags[0]", "tag1");
map.put("spring.cloud.openservicebroker.catalog.services[0].tags[1]", "tag2");
map.put("spring.cloud.openservicebroker.catalog.services[0].dashboard-client.id", "dashboard-id");
map.put("spring.cloud.openservicebroker.catalog.services[0].dashboard-client.secret", "dashboard-secret");
map.put("spring.cloud.openservicebroker.catalog.services[0].dashboard-client.redirect-uri", "dashboard-redirect-uri");
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[0].id", "plan-one-id");
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[0].name", "Plan One");
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[0].description", "Description for Plan One");
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].id", "plan-two-id");
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].name", "Plan Two");
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].description", "Description for Plan Two");
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].metadata[key1]", "value1");
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].metadata[key2]", "value2");
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].bindable", "true");
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].free", "true");
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.create.parameters[$schema]", "http://example.com/service/create/schema");
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.create.parameters[type]", "object");
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.update.parameters[$schema]", "http://example.com/service/update/schema");
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.serviceinstance.update.parameters[type]", "object");
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.servicebinding.create.parameters[$schema]", "http://example.com/service/create/schema");
map.put("spring.cloud.openservicebroker.catalog.services[0].plans[1].schemas.servicebinding.create.parameters[type]", "object");
map.put("spring.cloud.openservicebroker.catalog.services[1].id", "service-two-id");
map.put("spring.cloud.openservicebroker.catalog.services[1].name", "Service Two");
map.put("spring.cloud.openservicebroker.catalog.services[1].description", "Description for Service Two");
map.put("spring.cloud.openservicebroker.catalog.services[1].plans[0].id", "plan-one-id");
map.put("spring.cloud.openservicebroker.catalog.services[1].plans[0].name", "Plan One");
map.put("spring.cloud.openservicebroker.catalog.services[1].plans[0].description", "Description for Plan One");
ConfigurationPropertySource source = new MapConfigurationPropertySource(map);
Binder binder = new Binder(source);
ServiceBrokerProperties properties = new ServiceBrokerProperties();
binder.bind("spring.cloud.openservicebroker", Bindable.ofInstance(properties));
assertThat(properties.getCatalog()).isNotNull();
assertThat(properties.getCatalog().getServices()).hasSize(2);
assertThat(properties.getCatalog().getServices().get(0).getId()).isEqualTo("service-one-id");
assertThat(properties.getCatalog().getServices().get(0).getName()).isEqualTo("Service One");
assertThat(properties.getCatalog().getServices().get(0).getDescription()).isEqualTo("Description for Service One");
assertThat(properties.getCatalog().getServices().get(0).isBindable()).isTrue();
assertThat(properties.getCatalog().getServices().get(0).isBindingsRetrievable()).isTrue();
assertThat(properties.getCatalog().getServices().get(0).isInstancesRetrievable()).isTrue();
assertThat(properties.getCatalog().getServices().get(0).isPlanUpdateable()).isTrue();
assertThat(properties.getCatalog().getServices().get(0).getMetadata()).containsOnly(entry("key1", "value1"), entry("key2", "value2"));
assertThat(properties.getCatalog().getServices().get(0).getRequires()).containsOnly("syslog_drain", "route_forwarding");
assertThat(properties.getCatalog().getServices().get(0).getTags()).containsOnly("tag1", "tag2");
assertThat(properties.getCatalog().getServices().get(0).getDashboardClient().getId()).isEqualTo("dashboard-id");
assertThat(properties.getCatalog().getServices().get(0).getDashboardClient().getSecret()).isEqualTo("dashboard-secret");
assertThat(properties.getCatalog().getServices().get(0).getDashboardClient().getRedirectUri()).isEqualTo("dashboard-redirect-uri");
assertThat(properties.getCatalog().getServices().get(0).getPlans()).hasSize(2);
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(0).getId()).isEqualTo("plan-one-id");
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(0).getName()).isEqualTo("Plan One");
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(0).getDescription()).isEqualTo("Description for Plan One");
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getId()).isEqualTo("plan-two-id");
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getName()).isEqualTo("Plan Two");
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getDescription()).isEqualTo("Description for Plan Two");
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getMetadata()).containsOnly(entry("key1", "value1"), entry("key2", "value2"));
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).isBindable()).isTrue();
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).isFree()).isTrue();
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance().getCreate().getParameters()).containsOnly(entry("$schema", "http://example.com/service/create/schema"), entry("type", "object"));
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getSchemas().getServiceInstance().getUpdate().getParameters()).containsOnly(entry("$schema", "http://example.com/service/update/schema"), entry("type", "object"));
assertThat(properties.getCatalog().getServices().get(0).getPlans().get(1).getSchemas().getServiceBinding().getCreate().getParameters()).containsOnly(entry("$schema", "http://example.com/service/create/schema"), entry("type", "object"));
assertThat(properties.getCatalog().getServices().get(1).getId()).isEqualTo("service-two-id");
assertThat(properties.getCatalog().getServices().get(1).getName()).isEqualTo("Service Two");
assertThat(properties.getCatalog().getServices().get(1).getDescription()).isEqualTo("Description for Service Two");
assertThat(properties.getCatalog().getServices().get(1).getPlans()).hasSize(1);
assertThat(properties.getCatalog().getServices().get(1).getPlans().get(0).getId()).isEqualTo("plan-one-id");
assertThat(properties.getCatalog().getServices().get(1).getPlans().get(0).getName()).isEqualTo("Plan One");
assertThat(properties.getCatalog().getServices().get(1).getPlans().get(0).getDescription()).isEqualTo("Description for Plan One");
Catalog catalog = properties.getCatalog().toModel();
assertThat(catalog.getServiceDefinitions().get(0).getId()).isEqualTo("service-one-id");
assertThat(catalog.getServiceDefinitions().get(0).getName()).isEqualTo("Service One");
assertThat(catalog.getServiceDefinitions().get(0).getDescription()).isEqualTo("Description for Service One");
assertThat(catalog.getServiceDefinitions().get(0).isBindable()).isTrue();
assertThat(catalog.getServiceDefinitions().get(0).isBindingsRetrievable()).isTrue();
assertThat(catalog.getServiceDefinitions().get(0).isInstancesRetrievable()).isTrue();
assertThat(catalog.getServiceDefinitions().get(0).isPlanUpdateable()).isTrue();
assertThat(catalog.getServiceDefinitions().get(0).getMetadata()).containsOnly(entry("key1", "value1"), entry("key2", "value2"));
assertThat(catalog.getServiceDefinitions().get(0).getRequires()).containsOnly("syslog_drain", "route_forwarding");
assertThat(catalog.getServiceDefinitions().get(0).getTags()).containsOnly("tag1", "tag2");
assertThat(catalog.getServiceDefinitions().get(0).getDashboardClient().getId()).isEqualTo("dashboard-id");
assertThat(catalog.getServiceDefinitions().get(0).getDashboardClient().getSecret()).isEqualTo("dashboard-secret");
assertThat(catalog.getServiceDefinitions().get(0).getDashboardClient().getRedirectUri()).isEqualTo("dashboard-redirect-uri");
assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(0).getId()).isEqualTo("plan-one-id");
assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(0).getName()).isEqualTo("Plan One");
assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(0).getDescription()).isEqualTo("Description for Plan One");
assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getId()).isEqualTo("plan-two-id");
assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getName()).isEqualTo("Plan Two");
assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getDescription()).isEqualTo("Description for Plan Two");
assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getMetadata()).containsOnly(entry("key1", "value1"), entry("key2", "value2"));
assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).isBindable()).isTrue();
assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).isFree()).isTrue();
assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getSchemas().getServiceInstanceSchema().getCreateMethodSchema().getParameters()).containsOnly(entry("$schema", "http://example.com/service/create/schema"), entry("type", "object"));
assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getSchemas().getServiceInstanceSchema().getUpdateMethodSchema().getParameters()).containsOnly(entry("$schema", "http://example.com/service/update/schema"), entry("type", "object"));
assertThat(catalog.getServiceDefinitions().get(0).getPlans().get(1).getSchemas().getServiceBindingSchema().getCreateMethodSchema().getParameters()).containsOnly(entry("$schema", "http://example.com/service/create/schema"), entry("type", "object"));
assertThat(catalog.getServiceDefinitions().get(1).getId()).isEqualTo("service-two-id");
assertThat(catalog.getServiceDefinitions().get(1).getName()).isEqualTo("Service Two");
assertThat(catalog.getServiceDefinitions().get(1).getDescription()).isEqualTo("Description for Service Two");
assertThat(catalog.getServiceDefinitions().get(1).getPlans().get(0).getId()).isEqualTo("plan-one-id");
assertThat(catalog.getServiceDefinitions().get(1).getPlans().get(0).getName()).isEqualTo("Plan One");
assertThat(catalog.getServiceDefinitions().get(1).getPlans().get(0).getDescription()).isEqualTo("Description for Plan One");
}
use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-boot by spring-projects.
the class ConfigDataActivationContextTests method getCloudPlatformWhenCloudPropertyHasBeenContributedDuringInitialLoadDeducesCloudPlatform.
@Test
void getCloudPlatformWhenCloudPropertyHasBeenContributedDuringInitialLoadDeducesCloudPlatform() {
Environment environment = createKubernetesEnvironment();
Binder binder = new Binder(new MapConfigurationPropertySource(Collections.singletonMap("spring.main.cloud-platform", "HEROKU")));
ConfigDataActivationContext context = new ConfigDataActivationContext(environment, binder);
assertThat(context.getCloudPlatform()).isEqualTo(CloudPlatform.HEROKU);
}
use of org.springframework.boot.context.properties.source.MapConfigurationPropertySource in project spring-boot by spring-projects.
the class WebMvcPropertiesTests method bind.
private void bind(Map<String, String> map) {
ConfigurationPropertySource source = new MapConfigurationPropertySource(map);
new Binder(source).bind("spring.mvc", Bindable.ofInstance(this.properties));
}
Aggregations