@Test public void testRootImport() throws Exception { TestUtil.testBlock(() -> { ProgressCheck handler = new FilterSets().newInstance(obj().get()); CheckReport report = scanWithCheck(handler, "testrootimport.zip"); Assert.assertEquals("one violation", 1, report.getViolations().size()); assertTrue("all violations have packageIds", report.getViolations().stream() .allMatch(viol -> !viol.getPackages().isEmpty())); }); TestUtil.testBlock(() -> { ProgressCheck handler = new FilterSets().newInstance(key("allowRootFilter", true).get()); CheckReport report = scanWithCheck(handler, "testrootimport.zip"); Assert.assertEquals("no violations", 0, report.getViolations().size()); assertTrue("all violations have packageIds", report.getViolations().stream() .allMatch(viol -> !viol.getPackages().isEmpty())); }); }
@Override public ProgressCheck newInstance(final JsonObject config) { final Severity importModeSeverity = Severity .valueOf(config.getString(keys().importModeSeverity(), DEFAULT_IMPORT_MODE_SEVERITY.name()) .toUpperCase()); final boolean allowEmptyFilter = hasNonNull(config, keys().allowEmptyFilter()) && config.getBoolean(keys().allowEmptyFilter()); final boolean allowRootFilter = hasNonNull(config, keys().allowRootFilter()) && config.getBoolean(keys().allowRootFilter()); return new Check(importModeSeverity, allowEmptyFilter, allowRootFilter); }
FilterSets implements ProgressCheckFactory { @Override public ProgressCheck newInstance(final JsonObject config) { final Severity importModeSeverity = Severity .valueOf(config.getString(keys().importModeSeverity(), DEFAULT_IMPORT_MODE_SEVERITY.name()) .toUpperCase()); final boolean allowEmptyFilter = hasNonNull(config, keys().allowEmptyFilter()) && config.getBoolean(keys().allowEmptyFilter()); final boolean allowRootFilter = hasNonNull(config, keys().allowRootFilter()) && config.getBoolean(keys().allowRootFilter()); return new Check(importModeSeverity, allowEmptyFilter, allowRootFilter); } }
FilterSets implements ProgressCheckFactory { @Override public ProgressCheck newInstance(final JsonObject config) { final Severity importModeSeverity = Severity .valueOf(config.getString(keys().importModeSeverity(), DEFAULT_IMPORT_MODE_SEVERITY.name()) .toUpperCase()); final boolean allowEmptyFilter = hasNonNull(config, keys().allowEmptyFilter()) && config.getBoolean(keys().allowEmptyFilter()); final boolean allowRootFilter = hasNonNull(config, keys().allowRootFilter()) && config.getBoolean(keys().allowRootFilter()); return new Check(importModeSeverity, allowEmptyFilter, allowRootFilter); }  }
FilterSets implements ProgressCheckFactory { @Override public ProgressCheck newInstance(final JsonObject config) { final Severity importModeSeverity = Severity .valueOf(config.getString(keys().importModeSeverity(), DEFAULT_IMPORT_MODE_SEVERITY.name()) .toUpperCase()); final boolean allowEmptyFilter = hasNonNull(config, keys().allowEmptyFilter()) && config.getBoolean(keys().allowEmptyFilter()); final boolean allowRootFilter = hasNonNull(config, keys().allowRootFilter()) && config.getBoolean(keys().allowRootFilter()); return new Check(importModeSeverity, allowEmptyFilter, allowRootFilter); }  @NotNull static JsonKeys keys(); @Override ProgressCheck newInstance(final JsonObject config); }
FilterSets implements ProgressCheckFactory { @Override public ProgressCheck newInstance(final JsonObject config) { final Severity importModeSeverity = Severity .valueOf(config.getString(keys().importModeSeverity(), DEFAULT_IMPORT_MODE_SEVERITY.name()) .toUpperCase()); final boolean allowEmptyFilter = hasNonNull(config, keys().allowEmptyFilter()) && config.getBoolean(keys().allowEmptyFilter()); final boolean allowRootFilter = hasNonNull(config, keys().allowRootFilter()) && config.getBoolean(keys().allowRootFilter()); return new Check(importModeSeverity, allowEmptyFilter, allowRootFilter); }  @NotNull static JsonKeys keys(); @Override ProgressCheck newInstance(final JsonObject config); @Deprecated
    static final String CONFIG_IMPORT_MODE_SEVERITY; @Deprecated
    static final String CONFIG_ALLOW_EMPTY_FILTER; @Deprecated
    static final String CONFIG_ALLOW_ROOT_FILTER; static final Severity DEFAULT_IMPORT_MODE_SEVERITY; }