### Question:
Iterators { public static <T> List<T> asList(Iterator<? extends T> iterator) { List<T> list = new ArrayList<T>(); while (iterator.hasNext()) { list.add(iterator.next()); } return list; } private  Iterators(); static Iterator<T> emptyIterator(); static Iterable<T> asIterable(Iterator<T> iterator); static List<T> asList(Iterator<? extends T> iterator); static Set<T> asSet(Iterator<? extends T> iterator); static Multiset<T> asMultiset(Iterator<? extends T> iterator); static UnaryFunction<? super Iterable<? extends T>, Iterator<? extends T>> fromIterableToIterator(); static UnaryFunction<? super Iterable<? extends T>, Iterator<? extends T>> fromIterableToIterator(Class<T> ofKlass); static UnaryFunction<Iterable<? extends T>, Iterator<? extends T>> fromIterableToIteratorKeepingNull(); static UnaryFunction<Iterable<? extends T>, Iterator<? extends T>> fromIterableToIteratorKeepingNull(Class<T> ofKlass);  }### Answer:
@Test public void shouldConvertTheSuppliedIteratorToAList() { List<String> expectedList = listWith("a", "b", "c"); Iterator<String> iterator = expectedList.iterator(); List<String> actualList = asList(iterator); assertThat(actualList, is(expectedList)); }
@Test(expected = NullPointerException.class) public void shouldThrowANullPointerExceptionIfIterablePassedToAsListIsNull() throws Exception { asList(null); }