### Question:
Generators { public static <T> Generator<T> finiteGenerator(Iterable<T> iterable) { return new FiniteGenerator<T>(iterable); } private  Generators(); static Generator<T> constantGenerator(T value); static Generator<T> finiteGenerator(Iterable<T> iterable); @ToDo(raisedBy = "Toby", date = "2012-03-25", message = "This needs to tee rather than using the same instance in the same way that toIterable would") static Generatable<T> toGeneratable(final Generator<T> generator);  }### Answer:
@Test public void shouldConstructAFiniteGeneratorUsingTheSpecifiedIterable() throws Exception { Generator<Integer> expectedGenerator = new FiniteGenerator<Integer>(iterableWith(1, 2, 3, 4)); Generator<Integer> actualGenerator = finiteGenerator(iterableWith(1, 2, 3, 4)); assertThat(actualGenerator, is(expectedGenerator)); }
@Test(expected = NullPointerException.class) public void shouldThrowANullPointerExceptionIfIterableUsedToConstructFiniteGeneratorIsNull() throws Exception { finiteGenerator(null); }