@Test public void shouldDetectFileDelete() throws IOException, InterruptedException { File shouldChangeFile = temporaryFolder.newFile("testFile_tracked_3"); FileWatchListener shouldBeCalledListener = mock(FileWatchListener.class); final CountDownLatch startupWaitLatch = new CountDownLatch(1); this.runner = FileWatcherRunner.create() .watchForChangesIn(shouldChangeFile.toPath()) .listenToDelete() .andOnChangeNotify(shouldBeCalledListener) .andOnStartupNotify(startupWaitLatch::countDown) .buildAndStartWatcher(); verify(shouldBeCalledListener, never()).fileModified(); startupWaitLatch.await(TIMEOUT, TimeUnit.MILLISECONDS); Files.delete(shouldChangeFile.toPath()); verify(shouldBeCalledListener, timeout(TIMEOUT)).fileModified(); }
public static Builder create() { return new Builder(); }
FileWatcherRunner { public static Builder create() { return new Builder(); } }
FileWatcherRunner { public static Builder create() { return new Builder(); } private  FileWatcherRunner(FileWatcher watcher); }
FileWatcherRunner { public static Builder create() { return new Builder(); } private  FileWatcherRunner(FileWatcher watcher); static Builder create(); void stop(); }
FileWatcherRunner { public static Builder create() { return new Builder(); } private  FileWatcherRunner(FileWatcher watcher); static Builder create(); void stop();  }