use of cn.taketoday.context.properties.bind.Binder in project today-framework 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.bind.Binder in project today-framework by TAKETODAY.
the class ConfigDataPropertiesTests method createTestProfiles.
private Profiles createTestProfiles() {
MockEnvironment environment = new MockEnvironment();
environment.setActiveProfiles("a", "b", "c");
environment.setDefaultProfiles("d", "e", "f");
Binder binder = Binder.get(environment);
return new Profiles(environment, binder, null);
}
use of cn.taketoday.context.properties.bind.Binder in project today-framework by TAKETODAY.
the class ConfigDataLocationBindHandlerTests method bindToArrayFromCommaStringPropertyIgnoresEmptyElements.
@Test
void bindToArrayFromCommaStringPropertyIgnoresEmptyElements() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.put("locations", ",a,,b,c,");
Binder binder = new Binder(source);
ConfigDataLocation[] bound = binder.bind("locations", ARRAY, this.handler).get();
String expectedLocation = "\"locations\" from property source \"source\"";
assertThat(bound[0]).hasToString("a");
assertThat(bound[0].getOrigin()).hasToString(expectedLocation);
assertThat(bound[1]).hasToString("b");
assertThat(bound[1].getOrigin()).hasToString(expectedLocation);
assertThat(bound[2]).hasToString("c");
assertThat(bound[2].getOrigin()).hasToString(expectedLocation);
}
use of cn.taketoday.context.properties.bind.Binder in project today-framework by TAKETODAY.
the class ConfigDataLocationBindHandlerTests method bindToArrayFromCommaStringPropertySetsOrigin.
@Test
void bindToArrayFromCommaStringPropertySetsOrigin() {
MapConfigurationPropertySource source = new MapConfigurationPropertySource();
source.put("locations", "a,b,c");
Binder binder = new Binder(source);
ConfigDataLocation[] bound = binder.bind("locations", ARRAY, this.handler).get();
String expectedLocation = "\"locations\" from property source \"source\"";
assertThat(bound[0]).hasToString("a");
assertThat(bound[0].getOrigin()).hasToString(expectedLocation);
assertThat(bound[1]).hasToString("b");
assertThat(bound[1].getOrigin()).hasToString(expectedLocation);
assertThat(bound[2]).hasToString("c");
assertThat(bound[2].getOrigin()).hasToString(expectedLocation);
}
use of cn.taketoday.context.properties.bind.Binder in project today-framework 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