SilentIteration extends IterationWrapper<T, E> { @Override public T next() throws E { try { return super.next(); } catch (NoSuchElementException e) { throw e; } catch (Exception e) { if (logger.isTraceEnabled()) { logger.trace("Converted error in SILENT iteration: " + e.getMessage(), e); } throw new NoSuchElementException(e.getMessage()); } } SilentIteration(CloseableIteration<T, E> iter); @Override boolean hasNext(); @Override T next();  }
@Test public void nextConvertsException() throws Exception { when(delegate.next()).thenThrow(new RuntimeException()); assertThatExceptionOfType(NoSuchElementException.class).isThrownBy(subject::next); }