### Question:
MethodHierarchyMatcher extends ElementMatcher.Junction.AbstractBase<MethodDescription> { @Override public boolean matches(MethodDescription targetMethod) { return declaresInHierarchy(targetMethod, targetMethod.getDeclaringType().asErasure()); } MethodHierarchyMatcher(ElementMatcher<? super MethodDescription> extraMethodMatcher); private  MethodHierarchyMatcher(ElementMatcher<? super MethodDescription> extraMethodMatcher, ElementMatcher<? super TypeDescription> superClassMatcher); ElementMatcher<MethodDescription> onSuperClassesThat(ElementMatcher<? super TypeDescription> superClassMatcher); @Override boolean matches(MethodDescription targetMethod);  }### Answer:
@Test void testMatchInSameClass() throws Exception { assertThat(CustomElementMatchers.overridesOrImplementsMethodThat(isAnnotatedWith(FindMe.class)) .matches(new MethodDescription.ForLoadedMethod(TestClass.class.getDeclaredMethod("findInSameClass")))) .isTrue(); }
@Test void testMatchInInterfaceOfSuperClass() throws Exception { assertThat(CustomElementMatchers.overridesOrImplementsMethodThat(isAnnotatedWith(FindMe.class)) .matches(new MethodDescription.ForLoadedMethod(TestClass.class.getDeclaredMethod("findInInterfaceOfSuperClass")))) .isTrue(); }
@Test void testMatchInSuperInterface() throws Exception { assertThat(CustomElementMatchers.overridesOrImplementsMethodThat(isAnnotatedWith(FindMe.class)) .matches(new MethodDescription.ForLoadedMethod(TestClass.class.getDeclaredMethod("findInSuperInterface")))) .isTrue(); }
@Test void testMatchInInterface() throws Exception { assertThat(CustomElementMatchers.overridesOrImplementsMethodThat(isAnnotatedWith(FindMe.class)) .matches(new MethodDescription.ForLoadedMethod(TestClass.class.getDeclaredMethod("findInInterface")))) .isTrue(); }