### Question:
Algorithm { static <E> Predicate<E> negate(final Predicate<E> predicate) { return new Predicate<E>() { @Override public boolean test(E element) { return ! predicate.test(element); } }; }  static ArrayList<E> findAll(Ite input, Predicate<E> predicate);  }### Answer:
@Test public void testNegate() { final AtomicBoolean predicateCheck = new AtomicBoolean(false); Predicate<Integer> isGreaterThan42 = new Predicate<Integer>() { @Override public boolean test(Integer integer) { predicateCheck.set(true); return integer > 42; } }; Predicate<Integer> isFeawerThan42 = negate(isGreaterThan42); assertThat("The negate predicate is always different than the base predicate", isGreaterThan42.test(1), is(not(isFeawerThan42.test(1)))); assertThat("The negate predicate is always different than the base predicate", isGreaterThan42.test(50), is(not(isFeawerThan42.test(50)))); assertThat("During evaluation, the predicate should have set check to true", predicateCheck.get(), is(true)); }