@Test
public void testDenyIfPresent() throws Exception {

    TestUtil.testBlock(() -> {
        ProgressCheck check = new JcrProperties().newInstance(obj()
                .key("properties", arr()
                        .and(key("name", "double_nan").key("denyIfPresent", false)))
                .get());
        CheckReport report = scanWithCheck(check, "double_properties.zip");
        logViolations("double_nan, no scope", report);
        Assert.assertEquals("no violations: " + report.getViolations(), 0, 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("properties", arr()
                        .and(key("name", "double_nan").key("denyIfPresent", true)))
                .key("scopePaths", arr()
                        .and(key("pattern", "/tmp/jcr:content").key("type", "allow")))
                .get());
        CheckReport report = scanWithCheck(check, "double_properties.zip");
        Assert.assertEquals("one violation: " + report.getViolations(), 1, 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("properties", arr()
                        .and(key("name", "double_nan").key("denyIfPresent", false)))
                .key("scopePaths", arr()
                        .and(key("pattern", "/tmp/jcr:content").key("type", "allow")))
                .get());
        CheckReport report = scanWithCheck(check, "double_properties.zip");
        logViolations("double_nan, with scope", report);
        Assert.assertEquals("no violations: " + report.getViolations(), 0, report.getViolations().size());
        assertTrue("all violations have packageIds", report.getViolations().stream()
                .allMatch(viol -> !viol.getPackages().isEmpty()));
    });
}