@Test void flushEvents() { this.eventManager.shouldStack(true); this.eventManager.notifyComponentRegistered(this.descriptor1); this.eventManager.notifyComponentRegistered(this.descriptor1, this.componentManager); this.eventManager.notifyComponentUnregistered(this.descriptor2); this.eventManager.notifyComponentUnregistered(this.descriptor2, this.componentManager); ComponentDescriptorAddedEvent addedEvent = new ComponentDescriptorAddedEvent(this.descriptor1.getRoleType(), this.descriptor1.getRoleHint()); ComponentDescriptorRemovedEvent removedEvent = new ComponentDescriptorRemovedEvent(this.descriptor2.getRoleType(), this.descriptor2.getRoleHint()); this.eventManager.flushEvents(); verify(this.observationManager, times(1)).notify(eq(addedEvent), same(this.componentManager), same(this.descriptor1)); verify(this.observationManager, times(1)).notify(eq(addedEvent), eq(null), same(this.descriptor1)); verify(this.observationManager, times(1)).notify(eq(removedEvent), same(this.componentManager), same(this.descriptor2)); verify(this.observationManager, times(1)).notify(eq(removedEvent), eq(null), same(this.descriptor2)); }
public synchronized void flushEvents() { while (!this.events.isEmpty()) { ComponentEventEntry entry = this.events.pop(); sendEvent(entry.event, entry.descriptor, entry.componentManager); } }
StackingComponentEventManager implements ComponentEventManager { public synchronized void flushEvents() { while (!this.events.isEmpty()) { ComponentEventEntry entry = this.events.pop(); sendEvent(entry.event, entry.descriptor, entry.componentManager); } } }
StackingComponentEventManager implements ComponentEventManager { public synchronized void flushEvents() { while (!this.events.isEmpty()) { ComponentEventEntry entry = this.events.pop(); sendEvent(entry.event, entry.descriptor, entry.componentManager); } }  }
StackingComponentEventManager implements ComponentEventManager { public synchronized void flushEvents() { while (!this.events.isEmpty()) { ComponentEventEntry entry = this.events.pop(); sendEvent(entry.event, entry.descriptor, entry.componentManager); } }  @Override void notifyComponentRegistered(ComponentDescriptor<?> descriptor); @Override void notifyComponentRegistered(ComponentDescriptor<?> descriptor, ComponentManager componentManager); @Override void notifyComponentUnregistered(ComponentDescriptor<?> descriptor); @Override void notifyComponentUnregistered(ComponentDescriptor<?> descriptor, ComponentManager componentManager); synchronized void flushEvents(); void shouldStack(boolean shouldStack); boolean isStacked(); void setObservationManager(ObservationManager observationManager); }
StackingComponentEventManager implements ComponentEventManager { public synchronized void flushEvents() { while (!this.events.isEmpty()) { ComponentEventEntry entry = this.events.pop(); sendEvent(entry.event, entry.descriptor, entry.componentManager); } }  @Override void notifyComponentRegistered(ComponentDescriptor<?> descriptor); @Override void notifyComponentRegistered(ComponentDescriptor<?> descriptor, ComponentManager componentManager); @Override void notifyComponentUnregistered(ComponentDescriptor<?> descriptor); @Override void notifyComponentUnregistered(ComponentDescriptor<?> descriptor, ComponentManager componentManager); synchronized void flushEvents(); void shouldStack(boolean shouldStack); boolean isStacked(); void setObservationManager(ObservationManager observationManager);  }