### Question:
NotPredicate implements Predicate<T> { @Override public boolean evaluate(T instance) { return !predicate.evaluate(instance); } NotPredicate(UnaryPredicate<? super T> predicate); @Override boolean evaluate(T instance); @Override boolean equals(Object other); @Override int hashCode();  }### Answer:
@Test @SuppressWarnings("unchecked") public void shouldReturnTrueIfTheSuppliedPredicateReturnsFalse() { Predicate<String> delegatePredicate = (Predicate<String>) mock(Predicate.class); when(delegatePredicate.evaluate(any(String.class))).thenReturn(false); NotPredicate<String> notPredicate = new NotPredicate<String>(delegatePredicate); Boolean result = notPredicate.evaluate("some string"); assertThat(result, is(true)); }
@Test @SuppressWarnings("unchecked") public void shouldReturnFalseIfTheSuppliedPredicateReturnsTrue() { Predicate<String> delegatePredicate = (Predicate<String>) mock(Predicate.class); when(delegatePredicate.evaluate(any(String.class))).thenReturn(true); NotPredicate<String> notPredicate = new NotPredicate<String>(delegatePredicate); Boolean result = notPredicate.evaluate("some string"); assertThat(result, is(false)); }