private void assertWatcherHasEvents(List<WatchEvent<?>> expected, List<WatchEvent<?>> alternate)
      throws InterruptedException {
    ensureTimeToPoll(); // otherwise we could read 1 event but not all the events we're expecting
    WatchKey key = watcher.take();
    List<WatchEvent<?>> keyEvents = key.pollEvents();

    if (keyEvents.size() == expected.size() || alternate.isEmpty()) {
      assertThat(keyEvents).containsExactlyElementsIn(expected);
    } else {
      assertThat(keyEvents).containsExactlyElementsIn(alternate);
    }
    key.reset();
  }
Tests for {@link PollingWatchService}.

@author Colin Decker
jimfs/src/test/java/com/google/common/jimfs/PollingWatchServiceTest.java