### Question:
CallbackOnEntity extends AbstractCallback { @Override public void performCallback(Object entity) { try { callbackMethod.invoke(entity, (Object[]) null); } catch (Exception e) { throw new CayenneRuntimeException("Error invoking entity callback method " + callbackMethod.getName(), e); } } CallbackOnEntity(Class<?> objectClass, String methodName); @Override void performCallback(Object entity); @Override String toString();  }### Answer:
@Test public void testPublicCallbackMethod() { CallbackOnEntity callback = new CallbackOnEntity( MockCallingBackEntity.class, "publicCallback"); MockCallingBackEntity e = new MockCallingBackEntity(); callback.performCallback(e); assertTrue(e.publicCallbackInvoked); assertFalse(e.protectedCallbackInvoked); assertFalse(e.privateCallbackInvoked); assertFalse(e.defaultCallbackInvoked); }
@Test public void testProtectedCallbackMethod() { CallbackOnEntity callback = new CallbackOnEntity( MockCallingBackEntity.class, "protectedCallback"); MockCallingBackEntity e = new MockCallingBackEntity(); callback.performCallback(e); assertFalse(e.publicCallbackInvoked); assertTrue(e.protectedCallbackInvoked); assertFalse(e.privateCallbackInvoked); assertFalse(e.defaultCallbackInvoked); }
@Test public void testPrivateCallbackMethod() { CallbackOnEntity callback = new CallbackOnEntity( MockCallingBackEntity.class, "privateCallback"); MockCallingBackEntity e = new MockCallingBackEntity(); callback.performCallback(e); assertFalse(e.publicCallbackInvoked); assertFalse(e.protectedCallbackInvoked); assertTrue(e.privateCallbackInvoked); assertFalse(e.defaultCallbackInvoked); }
@Test public void testDefaultCallbackMethod() { CallbackOnEntity callback = new CallbackOnEntity( MockCallingBackEntity.class, "defaultCallback"); MockCallingBackEntity e = new MockCallingBackEntity(); callback.performCallback(e); assertFalse(e.publicCallbackInvoked); assertFalse(e.protectedCallbackInvoked); assertFalse(e.privateCallbackInvoked); assertTrue(e.defaultCallbackInvoked); }