### Question:
GeneratorIterable implements Iterable<T> { @Override public Iterator<T> iterator() { return new Iterator<T>() { private int cursor = 0; @Override public boolean hasNext() { return size == INFINITE_SIZE || cursor < size; } @Override public T next() { if (!hasNext()) { throw new NoSuchElementException(); } cursor++; return generator.next(); } @Override public void remove() { throw new UnsupportedOperationException("remove() operation is not supported"); } }; } GeneratorIterable(int limit, @Nonnull Generator<T> generator);  GeneratorIterable(@Nonnull Generator<T> generator); @Override Iterator<T> iterator();  }### Answer:
@Test public void shouldFailIfThereAreNoMoreItems() { expectedException.expect(NoSuchElementException.class); Iterable<Integer> generatorIterable = new GeneratorIterable<>(0, Generators.positiveInts); Iterator<Integer> iterator = generatorIterable.iterator(); iterator.next(); }
@Test public void shouldFailIfRemoveCalled() { expectedException.expect(UnsupportedOperationException.class); expectedException.expectMessage("remove() operation is not supported"); new GeneratorIterable<>(2, Generators.positiveInts).iterator().remove(); }