### Question:
GeciReflectionTools { public static Method getMethod(Class<?> klass, String methodName, Class<?>... classes) throws NoSuchMethodException { return Stream.of(getAllMethodsSorted(klass)) .filter(method -> method.getName().equals(methodName) && Arrays.deepEquals(method.getParameterTypes(), classes)).findAny() .orElseThrow(() -> new NoSuchMethodException("No method " + methodName + " was found in " + klass.getName())); }  static CompoundParams getParameters(AnnotatedElement element, String generatorMnemonic); static Invoker invoke(String methodName); static String modifiersString(Method method); static String modifiersStringNoAccess(Method method); static String typeAsString(Member member); static String normalizeTypeName(String s); static String normalizeTypeName(String s, Class<?> klass); static String getGenericTypeName(Type t); static String getSimpleGenericClassName(Class<?> t); static String getLocalGenericClassName(Class<?> t); static Field[] getDeclaredFieldsSorted(Class<?> klass); static Field[] getAllFieldsSorted(Class<?> klass); static Method[] getDeclaredMethodsSorted(Class<?> klass); static Method[] getMethodsSorted(Class<?> klass); static Method[] getAllMethodsSorted(final Class<?> klass); static Class[] getAllClassesSorted(Class<?> klass); static Class[] getDeclaredClassesSorted(Class<?> klass); static Class[] getClassesSorted(Class<?> klass); static Method getMethod(Class<?> klass, String methodName, Class<?>... classes); static Field getField(Class<?> klass, String fieldName); static Class<?> classForName(String className); static String unmask(int modifiers); static int mask(String masks, int dfault); static final int PACKAGE; }### Answer:
@Test @DisplayName("Get private method from base class.") public void getOwnMethod() { Assertions.assertDoesNotThrow(() -> GeciReflectionTools.getMethod(ChildClass.class, "ownMethod")); }
@Test @DisplayName("Get inherited method from superclass") public void getInheritedMethod() { Assertions.assertDoesNotThrow(() -> GeciReflectionTools.getMethod(ChildClass.class, "inheritedMethod")); }
@Test @DisplayName("Throw exception if method does not exists.") public void throwExceptionForNoMethod() { Assertions.assertThrows(NoSuchMethodException.class, () -> GeciReflectionTools.getMethod(ChildClass.class, "noSuchMethod")); }
@Test @DisplayName("Throw exception if method exists in superclass but is not inherited.") public void throwExceptionForNotInheritedMethod() { Assertions.assertThrows(NoSuchMethodException.class, () -> GeciReflectionTools.getMethod(ChildClass.class, "notInheritedMethod")); }
@Test @DisplayName("Throw exception if a package-private method is not inherited, even if the base class and the declaring superclass is in the same package") public void throwExceptionForMethodIfPackageInheritanceIsBroken() { Assertions.assertThrows(NoSuchMethodException.class, () -> GeciReflectionTools.getMethod(ChildClass.class, "packagePrivateMethod")); }
@Test @DisplayName("Get method from superclass even if packages are not the same in the inheritance line.") public void findInheritedMethodEvenIfPackageInheritanceIsBroken() { Assertions.assertDoesNotThrow(() -> GeciReflectionTools.getMethod(ChildClass.class, "inheritedFromGrandparentMethod")); }