use of cn.taketoday.context.properties.source.MapConfigurationPropertySource in project today-infrastructure by TAKETODAY.
the class ConfigDataActivationContextTests method getCloudPlatformWhenCloudPropertyHasBeenContributedDuringInitialLoadDeducesCloudPlatform.
@Test
void getCloudPlatformWhenCloudPropertyHasBeenContributedDuringInitialLoadDeducesCloudPlatform() {
Environment environment = createKubernetesEnvironment();
Binder binder = new Binder(new MapConfigurationPropertySource(Collections.singletonMap("context.main.cloud-platform", "HEROKU")));
ConfigDataActivationContext context = new ConfigDataActivationContext(environment, binder);
assertThat(context.getCloudPlatform()).isEqualTo(CloudPlatform.HEROKU);
}
use of cn.taketoday.context.properties.source.MapConfigurationPropertySource in project today-infrastructure by TAKETODAY.
the class ConfigDataPropertiesTests method getImportOriginWhenBracketListReturnsOrigin.
@Test
void getImportOriginWhenBracketListReturnsOrigin() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.put("context.config.import[0]", "one");
source.put("context.config.import[1]", "two");
source.put("context.config.import[2]", "three");
Binder binder = new Binder(source);
ConfigDataProperties properties = ConfigDataProperties.get(binder);
assertThat(properties.getImports().get(1).getOrigin()).hasToString("\"context.config.import[1]\" from property source \"source\"");
}
use of cn.taketoday.context.properties.source.MapConfigurationPropertySource in project today-infrastructure by TAKETODAY.
the class ConfigDataPropertiesTests method isActiveAgainstBoundDataWhenProfilesDontMatch.
@Test
void isActiveAgainstBoundDataWhenProfilesDontMatch() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.put("context.config.activate.on-cloud-platform", "kubernetes");
source.put("context.config.activate.on-profile", "x | z");
Binder binder = new Binder(source);
ConfigDataProperties properties = ConfigDataProperties.get(binder);
ConfigDataActivationContext context = new ConfigDataActivationContext(CloudPlatform.KUBERNETES, createTestProfiles());
assertThat(properties.isActive(context)).isFalse();
}
use of cn.taketoday.context.properties.source.MapConfigurationPropertySource in project today-infrastructure by TAKETODAY.
the class ConfigDataLocationBindHandlerTests method bindToValueObjectFromIndexedPropertiesSetsOrigin.
@Test
void bindToValueObjectFromIndexedPropertiesSetsOrigin() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.put("test.locations[0]", "a");
source.put("test.locations[1]", "b");
source.put("test.locations[2]", "c");
Binder binder = new Binder(source);
ValueObject bound = binder.bind("test", VALUE_OBJECT, this.handler).get();
assertThat(bound.getLocation(0)).hasToString("a");
assertThat(bound.getLocation(0).getOrigin()).hasToString("\"test.locations[0]\" from property source \"source\"");
assertThat(bound.getLocation(1)).hasToString("b");
assertThat(bound.getLocation(1).getOrigin()).hasToString("\"test.locations[1]\" from property source \"source\"");
assertThat(bound.getLocation(2)).hasToString("c");
assertThat(bound.getLocation(2).getOrigin()).hasToString("\"test.locations[2]\" from property source \"source\"");
}
use of cn.taketoday.context.properties.source.MapConfigurationPropertySource in project today-infrastructure by TAKETODAY.
the class ConfigDataLocationBindHandlerTests method bindToValueObjectFromCommaStringPropertySetsOrigin.
@Test
void bindToValueObjectFromCommaStringPropertySetsOrigin() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.put("test.locations", "a,b,c");
Binder binder = new Binder(source);
ValueObject bound = binder.bind("test", VALUE_OBJECT, this.handler).get();
String expectedLocation = "\"test.locations\" from property source \"source\"";
assertThat(bound.getLocation(0)).hasToString("a");
assertThat(bound.getLocation(0).getOrigin()).hasToString(expectedLocation);
assertThat(bound.getLocation(1)).hasToString("b");
assertThat(bound.getLocation(1).getOrigin()).hasToString(expectedLocation);
assertThat(bound.getLocation(2)).hasToString("c");
assertThat(bound.getLocation(2).getOrigin()).hasToString(expectedLocation);
}
Aggregations