jpaMap.setPersistenceUnitMetadata(metadata);
JpaPersistenceUnitDefaults defaults = new JpaPersistenceUnitDefaults();
metadata.setPersistenceUnitDefaults(defaults);
JpaEntityListeners listeners = new JpaEntityListeners();
defaults.setEntityListeners(listeners);
JpaEntityListener l1 = new JpaEntityListener();
l1.setClassName("abc.C1");
l1.setPostLoad(new JpaLifecycleCallback("xpl1"));
l1.setPreRemove(new JpaLifecycleCallback("xpr1"));
listeners.getEntityListeners().add(l1);
JpaEntityListener l2 = new JpaEntityListener();
l2.setClassName("abc.C2");
l2.setPostLoad(new JpaLifecycleCallback("xpl2"));
l2.setPreRemove(new JpaLifecycleCallback("xpr2"));
listeners.getEntityListeners().add(l2);
DataMap cayenneMap = new DataMapConverter().toDataMap("n1", context);
Collection<EntityListener> entityListeners = cayenneMap
.getDefaultEntityListeners();
assertEquals(2, entityListeners.size());