AnnotationDetector { public AnnotationDetector(final Reporter reporter) { final Class<? extends Annotation>[] a = reporter.annotations(); annotations = new HashMap<>(a.length); for (int i = 0; i < a.length; ++i) { annotations.put("L" + a[i].getName().replace('.', '/') + ";", a[i]); } if (reporter instanceof TypeReporter) { typeReporter = (TypeReporter)reporter; } if (reporter instanceof FieldReporter) { fieldReporter = (FieldReporter)reporter; } if (reporter instanceof MethodReporter) { methodReporter = (MethodReporter)reporter; } if (typeReporter == null && fieldReporter == null && methodReporter == null) { throw new AssertionError("No reporter defined"); } } AnnotationDetector(final Reporter reporter); void detect(); void detect(final String... packageNames); void detect(final File... filesOrDirectories);  }
@Test public void testAnnotationDetector() { AnnotationReporter reporter = new AnnotationReporter(); AnnotationDetector detector = new AnnotationDetector(reporter); try { detector.detect("org.aesh.command.foo"); assertFalse(reporter.foundManCommand); detector.detect("org.aesh.command.man"); assertTrue(reporter.foundManCommand); } catch (IOException e) { e.printStackTrace(); } }