DiscoveredList extends ObservedList<T> implements AdvertisementFoundListener, AdvertisementLostListener { public void dropAll() { mHandler.post( new Runnable() { @Override public void run() { while (size() > 0) { remove(size() - 1); } } }); } DiscoveredList(AdConverter<T> converter, IdSet rejects, Handler handler); @Override void handleFoundAdvertisement(Advertisement advertisement); @Override void handleLostAdvertisement(Advertisement advertisement); void dropAll();  }
@Test public void dropAll() throws Exception { mList.setObserver(mObserver); mList.push(THING0); mList.push(THING1); verify(mObserver, times(2)).notifyItemInserted(0); assertEquals(2, mList.size()); mList.dropAll(); verify(mHandler).post(mRunnable.capture()); mRunnable.getValue().run(); assertEquals(0, mList.size()); verify(mObserver).notifyItemRemoved(1); verify(mObserver).notifyItemRemoved(0); verifyNoMoreInteractions(mObserver); }