### Question:
Event implements Comparable<Event> { public long getTime() { return time; } Event(long timeFromNowNs); abstract void trigger(); long getTime(); @Override int compareTo(Event o);  }### Answer:
@Test public void testQueueOrder() { Event e1 = new FlowStartEvent(1000, null, 0, 0); Event e2 = new FlowStartEvent(0, null, 0, 0); Event e3 = new FlowStartEvent(848, null, 0, 0); Event e4 = new FlowStartEvent(1000, null, 0, 0); Event e5 = new FlowStartEvent(999999, null, 0, 0); PriorityQueue<Event> queue = new PriorityQueue<>(); queue.add(e1); queue.add(e2); queue.add(e3); queue.add(e4); queue.add(e5); assertEquals(queue.size(), 5); assertEquals(queue.peek().getTime(), 0); assertEquals(queue.poll().getTime(), 0); assertEquals(queue.size(), 4); assertEquals(queue.poll().getTime(), 848); assertEquals(queue.size(), 3); assertEquals(queue.poll().getTime(), 1000); assertEquals(queue.size(), 2); assertEquals(queue.poll().getTime(), 1000); assertEquals(queue.size(), 1); assertEquals(queue.poll().getTime(), 999999); assertEquals(queue.size(), 0); assertEquals(null, queue.poll()); }