public void check(Metadata metadata) throws AccessPermissionException {
        if (!needToCheck) {
            return;
        }
        if ("false".equals(metadata.get(AccessPermissions.EXTRACT_CONTENT))) {
            if (allowExtractionForAccessibility) {
                if ("true".equals(metadata.get(AccessPermissions.EXTRACT_FOR_ACCESSIBILITY))) {
                    return;
                }
                throw new AccessPermissionException(
                        "Content extraction for accessibility is not allowed.");
            }
            throw new AccessPermissionException("Content extraction is not allowed.");
        }
    }
@Test
    public void testNoExtraction() {

        Metadata m = null;
        //allow nothing
        AccessChecker checker = new AccessChecker(false);
        boolean ex = false;
        try {
            m = getMetadata(false, false);
            checker.check(m);
        } catch (AccessPermissionException e) {
            ex = true;
        }
        assertTrue(ex, "correct exception with no extraction, no extract for accessibility");
        ex = false;
        try {
            //document allows extraction for accessibility
            m = getMetadata(false, true);
            checker.check(m);
        } catch (AccessPermissionException e) {
            //but application is not an accessibility application
            ex = true;
        }
        assertTrue(ex, "correct exception with no extraction, no extract for accessibility");
    }