### Question:
OnlyOnceDirectoryScanner implements DirectoryScanner { @Override public void scan(final FileChangeListener listener) { if (executed.compareAndSet(false, true)) { delegate.scan(listener); } } OnlyOnceDirectoryScanner(final DirectoryScanner delegate); @Override void scan(final FileChangeListener listener);  }### Answer:
@Test public void testSubsequentInvocationsDoNotCallTheDelegate() throws Exception { OnlyOnceDirectoryScanner scanner = new OnlyOnceDirectoryScanner(delegate); scanner.scan(listener); scanner.scan(listener); scanner.scan(listener); verify(delegate).scan(listener); }