FileChangeIngestor implements Runnable, ChangeIngestor { protected boolean targetChanged() { boolean targetChanged = false; final WatchKey watchKey = this.watchService.poll(); if (watchKey == null) { return targetChanged; } for (WatchEvent<?> watchEvt : watchKey.pollEvents()) { final WatchEvent.Kind<?> evtKind = watchEvt.kind(); final WatchEvent<Path> pathEvent = (WatchEvent<Path>) watchEvt; final Path changedFile = pathEvent.context(); targetChanged = (evtKind == ENTRY_MODIFY && changedFile.equals(configFilePath.getName(configFilePath.getNameCount() - 1))); } boolean valid = watchKey.reset(); if (!valid) { throw new IllegalStateException("Unable to reinitialize file system watcher."); } return targetChanged; }  @Override void run(); @Override void initialize(Properties properties, ConfigurationFileHolder configurationFileHolder, ConfigurationChangeNotifier configurationChangeNotifier); @Override void start(); @Override void close(); static final String DIFFERENTIATOR_KEY; }
@Test public void testTargetChangedWithModificationEvent_nonConfigFile() throws Exception { when(mockDifferentiator.isNew(Mockito.any(InputStream.class))).thenReturn(false); final ConfigurationChangeNotifier testNotifier = Mockito.mock(ConfigurationChangeNotifier.class); final WatchKey mockWatchKey = createMockWatchKeyForPath("footage_not_found.yml"); establishMockEnvironmentForChangeTests(testNotifier, mockWatchKey); notifierSpy.targetChanged(); verify(testNotifier, Mockito.never()).notifyListeners(Mockito.any(ByteBuffer.class)); }