### Question:
Worksheets implements Iterable<FilteredSheet> { @Override public AbstractIterator<FilteredSheet> iterator() { return new AbstractIterator<FilteredSheet>() { private int sheetIndex = 0; @Override protected FilteredSheet computeNext() { if (sheetIndex >= numberOfSheets) { return endOfData(); } final Sheet currentSheet = workbook.getSheetAt(sheetIndex++); final FilteredSheet filteredSheet = new FilteredSheet(currentSheet); return isEmpty(filteredSheet) ? computeNext() : filteredSheet; } }; } Worksheets(final Workbook wb); @Override AbstractIterator<FilteredSheet> iterator();  }### Answer:
@Test public void testWorkbookWithOneEmptySheet() { when(mockSheet1.iterator()).thenAnswer(iterateOver()); when(mockWorkbook.getNumberOfSheets()).thenReturn(1); when(mockWorkbook.getSheetAt(0)).thenReturn(mockSheet1); assertTrue(isEmpty(new Worksheets(mockWorkbook))); }
@Test public void testWorkbookWithThreeEmptySheets() { when(mockSheet1.iterator()).thenAnswer(iterateOver()); when(mockWorkbook.getNumberOfSheets()).thenReturn(3); when(mockWorkbook.getSheetAt(0)).thenReturn(mockSheet1); when(mockWorkbook.getSheetAt(1)).thenReturn(mockSheet1); when(mockWorkbook.getSheetAt(2)).thenReturn(mockSheet1); assertTrue(isEmpty(new Worksheets(mockWorkbook))); }
@Test public void testWorkbookWithOneDataSheet() { when(mockSheet1.iterator()).thenAnswer(iterateOver(mockRow)); when(mockSheet1.getRow(0)).thenReturn(mockRow); when(mockSheet1.getFirstRowNum()).thenReturn(0); when(mockSheet1.getLastRowNum()).thenReturn(0); when(mockWorkbook.getNumberOfSheets()).thenReturn(1); when(mockWorkbook.getSheetAt(0)).thenReturn(mockSheet1); assertEquals(mockRow, getOnlyElement(getOnlyElement(new Worksheets(mockWorkbook)))); }
@Test public void testWorkbookWithThreeDataSheets() { when(mockSheet1.iterator()).thenAnswer(iterateOver(mockRow)); when(mockSheet1.getRow(0)).thenReturn(mockRow); when(mockSheet1.getFirstRowNum()).thenReturn(0); when(mockSheet1.getLastRowNum()).thenReturn(0); when(mockSheet2.iterator()).thenAnswer(iterateOver(mockRow)); when(mockSheet2.getRow(0)).thenReturn(mockRow); when(mockSheet2.getFirstRowNum()).thenReturn(0); when(mockSheet2.getLastRowNum()).thenReturn(0); when(mockSheet3.iterator()).thenAnswer(iterateOver(mockRow)); when(mockSheet3.getRow(0)).thenReturn(mockRow); when(mockSheet3.getFirstRowNum()).thenReturn(0); when(mockSheet3.getLastRowNum()).thenReturn(0); when(mockWorkbook.getNumberOfSheets()).thenReturn(3); when(mockWorkbook.getSheetAt(0)).thenReturn(mockSheet1); when(mockWorkbook.getSheetAt(1)).thenReturn(mockSheet2); when(mockWorkbook.getSheetAt(2)).thenReturn(mockSheet3); assertEquals(3, size(new Worksheets(mockWorkbook))); }