use of org.springframework.beans.BeanWrapperImpl in project spring-boot by spring-projects.
the class BindingPreparationTests method testBeanWrapperCreatesNewMaps.
@Test
public void testBeanWrapperCreatesNewMaps() throws Exception {
TargetWithNestedMap target = new TargetWithNestedMap();
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]");
assertThat(wrapper.getPropertyValue("nested")).isNotNull();
}
use of org.springframework.beans.BeanWrapperImpl in project spring-boot by spring-projects.
the class BindingPreparationTests method testListOfBeansWithListAndNoPeriod.
@Test
public void testListOfBeansWithListAndNoPeriod() throws Exception {
TargetWithNestedListOfBeansWithList target = new TargetWithNestedListOfBeansWithList();
BeanWrapperImpl wrapper = new BeanWrapperImpl(target);
wrapper.setAutoGrowNestedPaths(true);
RelaxedDataBinder binder = new RelaxedDataBinder(target);
binder.normalizePath(wrapper, "nested[0]list[1]");
assertThat(wrapper.getPropertyValue("nested")).isNotNull();
assertThat(wrapper.getPropertyValue("nested[0].list[1]")).isNotNull();
}
use of org.springframework.beans.BeanWrapperImpl in project spring-boot by spring-projects.
the class BindingPreparationTests method testAutoGrowNewNestedMapOfBeans.
@Test
public void testAutoGrowNewNestedMapOfBeans() throws Exception {
TargetWithNestedMapOfBean target = new TargetWithNestedMapOfBean();
BeanWrapperImpl wrapper = new BeanWrapperImpl(target);
wrapper.setAutoGrowNestedPaths(true);
RelaxedDataBinder binder = new RelaxedDataBinder(target);
String result = binder.normalizePath(wrapper, "nested[foo].foo");
assertThat(wrapper.getPropertyValue("nested")).isNotNull();
assertThat("nested[foo].foo").isEqualTo(result);
assertThat(wrapper.getPropertyValue("nested[foo]")).isNotNull();
}
use of org.springframework.beans.BeanWrapperImpl in project spring-framework by spring-projects.
the class JmxUtilsTests method testGetAttributeNameWithStrictCasing.
@Test
public void testGetAttributeNameWithStrictCasing() {
PropertyDescriptor pd = new BeanWrapperImpl(AttributeTestBean.class).getPropertyDescriptor("name");
String attributeName = JmxUtils.getAttributeName(pd, true);
assertEquals("Incorrect casing on attribute name", "Name", attributeName);
}
use of org.springframework.beans.BeanWrapperImpl in project spring-framework by spring-projects.
the class JmxUtilsTests method testGetAttributeNameWithoutStrictCasing.
@Test
public void testGetAttributeNameWithoutStrictCasing() {
PropertyDescriptor pd = new BeanWrapperImpl(AttributeTestBean.class).getPropertyDescriptor("name");
String attributeName = JmxUtils.getAttributeName(pd, false);
assertEquals("Incorrect casing on attribute name", "name", attributeName);
}
Aggregations