### Question:
EventLog { public EventLog(Function<EventLog<L, E>, L> listenerFactory) { this.listener = listenerFactory.apply(this); } EventLog(Function<EventLog<L, E>, L> listenerFactory); boolean open(); L listener(); CompletableFuture<E> nextEvent(); void addEvent(E event); boolean close();  }### Answer:
@Test public void testEventLog() throws Exception { EventLog<Consumer<String>, String> eventLog = new EventLog<>(l -> e -> l.addEvent(e)); assertTrue(eventLog.open()); assertFalse(eventLog.open()); CompletableFuture<String> nextEvent = eventLog.nextEvent(); assertFalse(nextEvent.isDone()); eventLog.listener().accept("a"); eventLog.listener().accept("b"); assertTrue(nextEvent.isDone()); assertEquals("a", nextEvent.get()); assertEquals("b", eventLog.nextEvent().get()); assertTrue(eventLog.close()); assertFalse(eventLog.close()); }