}
@Test
public void testCopyProperties() {
assertNull("Null is cloned as null", BeanUtils.copyProperties(null));
SimpleEntity e = entityManager.find(SimpleEntity.class, pk);
SimpleEntity target = new SimpleEntity();
BeanUtils.copyProperties(e, target);
assertEquals("String copied", "a name", target.getName());
assertNull("Non initialized object is not copied", target.getCglibEntity());
assertNull("Non initialized collection is not copied", target.getSimpleCollection());
SimpleInnerEntity inner = BeanUtils.copyProperties(e.getCglibEntity());
assertNull("Non initialized CGLIB object is not cloned", inner);
e.getSimpleCollection().size();
e.getCglibEntity().getName();
target = new SimpleEntity();
BeanUtils.copyProperties(e, target);
assertTrue("Initialized collection is copied", target.getSimpleCollection().size() == 2);
assertNotNull("Initialized object is copied", target.getCglibEntity().getId());
assertEquals("Initialized object is copied", "simple inner entity", target.getCglibEntity().getName());
inner = BeanUtils.copyProperties(e.getCglibEntity());
assertEquals("CGLIB objects are copied", "simple inner entity", inner.getName());
target = new SimpleEntity();
BeanUtils.copyProperties(e, target, Arrays.asList("name"));
assertNull("Properties are ignored", target.getName());
}