ReadyServiceImpl implements ReadyService { @Override public void unregisterTracker(ReadyTracker readyTracker) { rwlTrackers.writeLock().lock(); try { if (trackers.containsKey(readyTracker)) { notifyTracker(readyTracker, marker -> readyTracker.onReadyMarkerRemoved(marker)); } trackers.remove(readyTracker); } finally { rwlTrackers.writeLock().unlock(); } }  @Override void markReady(ReadyMarker readyMarker); @Override void unmarkReady(ReadyMarker readyMarker); @Override boolean isReady(ReadyMarker readyMarker); @Override void registerTracker(ReadyTracker readyTracker); @Override void registerTracker(ReadyTracker readyTracker, ReadyMarkerFilter filter); @Override void unregisterTracker(ReadyTracker readyTracker);  }
@Test public void testUnregisterTracker() { ReadyTracker tracker = mock(ReadyTracker.class); ReadyServiceImpl rs = new ReadyServiceImpl(); rs.markReady(new ReadyMarker("foo", "id")); rs.registerTracker(tracker, new ReadyMarkerFilter()); verify(tracker).onReadyMarkerAdded(isA(ReadyMarker.class)); rs.unregisterTracker(tracker); verify(tracker).onReadyMarkerRemoved(isA(ReadyMarker.class)); verifyNoMoreInteractions(tracker); }