IteratorHelper { private IteratorHelper() { throw new UnsupportedOperationException(); } private  IteratorHelper(); static boolean contains(final Iterator<? extends E> iter, final E item); static int size(final Iterator<E> iter);  }
@Test public final void testIteratorHelper() { List<String> fruits = new ArrayList<String>(LIST_SIZE); fruits.add("Apple"); fruits.add("Orange"); fruits.add("Pear"); assertTrue(IteratorHelper.contains(fruits.iterator(), "Apple")); assertFalse(IteratorHelper.contains(fruits.iterator(), "Potato")); try { IteratorHelper.contains(fruits.iterator(), null); Assert.fail("Expected NullPointerException missing"); } catch (NullPointerException e) { assertNotNull(e); } try { IteratorHelper.contains(null, "Apple"); fail("Expected NullPointerException missing"); } catch (NullPointerException e) { assertNotNull(e); } assertEquals(IteratorHelper.size(fruits.iterator()), LIST_SIZE, "Unexpected size delivered."); try { IteratorHelper.size(null); Assert.fail("Expected NullPointerException missing"); } catch (NullPointerException e) { assertNotNull(e); } }