RangeIteratorFacade implements RangeIterator { @Override public Object next() { throw new UnsupportedOperationException("override this method to ensure delegate elements are wrapped appropriately with facades."); } RangeIteratorFacade(final @NotNull R delegate); @Override final void skip(long skipNum); @Override final long getSize(); @Override final long getPosition(); @Override final boolean hasNext(); @Override Object next();  }
@Test(expected = UnsupportedOperationException.class) public void testNextThrows() { RangeIterator delegate = mock(RangeIterator.class); RangeIteratorFacade<RangeIterator> facade = getFacade(delegate); doThrow(new IllegalArgumentException("base facade class illegally called delegate next() method")).when(delegate).next(); facade.next(); }