### Question:
Algorithm { static <E, Ite extends Iterable<E>> void forEach(Ite input, Consumer<E> consumer) { for (E element : input) { try { consumer.consume(element); } catch (Throwable throwable) { throw new RuntimeException(throwable); } } }  static ArrayList<E> findAll(Ite input, Predicate<E> predicate);  }### Answer:
@Test public void testForEachWithEmptyIterable() { Iterable<Boolean> iterable = new ArrayList<Boolean>(); forEach(iterable, new Consumer<Boolean>() { @Override public void consume(Boolean value) { fail("Should not consume empty Iterable."); } }); }
@Test public void testForEachWithNonEmptyIterable() { Iterable<Boolean> iterable = Arrays.asList(Boolean.TRUE); final AtomicBoolean consumeCheck = new AtomicBoolean(false); forEach(iterable, new Consumer<Boolean>() { @Override public void consume(Boolean value) { consumeCheck.set(true); } }); assertThat("During evaluation, the consumer should have set check to true", consumeCheck.get(), is(true)); }