assertEquals(1, a2.getPostLoaded());
assertSame(a2, listener.getPublicCalledbackEntity());
}
public void testPostLoad_ThatModifiesObject() {
LifecycleCallbackRegistry registry = resolver.getCallbackRegistry();
registry.addCallback(LifecycleEvent.POST_LOAD, Artist.class, "postLoadCallback");
MockCallingBackListener listener = new MockCallingBackListener() {
@Override
public void publicCallback(Object entity) {
super.publicCallback(entity);
Artist a = (Artist)entity;
a.setArtistName("Changed"); // modify object during postLoad callback
}
};
registry.addListener(
LifecycleEvent.POST_LOAD,
Artist.class,
listener,
"publicCallback");