### Question:
Reflections { public Set<Method> getMethodsAnnotatedWith(Class<? extends Annotation> annotation) { ensureScan(); synchronized (MONITOR) { Set<Method> result = annotationClassToMethod.get(annotation); if (result != null) { return result; } Set<Method> newResult = new LinkedHashSet<>(); visitEveryClass(new Visitor() { @Override public void visit(Class<?> clazz) { for (Method method : clazz.getDeclaredMethods()) { if (method.getDeclaredAnnotation(annotation) != null) { if (annotation.equals(UseCaseRestDoc.class)){ if (GeneratorConstants.DEBUG) { LOG.info("UsecaseRestDoc found:{}",clazz); } } newResult.add(method); } } } }); annotationClassToMethod.put(annotation, newResult); return newResult; } } Reflections(); Set<Class<?>> getTypesAnnotatedWith(Class<? extends Annotation> annotation); Set<Method> getMethodsAnnotatedWith(Class<? extends Annotation> annotation); Set<Field> getFieldsAnnotatedWith(Class<? extends Annotation> annotation); Set<Class<? extends T>> getSubTypesOf(Class<T> clazz); boolean isInspecting(Class<?> clazz); int getAmountOfInspectedClasses();  }### Answer:
@Test public void getMethodsAnnotatedWith() { Set<Method> found = reflectionsToTest.getMethodsAnnotatedWith(ReflectionsExampleUsageAnnotation.class); assertNotNull(found); assertEquals(4, found.size()); Set<String> sortedSet = new TreeSet<>(); for (Method method : found) { sortedSet.add(method.toString()); } assertFound("public void com.daimler.sechub.docgen.reflections.ReflectionsExampleClass1.method1()",sortedSet); assertFound("public void com.daimler.sechub.docgen.reflections.ReflectionsExampleClass1.method2()",sortedSet); assertFound("public void com.daimler.sechub.docgen.reflections.ReflectionsExampleClass2.method1()",sortedSet); assertFound("public void com.daimler.sechub.docgen.reflections.ReflectionsExampleClass2.method2()",sortedSet); }