assertFalse(p3.isPostAdded());
assertSame(a3, listener2.getPublicCalledbackEntity());
}
public void testPrePersistCallbacks() {
LifecycleCallbackRegistry registry = getDomain()
.getEntityResolver()
.getCallbackRegistry();
DataContext context = createDataContext();
// no callbacks
Artist a1 = context.newObject(Artist.class);
a1.setArtistName("1");
assertFalse(a1.isPrePersisted());
context.commitChanges();
assertFalse(a1.isPrePersisted());
registry.addListener(
LifecycleEvent.PRE_PERSIST,
Artist.class,
"prePersistCallback");
Artist a2 = context.newObject(Artist.class);
a2.setArtistName("2");
assertFalse(a2.isPrePersisted());
context.commitChanges();
assertTrue(a2.isPrePersisted());
MockCallingBackListener listener2 = new MockCallingBackListener();
registry.addListener(
LifecycleEvent.PRE_PERSIST,
Artist.class,
listener2,
"publicCallback");