### Question:
NameMatcher extends ElementMatcher.Junction.AbstractBase<T> { public boolean matches(T target) { return matcher.matches(target.getActualName()); } NameMatcher(ElementMatcher<String> matcher); boolean matches(T target); @Override String toString();  }### Answer:
@Test public void testMatch() throws Exception { when(nameMatcher.matches(FOO)).thenReturn(true); assertThat(new NameMatcher<NamedElement>(nameMatcher).matches(namedElement), is(true)); verify(nameMatcher).matches(FOO); verifyNoMoreInteractions(nameMatcher); }
@Test public void testNoMatch() throws Exception { when(nameMatcher.matches(FOO)).thenReturn(false); assertThat(new NameMatcher<NamedElement>(nameMatcher).matches(namedElement), is(false)); verify(nameMatcher).matches(FOO); verifyNoMoreInteractions(nameMatcher); }