### Question:
ChromeDevToolsUtils { public static <T> void waitForEvent(Function<EventHandler<T>, EventListener> eventConsumer) { final CountDownLatch countDownLatch = new CountDownLatch(1); final EventListener eventListener = eventConsumer.apply( event -> { countDownLatch.countDown(); }); try { countDownLatch.await(); } catch (InterruptedException e) { throw new RuntimeException("Interrupted while waiting for event.", e); } finally { eventListener.unsubscribe(); } }  static void closeQuietly(Closeable closeable); static void waitForEvent(Function<EventHandler<T>, EventListener> eventConsumer);  }### Answer:
@Test public void testWaitForEvent() { EventListener eventListener = mock(EventListener.class); eventListener.unsubscribe(); replay(eventListener); ChromeDevToolsUtils.waitForEvent( eventHandler -> { eventHandler.onEvent(null); return eventListener; }); verify(eventListener); }