### Question:
GlusterWatchService implements WatchService { WatchKey popPending() { Iterator<GlusterWatchKey> iterator = pendingPaths.iterator(); try { GlusterWatchKey key = iterator.next(); iterator.remove(); return key; } catch (NoSuchElementException e) { return null; } }  WatchKey registerPath(GlusterPath path, WatchEvent.Kind... kinds); @Override void close(); @Override WatchKey poll(); @Override WatchKey poll(long timeout, TimeUnit unit); @Override WatchKey take(); static final int MILLIS_PER_SECOND; static final int MILLIS_PER_MINUTE; static final int MILLIS_PER_HOUR; static final int MILLIS_PER_DAY; static long PERIOD; }### Answer:
@Test public void testPopPending_whenNonePending() { WatchKey key = watchService.popPending(); assertEquals(null, key); assertEquals(0, watchService.getPendingPaths().size()); }
@Test public void testPopPending() { GlusterPath mockPath = mock(GlusterPath.class); GlusterWatchKey keyFix = new GlusterWatchKey(mockPath, new WatchEvent.Kind[]{StandardWatchEventKinds.ENTRY_CREATE}); watchService.getPendingPaths().add(keyFix); WatchKey key = watchService.popPending(); assertEquals(keyFix, key); assertEquals(0, watchService.getPendingPaths().size()); }