### Question:
DeclaringAnnotationMatcher extends ElementMatcher.Junction.AbstractBase<T> { public boolean matches(T target) { return matcher.matches(target.getDeclaredAnnotations()); } DeclaringAnnotationMatcher(ElementMatcher<? super AnnotationList> matcher); boolean matches(T target); @Override String toString();  }### Answer:
@Test public void testMatch() throws Exception { when(annotationSource.getDeclaredAnnotations()).thenReturn(annotationList); when(annotationMatcher.matches(annotationList)).thenReturn(true); assertThat(new DeclaringAnnotationMatcher<AnnotationSource>(annotationMatcher).matches(annotationSource), is(true)); verify(annotationMatcher).matches(annotationList); verifyNoMoreInteractions(annotationMatcher); verify(annotationSource).getDeclaredAnnotations(); verifyNoMoreInteractions(annotationSource); }
@Test public void testNoMatch() throws Exception { when(annotationSource.getDeclaredAnnotations()).thenReturn(annotationList); when(annotationMatcher.matches(annotationList)).thenReturn(false); assertThat(new DeclaringAnnotationMatcher<AnnotationSource>(annotationMatcher).matches(annotationSource), is(false)); verify(annotationMatcher).matches(annotationList); verifyNoMoreInteractions(annotationMatcher); verify(annotationSource).getDeclaredAnnotations(); verifyNoMoreInteractions(annotationSource); }