### Question:
UserEventDispatcher implements Runnable, Disposable, Initializable { public boolean addEvent(Event event) throws InterruptedException { if (!this.disposed) { if (event.getDate() == null || (System.currentTimeMillis() - event.getDate().getTime()) >= LIVE_EVENT_INTERVAL || !this.priorityQueue.offer(event)) { return addEvent(event.getId(), false); } return true; } return false; }  @Override void initialize(); @Override void dispose(); boolean addEvent(Event event); boolean addEvent(String eventId, boolean wait); @Override void run(); void dispatch(Event event);  }### Answer:
@Test void addEvent() throws InterruptedException, EventStreamException { this.dispatcher.lock.lock(); assertEquals(0, this.dispatcher.priorityQueue.size()); assertEquals(0, this.dispatcher.secondaryQueue.size()); this.dispatcher.addEvent(storeEvent("event1")); Thread.sleep(100); assertEquals(0, this.dispatcher.priorityQueue.size()); assertEquals(0, this.dispatcher.secondaryQueue.size()); assertEquals(1, this.dispatcher.dispatched.size()); this.dispatcher.addEvent(storeEvent("event2")); this.dispatcher.addEvent(storeEvent("event3")); assertEquals(2, this.dispatcher.priorityQueue.size()); assertEquals(0, this.dispatcher.secondaryQueue.size()); assertEquals(1, this.dispatcher.dispatched.size()); this.dispatcher.addEvent(storeEvent("event4", nowMinus10Minutes())); assertEquals(2, this.dispatcher.priorityQueue.size()); assertEquals(1, this.dispatcher.secondaryQueue.size()); assertEquals(1, this.dispatcher.dispatched.size()); this.dispatcher.addEvent(storeEvent("event5").getId(), true); assertEquals(2, this.dispatcher.priorityQueue.size()); assertEquals(2, this.dispatcher.secondaryQueue.size()); assertEquals(1, this.dispatcher.dispatched.size()); this.dispatcher.addEvent(storeEvent("event6").getId(), false); assertEquals(2, this.dispatcher.priorityQueue.size()); assertEquals(3, this.dispatcher.secondaryQueue.size()); assertEquals(1, this.dispatcher.dispatched.size()); this.dispatcher.skipDispatch = true; this.dispatcher.lock.unlock(); Thread.sleep(100); assertEquals(0, this.dispatcher.priorityQueue.size()); assertEquals(0, this.dispatcher.secondaryQueue.size()); assertEquals(6, this.dispatcher.dispatched.size()); }