Search in sources :

Example 1 with TextEmptinessChecker

use of org.asqatasun.rules.elementchecker.text.TextEmptinessChecker in project Asqatasun by Asqatasun.

the class Rgaa30Rule010202 method getLocalRegularElementChecker.

/**
     * 
     * @return the checker user for not marked elements
     */
private ElementChecker getLocalRegularElementChecker() {
    CompositeChecker compositeChecker = new CompositeChecker(new TextEmptinessChecker(new TextAttributeOfElementBuilder(ALT_ATTR), new ImmutablePair(PASSED, ""), new ImmutablePair(FAILED, "")), new AttributePresenceChecker(TITLE_ATTR, new ImmutablePair(FAILED, ""), new ImmutablePair(PASSED, "")));
    compositeChecker.setIsOrCombinaison(false);
    compositeChecker.addCheckMessageFromSolution(PASSED, Collections.singletonMap(NEED_MORE_INFO, RemarkMessageStore.CHECK_NATURE_OF_IMAGE_WITH_EMPTY_ALT_MSG));
    compositeChecker.addCheckMessageFromSolution(FAILED, Collections.singletonMap(NEED_MORE_INFO, RemarkMessageStore.CHECK_NATURE_OF_IMAGE_WITH_NOT_EMPTY_ALT_MSG));
    return compositeChecker;
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder) TextEmptinessChecker(org.asqatasun.rules.elementchecker.text.TextEmptinessChecker) CompositeChecker(org.asqatasun.rules.elementchecker.CompositeChecker) AttributePresenceChecker(org.asqatasun.rules.elementchecker.attribute.AttributePresenceChecker)

Example 2 with TextEmptinessChecker

use of org.asqatasun.rules.elementchecker.text.TextEmptinessChecker in project Asqatasun by Asqatasun.

the class LinkTitlePertinenceChecker method addCheckers.

/**
     * 
     */
private void addCheckers() {
    ElementChecker ec = new TextEmptinessChecker(titleAttrElementBuilder, RemarkMessageStore.EMPTY_LINK_TITLE_MSG, null, getEeAttributeNames());
    ec.setTextElementBuilder(linkTextElementBuilder);
    addChecker(ec);
    ec = new TextOnlyContainsNonAlphanumericalCharactersChecker(titleAttrElementBuilder, getFailureSolution(), RemarkMessageStore.NOT_PERTINENT_LINK_TITLE_MSG, getEeAttributeNames());
    ec.setTextElementBuilder(linkTextElementBuilder);
    addChecker(ec);
    ec = new TextBelongsToBlackListChecker(titleAttrElementBuilder, LINK_TEXT_BL_NOM_NAME, getFailureSolution(), RemarkMessageStore.NOT_PERTINENT_LINK_TITLE_MSG, getEeAttributeNames());
    ec.setTextElementBuilder(linkTextElementBuilder);
    addChecker(ec);
    TestSolution strictCheckerSolution = TestSolution.FAILED;
    String strictCheckerMsg = RemarkMessageStore.NOT_PERTINENT_LINK_TITLE_MSG;
    if (isEqualContentAuthorized) {
        strictCheckerSolution = TestSolution.NEED_MORE_INFO;
        strictCheckerMsg = RemarkMessageStore.SUSPECTED_PERTINENT_LINK_TITLE_MSG;
    }
    ElementChecker strictChecker = new TextNotIdenticalToAttributeChecker(getTextElementBuilder(), titleAttrElementBuilder, new ImmutablePair(strictCheckerSolution, strictCheckerMsg), new ImmutablePair(TestSolution.PASSED, ""), getEeAttributeNames());
    ((TextNotIdenticalToAttributeChecker) strictChecker).setStrictEquality(true);
    strictChecker.setTextElementBuilder(linkTextElementBuilder);
    addChecker(strictChecker);
    ElementChecker containChecker = new TextNotIdenticalToAttributeChecker(getTextElementBuilder(), titleAttrElementBuilder, new ImmutablePair(TestSolution.NEED_MORE_INFO, RemarkMessageStore.SUSPECTED_PERTINENT_LINK_TITLE_MSG), new ImmutablePair(TestSolution.NEED_MORE_INFO, RemarkMessageStore.SUSPECTED_NOT_PERTINENT_LINK_TITLE_MSG), getEeAttributeNames());
    containChecker.setTextElementBuilder(linkTextElementBuilder);
    addChecker(containChecker);
}
Also used : TextBelongsToBlackListChecker(org.asqatasun.rules.elementchecker.text.TextBelongsToBlackListChecker) TextNotIdenticalToAttributeChecker(org.asqatasun.rules.elementchecker.text.TextNotIdenticalToAttributeChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TextEmptinessChecker(org.asqatasun.rules.elementchecker.text.TextEmptinessChecker) TestSolution(org.asqatasun.entity.audit.TestSolution) TextOnlyContainsNonAlphanumericalCharactersChecker(org.asqatasun.rules.elementchecker.text.TextOnlyContainsNonAlphanumericalCharactersChecker) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Example 3 with TextEmptinessChecker

use of org.asqatasun.rules.elementchecker.text.TextEmptinessChecker in project Asqatasun by Asqatasun.

the class Aw22Rule11012 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    // If the page has no input form element, the test is not applicable
    if (labels.isEmpty()) {
        testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
        return;
    }
    /* The attribute Presence Checker */
    ElementChecker attributePresenceChecker = new AttributePresenceChecker(ID_ATTR, TestSolution.PASSED, TestSolution.FAILED, null, ID_MISSING_MSG);
    attributePresenceChecker.check(sspHandler, labels, testSolutionHandler);
    /* The attribute Emptiness Checker. Keep default value i.e failed 
         when attribute is empty
         */
    ElementChecker attributeEmptinessChecker = new TextEmptinessChecker(new TextAttributeOfElementBuilder(ID_ATTR), ID_MISSING_MSG, null);
    attributeEmptinessChecker.check(sspHandler, labels, testSolutionHandler);
    /* The id unicityChecker */
    ElementChecker idUnicityChecker = new IdUnicityChecker(ID_NOT_UNIQUE_MSG);
    idUnicityChecker.check(sspHandler, labels, testSolutionHandler);
}
Also used : TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder) IdUnicityChecker(org.asqatasun.rules.elementchecker.attribute.IdUnicityChecker) TextEmptinessChecker(org.asqatasun.rules.elementchecker.text.TextEmptinessChecker) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker) AttributePresenceChecker(org.asqatasun.rules.elementchecker.attribute.AttributePresenceChecker)

