### Question:
LocalChangeEvent extends AbstractChangeEvent { @Override public boolean isValid() { try { long currentMtime = Files.getLastModifiedTime(getPath()).toMillis(); boolean valid = currentMtime == getMtime(); if (!valid) { LoggerFactory.getLogger(getClass()).debug("event invalid: mtime " + currentMtime + " != " + getMtime() + " on " + getPath()); } return valid; } catch (IOException e) { return type == DELETE; } } LocalChangeEvent(Path path, ChangeEvent.TYPE type);  LocalChangeEvent(Path path, boolean isDir, Long mtime, ChangeEvent.TYPE type); @Override boolean isValid(); @Override long getSize();  }### Answer:
@Test public void updateTypeIsValidOnSameMtime() { LocalChangeEvent event = new LocalChangeEvent(file, true, mtime, UPDATE); assertTrue(event.isValid()); }
@Test public void updateTypeInvalidatesOnMtimeChange() { LocalChangeEvent event = new LocalChangeEvent(file, true, mtime, UPDATE); file.toFile().setLastModified(123456); assertFalse(event.isValid()); }
@Test public void updateTypeInvalidatesOnDelete() { LocalChangeEvent event = new LocalChangeEvent(file, true, mtime, UPDATE); file.toFile().delete(); assertFalse(event.isValid()); }
@Test public void updateTypeDirectoryValidatesByDefault() { LocalChangeEvent event = new LocalChangeEvent(tmpDir, true, mtime, UPDATE); assertTrue(event.isValid()); }
@Test public void updateTypeDirectoryInvalidatesOnDelete() { Path path = Paths.get(tmpDir + "/subdir"); path.toFile().mkdir(); LocalChangeEvent event = new LocalChangeEvent(path, true, mtime, CREATE); path.toFile().delete(); assertFalse(event.isValid()); }
@Test public void deleteTypeIsValidWhileDeleted() { LocalChangeEvent event = new LocalChangeEvent(Paths.get(tmpDir + "/inexistent"), true, 0L, DELETE); assertTrue(event.isValid()); }
@Test public void deleteTypeInvalidatesOnCreation() throws IOException { Path path = Paths.get(tmpDir + "/inexistent"); LocalChangeEvent event = new LocalChangeEvent(path, true, 0L, DELETE); path.toFile().createNewFile(); assertFalse(event.isValid()); }
@Test public void deleteTypeInvalidatesOnMkdir() throws IOException { Path path = Paths.get(tmpDir + "/subdir"); LocalChangeEvent event = new LocalChangeEvent(path, true, 0L, DELETE); path.toFile().mkdir(); assertFalse(event.isValid()); }