ReflectionUtils { public static Method findAMethod(Class<?> clazz, String methodName, BeanContainer beanContainer) throws NoSuchMethodException { StringTokenizer tokenizer = new StringTokenizer(methodName, "("); String m = tokenizer.nextToken(); Method result; if (tokenizer.hasMoreElements()) { StringTokenizer tokens = new StringTokenizer(tokenizer.nextToken(), ")"); String params = tokens.hasMoreTokens() ? tokens.nextToken() : null; result = findMethodWithParam(clazz, m, params, beanContainer); } else { result = findMethod(clazz, methodName); } if (result == null) { throw new NoSuchMethodException(clazz.getName() + "." + methodName); } return result; } private  ReflectionUtils(); static PropertyDescriptor findPropertyDescriptor(Class<?> objectClass, String fieldName,
                                                            HintContainer deepIndexHintContainer); static DeepHierarchyElement[] getDeepFieldHierarchy(Class<?> parentClass, String field,
                                                               HintContainer deepIndexHintContainer); static Method getMethod(Object obj, String methodName); static Method getMethod(Class<?> clazz, String methodName); static Method findAMethod(Class<?> clazz, String methodName, BeanContainer beanContainer); static PropertyDescriptor[] getPropertyDescriptors(Class<?> objectClass); static Field getFieldFromBean(Class<?> clazz, String fieldName); static Object invoke(Method method, Object obj, Object[] args); static Method getMethod(Class<?> clazz, String name, Class<?>[] parameterTypes); static T newInstance(Class<T> clazz); static Class<?> determineGenericsType(Class<?> parentClazz, PropertyDescriptor propDescriptor); static Class<?> determineGenericsType(Class<?> clazz, Method method, boolean isReadMethod); static Class<?> determineGenericsType(Type type); static Method getNonStandardSetter(Class<?> clazz, String fieldName);  }
@Test public void shouldThrowNoSuchMethodFound() throws NoSuchMethodException { Method result = ReflectionUtils.findAMethod(TestClass.class, "getC()", beanContainer); assertThat(result, notNullValue()); }
@Test public void shouldThrowNoSuchMethodFound_NoBrackets() throws NoSuchMethodException { Method result = ReflectionUtils.findAMethod(TestClass.class, "getC", beanContainer); assertThat(result, notNullValue()); }
@Test(expected = NoSuchMethodException.class) public void shouldThrowNoSuchMethodFound_Missing() throws Exception { ReflectionUtils.findAMethod(TestClass.class, "noSuchMethod()", beanContainer); fail(); }
@Test(expected = NoSuchMethodException.class) public void shouldThrowNoSuchMethodFound_MissingNoBrackets() throws Exception { ReflectionUtils.findAMethod(TestClass.class, "noSuchMethod", beanContainer); fail(); }