### Question:
DatabaseDocumentIterator extends AbstractDocumentIterator<String> { @Override public long size() { long size = 0; try { getQuery(); for (String wikiName : getWikis()) { size += (long) countQuery.setWiki(wikiName).execute().get(0); } } catch (QueryException e) { throw new IllegalStateException("Failed to count the documents.", e); } return size; }  @Override boolean hasNext(); @Override Pair<DocumentReference, String> next(); @Override long size();  }### Answer:
@Test void sizeWithException() throws Exception { doThrow(QueryException.class).when(this.queryManager).createQuery(anyString(), anyString()); assertThrows(IllegalStateException.class, () -> this.databaseIterator.size(), "Failed to query the Solr index."); }