void () { ArrayList list = new ArrayList(Arrays.asList(null, "a", null, "b")); MockIterator mockIterator = new MockIterator(list.iterator()); MockCondition mockCondition = new MockCondition(STRINGS_ONLY); Iterator iterator = FilteringIterator.create(mockIterator, mockCondition); assertTrue(iterator.hasNext()); assertTrue(iterator.hasNext()); assertEquals(2, mockIterator.myHasNextCalls); assertEquals(2, mockCondition.myValueCalls); assertEquals("a", iterator.next()); assertEquals(2, mockIterator.myHasNextCalls); assertEquals(2, mockCondition.myValueCalls); iterator.remove(); assertEquals(2, mockIterator.myHasNextCalls); assertEquals(2, mockCondition.myValueCalls); assertTrue(iterator.hasNext()); assertTrue(iterator.hasNext()); assertEquals(4, mockIterator.myHasNextCalls); assertEquals(4, mockCondition.myValueCalls); assertEquals("b", iterator.next()); assertEquals(4, mockIterator.myHasNextCalls); assertEquals(4, mockCondition.myValueCalls); assertEquals(3, list.size()); }