### Question:
NegatingMatcher extends ElementMatcher.Junction.AbstractBase<T> { public boolean matches(T target) { return !matcher.matches(target); } NegatingMatcher(ElementMatcher<? super T> matcher); boolean matches(T target); @Override String toString();  }### Answer:
@Test public void testNegateToPositive() throws Exception { Object target = new Object(); when(elementMatcher.matches(target)).thenReturn(true); assertThat(new NegatingMatcher<Object>(elementMatcher).matches(target), is(false)); verify(elementMatcher).matches(target); verifyNoMoreInteractions(elementMatcher); }
@Test public void testPositiveToNegative() throws Exception { Object target = new Object(); when(elementMatcher.matches(target)).thenReturn(false); assertThat(new NegatingMatcher<Object>(elementMatcher).matches(target), is(true)); verify(elementMatcher).matches(target); verifyNoMoreInteractions(elementMatcher); }