use of org.springframework.beans.BeanWrapperImpl in project spring-boot by spring-projects.
the class BindingPreparationTests method testAutoGrowWithFuzzyNameUnderscores.
@Test
public void testAutoGrowWithFuzzyNameUnderscores() throws Exception {
TargetWithNestedMap target = new TargetWithNestedMap();
BeanWrapperImpl wrapper = new BeanWrapperImpl(target);
wrapper.setAutoGrowNestedPaths(true);
RelaxedDataBinder binder = new RelaxedDataBinder(target);
String result = binder.normalizePath(wrapper, "nes_ted[foo][bar]");
assertThat(wrapper.getPropertyValue("nested")).isNotNull();
assertThat("nested[foo][bar]").isEqualTo(result);
assertThat(wrapper.getPropertyValue("nested[foo][bar]")).isNotNull();
}
use of org.springframework.beans.BeanWrapperImpl in project spring-boot by spring-projects.
the class BindingPreparationTests method testBeanWrapperCreatesNewMapEntries.
@Test
public void testBeanWrapperCreatesNewMapEntries() throws Exception {
TargetWithNestedMapOfBean target = new TargetWithNestedMapOfBean();
BeanWrapperImpl wrapper = new BeanWrapperImpl(target);
wrapper.setAutoGrowNestedPaths(true);
// For a nested map, you only have to get an element of it for it to be created
wrapper.getPropertyValue("nested[foo]");
wrapper.setPropertyValue("nested[foo].foo", "bar");
assertThat(wrapper.getPropertyValue("nested")).isNotNull();
assertThat(wrapper.getPropertyValue("nested[foo]")).isNotNull();
}
use of org.springframework.beans.BeanWrapperImpl in project spring-boot by spring-projects.
the class BindingPreparationTests method testAutoGrowNewNestedMapOfMaps.
@Test
public void testAutoGrowNewNestedMapOfMaps() throws Exception {
TargetWithNestedMap target = new TargetWithNestedMap();
BeanWrapperImpl wrapper = new BeanWrapperImpl(target);
wrapper.setAutoGrowNestedPaths(true);
RelaxedDataBinder binder = new RelaxedDataBinder(target);
String result = binder.normalizePath(wrapper, "nested[foo][bar]");
assertThat(wrapper.getPropertyValue("nested")).isNotNull();
assertThat("nested[foo][bar]").isEqualTo(result);
assertThat(wrapper.getPropertyValue("nested[foo][bar]")).isNotNull();
}
use of org.springframework.beans.BeanWrapperImpl in project spring-boot by spring-projects.
the class BindingPreparationTests method testAutoGrowListOfLists.
@Test
public void testAutoGrowListOfLists() throws Exception {
TargetWithNestedListOfLists target = new TargetWithNestedListOfLists();
BeanWrapperImpl wrapper = new BeanWrapperImpl(target);
wrapper.setAutoGrowNestedPaths(true);
RelaxedDataBinder binder = new RelaxedDataBinder(target);
binder.normalizePath(wrapper, "nested[0][1]");
assertThat(wrapper.getPropertyValue("nested")).isNotNull();
assertThat(wrapper.getPropertyValue("nested[0][1]")).isNotNull();
}
use of org.springframework.beans.BeanWrapperImpl in project spring-boot by spring-projects.
the class BindingPreparationTests method testAutoGrowWithFuzzyNameCapitals.
@Test
public void testAutoGrowWithFuzzyNameCapitals() throws Exception {
TargetWithNestedMap target = new TargetWithNestedMap();
BeanWrapperImpl wrapper = new BeanWrapperImpl(target);
wrapper.setAutoGrowNestedPaths(true);
RelaxedDataBinder binder = new RelaxedDataBinder(target);
String result = binder.normalizePath(wrapper, "NESTED[foo][bar]");
assertThat(wrapper.getPropertyValue("nested")).isNotNull();
assertThat("nested[foo][bar]").isEqualTo(result);
assertThat(wrapper.getPropertyValue("nested[foo][bar]")).isNotNull();
}
Aggregations