Search in sources :

Example 1 with TextNotIdenticalToAttributeChecker

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

the class Rgaa30Rule010301 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 AttributePertinenceChecker(ALT_ATTR, // check emptiness
    true, // compare with src attribute
    new TextAttributeOfElementBuilder(SRC_ATTR), // compare attribute value with nomenclature
    IMAGE_FILE_EXTENSION_NOM, // solution when not pertinent
    FAILED, // not pertinent message
    "", // manual check message
    ""));
    compositeChecker.addChecker(new TextNotIdenticalToAttributeChecker(new TextAttributeOfElementBuilder(ALT_ATTR), new TextAttributeOfElementBuilder(TITLE_ATTR), new ImmutablePair(FAILED, ""), new ImmutablePair(PASSED, "")));
    compositeChecker.setIsOrCombinaison(false);
    compositeChecker.addCheckMessageFromSolution(NEED_MORE_INFO, Collections.singletonMap(NEED_MORE_INFO, RemarkMessageStore.CHECK_NATURE_OF_IMAGE_AND_ALT_PERTINENCE_MSG));
    compositeChecker.addCheckMessageFromSolution(FAILED, Collections.singletonMap(NEED_MORE_INFO, RemarkMessageStore.CHECK_NATURE_OF_IMAGE_WITH_NOT_PERTINENT_ALT_MSG));
    return compositeChecker;
}
Also used : TextNotIdenticalToAttributeChecker(org.asqatasun.rules.elementchecker.text.TextNotIdenticalToAttributeChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder) AttributePertinenceChecker(org.asqatasun.rules.elementchecker.pertinence.AttributePertinenceChecker) CompositeChecker(org.asqatasun.rules.elementchecker.CompositeChecker)

Example 2 with TextNotIdenticalToAttributeChecker

use of org.asqatasun.rules.elementchecker.text.TextNotIdenticalToAttributeChecker 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 TextNotIdenticalToAttributeChecker

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

the class Rgaa30Rule010302 method getMarkerElementChecker.

/**
     * 
     * @return the checker user for marked elements
     */
private ElementChecker getMarkerElementChecker() {
    CompositeChecker ec = new CompositeChecker(// checker for elements identified by marker
    new AttributePertinenceChecker(ALT_ATTR, // check emptiness
    true, // compare with src attribute
    new TextAttributeOfElementBuilder(HREF_ATTR), // compare attribute value with nomenclature
    IMAGE_FILE_EXTENSION_NOM, // not pertinent message
    NOT_PERTINENT_ALT_MSG, // manual check message
    CHECK_ALT_PERTINENCE_OF_INFORMATIVE_IMG_MSG, // evidence elements
    ALT_ATTR, TITLE_ATTR, HREF_ATTR), new TextNotIdenticalToAttributeChecker(new TextAttributeOfElementBuilder(TITLE_ATTR), new TextAttributeOfElementBuilder(ALT_ATTR), new ImmutablePair(PASSED, ""), new ImmutablePair(FAILED, TITLE_NOT_IDENTICAL_TO_ALT_MSG), // evidence elements
    ALT_ATTR, TITLE_ATTR, HREF_ATTR));
    ec.setIsOrCombinaison(false);
    return ec;
}
Also used : TextNotIdenticalToAttributeChecker(org.asqatasun.rules.elementchecker.text.TextNotIdenticalToAttributeChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder) AttributePertinenceChecker(org.asqatasun.rules.elementchecker.pertinence.AttributePertinenceChecker) CompositeChecker(org.asqatasun.rules.elementchecker.CompositeChecker)

Example 4 with TextNotIdenticalToAttributeChecker

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

the class Rgaa30Rule010302 method getLocalRegularElementChecker.

/**
     * 
     * @return the checker user for not marked elements
     */
