PmEventApi { public static <T extends PmEventListener> T addPmEventListener(PmObject pm, int eventMask, T listener) { apiHandler.addPmEventListener(pm, eventMask, listener); return listener; }  static T addValueChangeDecorator(PmAttr<?> pmAttr, T decorator); static T addPmEventListener(PmObject pm, int eventMask, T listener); static T addWeakPmEventListener(PmObject pm, int eventMask, T listener); static T addHierarchyListener(PmObject hierachyRootPm, int eventMask, T listener); static T addWeakHierarchyListener(PmObject hierachyRootPm, int eventMask, T listener); static void removePmEventListener(PmObject pm, PmEventListener listener); static void firePmEvent(PmObject pm, int eventMask, ValueChangeKind valueChangeKind); static void firePmEvent(PmObject pm, int eventMask); static void firePmEventIfInitialized(PmObject pm, int eventMask, ValueChangeKind valueChangeKind); static void firePmEventIfInitialized(PmObject pm, int eventMask); static void firePmEvent(PmObject pm, PmEvent event); static void broadcastPmEvent(PmObject rootPm, int eventMask); static Object ensureThreadEventSource(Object param); static void setApiHandler(PmEventApiHandler newApiHandler);  }
@Test public void testPostEventCallbackForRecursiveEventCall() { final String[] receivedPostProcessingPayload = new String[1]; final PostProcessor<String> eventPostProcessor = new PostProcessor<String>() { @Override public void postProcess(PmEvent event, String postProcessPayload) { assertNull(receivedPostProcessingPayload[0]); receivedPostProcessingPayload[0] = postProcessPayload; } }; PmEventApi.addPmEventListener(myPm.s, PmEvent.TITLE_CHANGE, new PmEventListener() { @Override public void handleEvent(PmEvent event) { event.addPostProcessingListener(eventPostProcessor, "This is my payload."); assertNull("The post processing should not happen immediately.", receivedPostProcessingPayload[0]); } }); new BroadcastPmEventProcessor(myPm, PmEvent.TITLE_CHANGE).doIt(); assertEquals("This is my payload.", receivedPostProcessingPayload[0]); }