DetectorRegistry { boolean addDetector(Class<?> clazz) { List<WarningDefinition> wds = getDefinitions(clazz); if (wds.isEmpty()) return false; try { wds.forEach(wd -> ctx.incStat("WarningTypes.Total")); Map<String, WarningType> wts = createWarningMap(wds.stream().map(WarningType::new)); Detector detector = createDetector(clazz, wts); if (detector == null) return false; detectors.add(detector); } catch (Exception e) { ctx.addError(new ErrorMessage(clazz.getName(), null, null, null, -1, e)); } return true; } DetectorRegistry(Context ctx); boolean hasDatabases(); void populateDatabases(TypeDefinition type); void analyzeClass(TypeDefinition type); void reportWarningTypes(PrintStream out); void reportDatabases(PrintStream out); void reportTitles(PrintStream out); WarningType getWarningType(String typeName); Stream<WarningType> warningTypes();  }
@Test public void addDetector() { final long WARNINGS = getWarnings(); assertTrue(detectorRegistry.addDetector(TestDetector.class)); assertEquals(WARNINGS + 2, getWarnings()); }
@Test public void addFakeDetector() { final long WARNINGS = getWarnings(); assertFalse(detectorRegistry.addDetector(DetectorRegistryTest.class)); assertEquals(WARNINGS, getWarnings()); }