private ElementChecker getLocalRegularElementChecker() {
    CompositeChecker compositeChecker = new CompositeChecker(ALT_ATTR, TITLE_ATTR, HREF_ATTR);
    compositeChecker.addChecker(new AttributePertinenceChecker(ALT_ATTR, // check emptiness
    true, // compare with src attribute
    new TextAttributeOfElementBuilder(HREF_ATTR), // compare attribute value with nomenclature
    IMAGE_FILE_EXTENSION_NOM, // solution when not pertinent
    FAILED, // not pertinent message
    "", // manual check message
    ""));
    compositeChecker.addChecker(new TextNotIdenticalToAttributeChecker(new TextAttributeOfElementBuilder(ALT_ATTR), new TextAttributeOfElementBuilder(TITLE_ATTR), new ImmutablePair(FAILED, ""), new ImmutablePair(PASSED, "")));
    compositeChecker.setIsOrCombinaison(false);
    compositeChecker.addCheckMessageFromSolution(NEED_MORE_INFO, Collections.singletonMap(NEED_MORE_INFO, RemarkMessageStore.CHECK_NATURE_OF_IMAGE_AND_ALT_PERTINENCE_MSG));
    compositeChecker.addCheckMessageFromSolution(FAILED, Collections.singletonMap(NEED_MORE_INFO, RemarkMessageStore.CHECK_NATURE_OF_IMAGE_WITH_NOT_PERTINENT_ALT_MSG));
    return compositeChecker;
}
Also used : TextNotIdenticalToAttributeChecker(org.asqatasun.rules.elementchecker.text.TextNotIdenticalToAttributeChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder) AttributePertinenceChecker(org.asqatasun.rules.elementchecker.pertinence.AttributePertinenceChecker) CompositeChecker(org.asqatasun.rules.elementchecker.CompositeChecker)

Example 5 with TextNotIdenticalToAttributeChecker

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

the class Rgaa30Rule010301 method getMarkerElementChecker.

/**
     * 
     * @return the checker user for marked elements
     */
private ElementChecker getMarkerElementChecker() {
    CompositeChecker ec = new CompositeChecker(// checker for elements identified by marker
    new AttributePertinenceChecker(ALT_ATTR, // check emptiness
    true, // compare with src attribute
    new TextAttributeOfElementBuilder(SRC_ATTR), // compare attribute value with nomenclature
    IMAGE_FILE_EXTENSION_NOM, // not pertinent message
    NOT_PERTINENT_ALT_MSG, // manual check message
    CHECK_ALT_PERTINENCE_OF_INFORMATIVE_IMG_MSG, // evidence elements
    ALT_ATTR, TITLE_ATTR, SRC_ATTR), new TextNotIdenticalToAttributeChecker(new TextAttributeOfElementBuilder(TITLE_ATTR), new TextAttributeOfElementBuilder(ALT_ATTR), new ImmutablePair(PASSED, ""), new ImmutablePair(FAILED, TITLE_NOT_IDENTICAL_TO_ALT_MSG), // evidence elements
    ALT_ATTR, TITLE_ATTR, SRC_ATTR));
    ec.setIsOrCombinaison(false);
    return ec;
}
Also used : TextNotIdenticalToAttributeChecker(org.asqatasun.rules.elementchecker.text.TextNotIdenticalToAttributeChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder) AttributePertinenceChecker(org.asqatasun.rules.elementchecker.pertinence.AttributePertinenceChecker) CompositeChecker(org.asqatasun.rules.elementchecker.CompositeChecker)

Aggregations

ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)5 TextNotIdenticalToAttributeChecker (org.asqatasun.rules.elementchecker.text.TextNotIdenticalToAttributeChecker)5 CompositeChecker (org.asqatasun.rules.elementchecker.CompositeChecker)4 AttributePertinenceChecker (org.asqatasun.rules.elementchecker.pertinence.AttributePertinenceChecker)4 TextAttributeOfElementBuilder (org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder)4 TestSolution (org.asqatasun.entity.audit.TestSolution)1 ElementChecker (org.asqatasun.rules.elementchecker.ElementChecker)1 TextBelongsToBlackListChecker (org.asqatasun.rules.elementchecker.text.TextBelongsToBlackListChecker)1 TextEmptinessChecker (org.asqatasun.rules.elementchecker.text.TextEmptinessChecker)1 TextOnlyContainsNonAlphanumericalCharactersChecker (org.asqatasun.rules.elementchecker.text.TextOnlyContainsNonAlphanumericalCharactersChecker)1