@Test public void testScopeNodeTypes() throws Exception { TestUtil.testBlock(() -> { ProgressCheck check = new JcrProperties().newInstance(obj() .key("properties", arr() .and(key("name", "double_nan").key("requireType", "String")) .and(key("name", "double_neg_inf").key("requireType", "String")) ) .get()); CheckReport report = scanWithCheck(check, "double_properties.zip"); Assert.assertEquals("two violations: " + report.getViolations(), 2, report.getViolations().size()); assertTrue("all violations have packageIds", report.getViolations().stream() .allMatch(viol -> !viol.getPackages().isEmpty())); }); TestUtil.testBlock(() -> { ProgressCheck check = new JcrProperties().newInstance(obj() .key("scopeNodeTypes", arr("nt:unstructured")) .key("properties", arr() .and(key("name", "double_nan").key("requireType", "String")) .and(key("name", "double_neg_inf").key("requireType", "String")) ) .get()); CheckReport report = scanWithCheck(check, "double_properties.zip"); Assert.assertEquals("two violations: " + report.getViolations(), 2, report.getViolations().size()); assertTrue("all violations have packageIds", report.getViolations().stream() .allMatch(viol -> !viol.getPackages().isEmpty())); }); TestUtil.testBlock(() -> { ProgressCheck check = new JcrProperties().newInstance(obj() .key("scopeNodeTypes", arr("sling:Folder")) .key("properties", arr() .and(key("name", "double_nan").key("requireType", "String")) .and(key("name", "double_neg_inf").key("requireType", "String")) ) .get()); CheckReport report = scanWithCheck(check, "double_properties.zip"); Assert.assertEquals("no violations: " + report.getViolations(), 0, report.getViolations().size()); assertTrue("all violations have packageIds", report.getViolations().stream() .allMatch(viol -> !viol.getPackages().isEmpty())); }); }
@Override public ProgressCheck newInstance(final JsonObject config) { List<Rule> pathScope = Rules.fromJsonArray(arrayOrEmpty(config, keys().scopePaths())); List<String> denyNodeTypes = mapArrayOfStrings(arrayOrEmpty(config, keys().denyNodeTypes())); List<String> nodeTypeScope = mapArrayOfStrings(arrayOrEmpty(config, keys().scopeNodeTypes())); final ResourceBundleHolder resourceBundleHolder = new ResourceBundleHolder(); List<JcrPropertyConstraints> propertyChecks = JcrPropertyConstraints .fromJsonArray(resourceBundleHolder::getResourceBundle, arrayOrEmpty(config, keys().properties())); return new Check(pathScope, denyNodeTypes, nodeTypeScope, propertyChecks, resourceBundleHolder); }
JcrProperties implements ProgressCheckFactory { @Override public ProgressCheck newInstance(final JsonObject config) { List<Rule> pathScope = Rules.fromJsonArray(arrayOrEmpty(config, keys().scopePaths())); List<String> denyNodeTypes = mapArrayOfStrings(arrayOrEmpty(config, keys().denyNodeTypes())); List<String> nodeTypeScope = mapArrayOfStrings(arrayOrEmpty(config, keys().scopeNodeTypes())); final ResourceBundleHolder resourceBundleHolder = new ResourceBundleHolder(); List<JcrPropertyConstraints> propertyChecks = JcrPropertyConstraints .fromJsonArray(resourceBundleHolder::getResourceBundle, arrayOrEmpty(config, keys().properties())); return new Check(pathScope, denyNodeTypes, nodeTypeScope, propertyChecks, resourceBundleHolder); } }
JcrProperties implements ProgressCheckFactory { @Override public ProgressCheck newInstance(final JsonObject config) { List<Rule> pathScope = Rules.fromJsonArray(arrayOrEmpty(config, keys().scopePaths())); List<String> denyNodeTypes = mapArrayOfStrings(arrayOrEmpty(config, keys().denyNodeTypes())); List<String> nodeTypeScope = mapArrayOfStrings(arrayOrEmpty(config, keys().scopeNodeTypes())); final ResourceBundleHolder resourceBundleHolder = new ResourceBundleHolder(); List<JcrPropertyConstraints> propertyChecks = JcrPropertyConstraints .fromJsonArray(resourceBundleHolder::getResourceBundle, arrayOrEmpty(config, keys().properties())); return new Check(pathScope, denyNodeTypes, nodeTypeScope, propertyChecks, resourceBundleHolder); }  }
JcrProperties implements ProgressCheckFactory { @Override public ProgressCheck newInstance(final JsonObject config) { List<Rule> pathScope = Rules.fromJsonArray(arrayOrEmpty(config, keys().scopePaths())); List<String> denyNodeTypes = mapArrayOfStrings(arrayOrEmpty(config, keys().denyNodeTypes())); List<String> nodeTypeScope = mapArrayOfStrings(arrayOrEmpty(config, keys().scopeNodeTypes())); final ResourceBundleHolder resourceBundleHolder = new ResourceBundleHolder(); List<JcrPropertyConstraints> propertyChecks = JcrPropertyConstraints .fromJsonArray(resourceBundleHolder::getResourceBundle, arrayOrEmpty(config, keys().properties())); return new Check(pathScope, denyNodeTypes, nodeTypeScope, propertyChecks, resourceBundleHolder); }  @NotNull static JsonKeys keys(); @Override ProgressCheck newInstance(final JsonObject config); }
JcrProperties implements ProgressCheckFactory { @Override public ProgressCheck newInstance(final JsonObject config) { List<Rule> pathScope = Rules.fromJsonArray(arrayOrEmpty(config, keys().scopePaths())); List<String> denyNodeTypes = mapArrayOfStrings(arrayOrEmpty(config, keys().denyNodeTypes())); List<String> nodeTypeScope = mapArrayOfStrings(arrayOrEmpty(config, keys().scopeNodeTypes())); final ResourceBundleHolder resourceBundleHolder = new ResourceBundleHolder(); List<JcrPropertyConstraints> propertyChecks = JcrPropertyConstraints .fromJsonArray(resourceBundleHolder::getResourceBundle, arrayOrEmpty(config, keys().properties())); return new Check(pathScope, denyNodeTypes, nodeTypeScope, propertyChecks, resourceBundleHolder); }  @NotNull static JsonKeys keys(); @Override ProgressCheck newInstance(final JsonObject config); @Deprecated
    static final String CONFIG_SCOPE_PATHS; @Deprecated
    static final String CONFIG_DENY_NODE_TYPES; @Deprecated
    static final String CONFIG_SCOPE_NODE_TYPES; @Deprecated
    static final String CONFIG_PROPERTIES; }