Assert.assertEquals(TestEnum.Fifth, root.getBeanMap().get("testKey").getEnumProperty());
}
@Test(groups="fast")
public void testSetNull() throws Exception {
TestBean root = new TestBean();
// Try setting a null on a null nested property and make sure the nested
// property doesn't get instantiated
Assert.assertNull(root.getNestedBean());
BeanUtil.setPropertyToNull("nestedBean.stringProperty", root);
Assert.assertNull(root.getNestedBean());
// Now set the property set the nest bean and do it again
root.setNestedBean( new TestBean() );
BeanUtil.setPropertyToNull("nestedBean.stringProperty", root);
Assert.assertNotNull(root.getNestedBean());
Assert.assertNull(root.getNestedBean().getStringProperty());
// Now set the string property and null it out for real
root.getNestedBean().setStringProperty("Definitely Not Null");
BeanUtil.setPropertyToNull("nestedBean.stringProperty", root);
Assert.assertNotNull(root.getNestedBean());
Assert.assertNull(root.getNestedBean().getStringProperty());
// Now use setNullValue to trim the nestedBean
BeanUtil.setPropertyToNull("nestedBean", root);
Assert.assertNull(root.getNestedBean());
// Now try some nulling out of indexed properties
root.setStringList(new ArrayList<String>());
root.getStringList().add("foo");
root.getStringList().add("bar");
Assert.assertNotNull(root.getStringList().get(0));
Assert.assertNotNull(root.getStringList().get(1));
BeanUtil.setPropertyToNull("stringList[1]", root);
Assert.assertNotNull(root.getStringList().get(0));
Assert.assertNull(root.getStringList().get(1));
}