use of cn.taketoday.core.env.PropertySource in project today-infrastructure by TAKETODAY.
the class ConfigDataTests method getOptionsWhenPropertySourceOptionsReturnsNullReturnsNone.
@Test
void getOptionsWhenPropertySourceOptionsReturnsNullReturnsNone() {
MapPropertySource source = new MapPropertySource("test", Collections.emptyMap());
PropertySourceOptions propertySourceOptions = (propertySource) -> null;
ConfigData configData = new ConfigData(Collections.singleton(source), propertySourceOptions);
assertThat(configData.getOptions(source)).isEqualTo(Options.NONE);
}
use of cn.taketoday.core.env.PropertySource in project today-infrastructure by TAKETODAY.
the class BinderTests method bindToValidatedBeanWithResourceAndNonEnumerablePropertySource.
@Test
void bindToValidatedBeanWithResourceAndNonEnumerablePropertySource() {
ConfigurationPropertySources.from(new PropertySource<String>("test") {
@Override
public Object getProperty(String name) {
return null;
}
}).forEach(this.sources::add);
Validator validator = new ValidatorAdapter(Validation.byDefaultProvider().configure().buildValidatorFactory().getValidator());
this.binder.bind("foo", Bindable.of(ResourceBean.class), new ValidationBindHandler(validator));
}
use of cn.taketoday.core.env.PropertySource in project today-framework by TAKETODAY.
the class ConfigDataLoadersTests method createConfigData.
private static ConfigData createConfigData(ConfigDataLoader<?> loader, ConfigDataResource resource) {
MockPropertySource propertySource = new MockPropertySource();
propertySource.setProperty("loader", loader);
propertySource.setProperty("resource", resource);
List<PropertySource<?>> propertySources = Arrays.asList(propertySource);
return new ConfigData(propertySources);
}
use of cn.taketoday.core.env.PropertySource in project today-framework by TAKETODAY.
the class ConfigDataTests method getOptionsWhenPropertySourceOptionsReturnsNullReturnsNone.
@Test
void getOptionsWhenPropertySourceOptionsReturnsNullReturnsNone() {
MapPropertySource source = new MapPropertySource("test", Collections.emptyMap());
PropertySourceOptions propertySourceOptions = (propertySource) -> null;
ConfigData configData = new ConfigData(Collections.singleton(source), propertySourceOptions);
assertThat(configData.getOptions(source)).isEqualTo(Options.NONE);
}
use of cn.taketoday.core.env.PropertySource in project today-framework by TAKETODAY.
the class BinderTests method bindToValidatedBeanWithResourceAndNonEnumerablePropertySource.
@Test
void bindToValidatedBeanWithResourceAndNonEnumerablePropertySource() {
ConfigurationPropertySources.from(new PropertySource<String>("test") {
@Override
public Object getProperty(String name) {
return null;
}
}).forEach(this.sources::add);
Validator validator = new ValidatorAdapter(Validation.byDefaultProvider().configure().buildValidatorFactory().getValidator());
this.binder.bind("foo", Bindable.of(ResourceBean.class), new ValidationBindHandler(validator));
}
Aggregations