Utils { public static List<Method> getAnnotatedMethods(Class<?> clazz, Class<? extends Annotation> ann) { List<Method> methods = new ArrayList<>(); Method[] declared = clazz.getDeclaredMethods(); for (Method method : declared) { if (method.getAnnotation(ann) != null) { methods.add(method); } } return methods; } private  Utils(); static int getCurrentVersionCode(Context context); static SharedPreferences getDefaultSharedPreferences(Context context, String prefName); static List<Method> getAnnotatedMethods(Class<?> clazz, Class<? extends Annotation> ann); static boolean hasAnnotatedMethods(Class<?> clazz, Class<? extends Annotation> ann); static void dispatch(VersionModule module, Method method); static boolean containsValueInRange(int[] values, int min, int max); static boolean isNewInstall(int baseCode); static final String TAG; }
@Test public void getAnnotatedMethods() throws Exception { assertEquals(1, Utils.getAnnotatedMethods(MockVersionModule.class, VersionCode.class).size()); assertEquals("foo", Utils.getAnnotatedMethods(MockVersionModule.class, VersionCode.class).get(0).getName()); }