Example 4 with TextEmptinessChecker

use of org.asqatasun.rules.elementchecker.text.TextEmptinessChecker in project Asqatasun by Asqatasun.

the class Rgaa30Rule010201 method getLocalRegularElementChecker.

/**
     * 
     * @return the checker user for not marked elements
     */
private ElementChecker getLocalRegularElementChecker() {
    CompositeChecker compositeChecker = new CompositeChecker(ALT_ATTR, TITLE_ATTR, SRC_ATTR);
    compositeChecker.addChecker(new TextEmptinessChecker(new TextAttributeOfElementBuilder(ALT_ATTR), new ImmutablePair(PASSED, ""), new ImmutablePair(FAILED, "")));
    compositeChecker.addChecker(new AttributePresenceChecker(TITLE_ATTR, new ImmutablePair(FAILED, ""), new ImmutablePair(PASSED, "")));
    compositeChecker.setIsOrCombinaison(false);
    compositeChecker.addCheckMessageFromSolution(PASSED, Collections.singletonMap(NEED_MORE_INFO, RemarkMessageStore.CHECK_NATURE_OF_IMAGE_WITH_EMPTY_ALT_MSG));
    compositeChecker.addCheckMessageFromSolution(FAILED, Collections.singletonMap(NEED_MORE_INFO, RemarkMessageStore.CHECK_NATURE_OF_IMAGE_WITH_NOT_EMPTY_ALT_MSG));
    return compositeChecker;
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder) TextEmptinessChecker(org.asqatasun.rules.elementchecker.text.TextEmptinessChecker) CompositeChecker(org.asqatasun.rules.elementchecker.CompositeChecker) AttributePresenceChecker(org.asqatasun.rules.elementchecker.attribute.AttributePresenceChecker)

Example 5 with TextEmptinessChecker

use of org.asqatasun.rules.elementchecker.text.TextEmptinessChecker in project Asqatasun by Asqatasun.

the class Rgaa30Rule010202 method getMarkerElementChecker.

/**
     * 
     * @return the checker user for marked elements
     */
private ElementChecker getMarkerElementChecker() {
    CompositeChecker ec = new CompositeChecker(new TextEmptinessChecker(new TextAttributeOfElementBuilder(ALT_ATTR), new ImmutablePair(PASSED, ""), new ImmutablePair(FAILED, DECORATIVE_ELEMENT_WITH_NOT_EMPTY_ALT_MSG), ALT_ATTR, TITLE_ATTR), new AttributePresenceChecker(TITLE_ATTR, new ImmutablePair(FAILED, DECORATIVE_ELEMENT_WITH_TITLE_ATTR_MSG), new ImmutablePair(PASSED, ""), ALT_ATTR, TITLE_ATTR));
    ec.setIsOrCombinaison(false);
    return ec;
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder) TextEmptinessChecker(org.asqatasun.rules.elementchecker.text.TextEmptinessChecker) CompositeChecker(org.asqatasun.rules.elementchecker.CompositeChecker) AttributePresenceChecker(org.asqatasun.rules.elementchecker.attribute.AttributePresenceChecker)

Aggregations

TextEmptinessChecker (org.asqatasun.rules.elementchecker.text.TextEmptinessChecker)9 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)8 TextAttributeOfElementBuilder (org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder)8 AttributePresenceChecker (org.asqatasun.rules.elementchecker.attribute.AttributePresenceChecker)7 ElementChecker (org.asqatasun.rules.elementchecker.ElementChecker)5 CompositeChecker (org.asqatasun.rules.elementchecker.CompositeChecker)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ElementHandler (org.asqatasun.ruleimplementation.ElementHandler)3 ElementHandlerImpl (org.asqatasun.ruleimplementation.ElementHandlerImpl)3 IdUnicityChecker (org.asqatasun.rules.elementchecker.attribute.IdUnicityChecker)3 ElementPresenceChecker (org.asqatasun.rules.elementchecker.element.ElementPresenceChecker)3 Element (org.jsoup.nodes.Element)3 TestSolution (org.asqatasun.entity.audit.TestSolution)1 TextBelongsToBlackListChecker (org.asqatasun.rules.elementchecker.text.TextBelongsToBlackListChecker)1 TextNotIdenticalToAttributeChecker (org.asqatasun.rules.elementchecker.text.TextNotIdenticalToAttributeChecker)1 TextOnlyContainsNonAlphanumericalCharactersChecker (org.asqatasun.rules.elementchecker.text.TextOnlyContainsNonAlphanumericalCharactersChecker)1