### Question:
FilteringGenerator implements Generator<T> { @Override public T next() { T next; do { next = delegate.next(); } while (!predicate.apply(next)); return next; } FilteringGenerator(@Nonnull Generator<T> delegate, @Nonnull Predicate<T> predicate); @Override T next();  }### Answer:
@Test public void shouldFilterGeneratedValueUsingSuppliedPredicate() { Generator<Integer> oddNumbers = new FilteringGenerator<>(new RandomFromCollectionGenerator<>(1, 2, 3, 4, 5), new Predicate<Integer>() { @Override public boolean apply(Integer input) { return input % 2 != 0; } }); for (int i = 0; i < 10; i++) { assertThat(oddNumbers.next(), isOneOf(1, 3, 5)); } }