### Question:
DefinedShapeMatcher extends ElementMatcher.Junction.AbstractBase<T> { public boolean matches(T target) { return matcher.matches(target.asDefined()); } DefinedShapeMatcher(ElementMatcher<? super S> matcher); boolean matches(T target); @Override String toString();  }### Answer:
@Test @SuppressWarnings("unchecked") public void testMatch() throws Exception { when(matcher.matches(resolvedDependant)).thenReturn(true); when(dependent.asDefined()).thenReturn((ByteCodeElement.TypeDependant) resolvedDependant); assertThat(new DefinedShapeMatcher(matcher).matches(dependent), is(true)); verify(dependent).asDefined(); verifyNoMoreInteractions(dependent); verify(matcher).matches(resolvedDependant); verifyNoMoreInteractions(matcher); }
@Test @SuppressWarnings("unchecked") public void testNoMatch() throws Exception { when(matcher.matches(resolvedDependant)).thenReturn(true); when(dependent.asDefined()).thenReturn((ByteCodeElement.TypeDependant) otherResolvedDependant); assertThat(new DefinedShapeMatcher(matcher).matches(dependent), is(false)); verify(dependent).asDefined(); verifyNoMoreInteractions(dependent); verify(matcher).matches(otherResolvedDependant); verifyNoMoreInteractions(matcher); }