Search in sources :

Example 16 with ElementPresenceChecker

use of org.asqatasun.rules.elementchecker.element.ElementPresenceChecker in project Asqatasun by Asqatasun.

the class Aw22Rule06061 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    if (linksHandler.isEmpty()) {
        testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
        return;
    }
    if (emptyLinksHandler.isEmpty()) {
        testSolutionHandler.addTestSolution(TestSolution.PASSED);
        return;
    }
    ElementChecker ec = new ElementPresenceChecker(TestSolution.FAILED, TestSolution.PASSED, EMPTY_LINK_MSG, null, HREF_ATTR);
    ec.check(sspHandler, emptyLinksHandler, testSolutionHandler);
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Example 17 with ElementPresenceChecker

use of org.asqatasun.rules.elementchecker.element.ElementPresenceChecker in project Asqatasun by Asqatasun.

the class Rgaa22Rule07081 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    // Tags check
    ElementChecker ec = new ElementPresenceChecker(TestSolution.FAILED, TestSolution.PASSED, PRESENTATION_TAG_DETECTED_MSG, null);
    ec.check(sspHandler, deprecatedElementHandler, testSolutionHandler);
    // Attributes checks
    for (Map.Entry<String, ElementHandler> attrElementHandlerMapEntry : attrElementHandlerMap.entrySet()) {
        ElementChecker attrEc = new ElementWithAttributePresenceChecker(new ImmutablePair(TestSolution.FAILED, PRESENTATION_ATTR_DETECTED_MSG), new ImmutablePair(TestSolution.PASSED, ""), attrElementHandlerMapEntry.getKey());
        attrEc.check(sspHandler, attrElementHandlerMapEntry.getValue(), testSolutionHandler);
    }
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ElementWithAttributePresenceChecker(org.asqatasun.rules.elementchecker.element.ElementWithAttributePresenceChecker) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker) ElementHandler(org.asqatasun.ruleimplementation.ElementHandler) HashMap(java.util.HashMap) Map(java.util.Map)

Example 18 with ElementPresenceChecker

use of org.asqatasun.rules.elementchecker.element.ElementPresenceChecker in project Asqatasun by Asqatasun.

the class Rgaa22Rule07091 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    if (linkWithoutTarget.isEmpty() && fieldsetNotWithinForm.isEmpty()) {
        sspHandler.getProcessRemarkService().addProcessRemark(TestSolution.NEED_MORE_INFO, RuleCheckHelper.specifyMessageToRule(NO_PATTERN_DETECTED_MSG, this.getTest().getCode()));
        testSolutionHandler.addTestSolution(TestSolution.NEED_MORE_INFO);
        return;
    }
    ElementChecker linkWithoutTargetChecker = new ElementPresenceChecker(TestSolution.FAILED, TestSolution.PASSED, LINK_WITHOUT_TARGET_MSG, null);
    linkWithoutTargetChecker.check(sspHandler, linkWithoutTarget, testSolutionHandler);
    ElementChecker fieldsetNotWithinFormChecker = new ElementPresenceChecker(TestSolution.FAILED, TestSolution.PASSED, FIELDSET_NOT_WITHIN_FORM_MSG, null);
    fieldsetNotWithinFormChecker.check(sspHandler, fieldsetNotWithinForm, testSolutionHandler);
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Example 19 with ElementPresenceChecker

use of org.asqatasun.rules.elementchecker.element.ElementPresenceChecker in project Asqatasun by Asqatasun.

the class Rgaa22Rule06021 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    if (imageLinks.isEmpty() && formWithTargetHandler.isEmpty()) {
        testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
        return;
    }
    ElementPresenceChecker epc = new ElementPresenceChecker(TestSolution.NEED_MORE_INFO, TestSolution.NOT_APPLICABLE, CHECK_USER_IS_WARNED_WHEN_NEW_WINDOW_OPEN_MSG, null, TEXT_ELEMENT2, TITLE_ATTR);
    epc.setTextElementBuilder(new LinkTextElementBuilder());
    epc.check(sspHandler, imageLinks, testSolutionHandler);
    epc = new ElementPresenceChecker(TestSolution.NEED_MORE_INFO, TestSolution.NOT_APPLICABLE, CHECK_USER_IS_WARNED_WHEN_NEW_WINDOW_OPEN_MSG, null);
    epc.check(sspHandler, formWithTargetHandler, testSolutionHandler);
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) LinkTextElementBuilder(org.asqatasun.rules.textbuilder.LinkTextElementBuilder)

Example 20 with ElementPresenceChecker

use of org.asqatasun.rules.elementchecker.element.ElementPresenceChecker in project Asqatasun by Asqatasun.

the class Rgaa22Rule06031 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    if (compositeLinks.isEmpty()) {
        testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
        return;
    }
    ElementPresenceChecker epc = new ElementPresenceChecker(TestSolution.NEED_MORE_INFO, TestSolution.NOT_APPLICABLE, CHECK_USER_IS_WARNED_WHEN_NEW_WINDOW_OPEN_MSG, null, TEXT_ELEMENT2, TITLE_ATTR);
    epc.setTextElementBuilder(new LinkTextElementBuilder());
    epc.check(sspHandler, compositeLinks, testSolutionHandler);
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) LinkTextElementBuilder(org.asqatasun.rules.textbuilder.LinkTextElementBuilder)

Aggregations

ElementPresenceChecker (org.asqatasun.rules.elementchecker.element.ElementPresenceChecker)29 ElementChecker (org.asqatasun.rules.elementchecker.ElementChecker)24 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)15 LinkTextElementBuilder (org.asqatasun.rules.textbuilder.LinkTextElementBuilder)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 ElementHandler (org.asqatasun.ruleimplementation.ElementHandler)4 ElementHandlerImpl (org.asqatasun.ruleimplementation.ElementHandlerImpl)4 Element (org.jsoup.nodes.Element)4 TextEmptinessChecker (org.asqatasun.rules.elementchecker.text.TextEmptinessChecker)3 TextAttributeOfElementBuilder (org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder)3 AttributePresenceChecker (org.asqatasun.rules.elementchecker.attribute.AttributePresenceChecker)2 IdUnicityChecker (org.asqatasun.rules.elementchecker.attribute.IdUnicityChecker)2 ElementWithAttributePresenceChecker (org.asqatasun.rules.elementchecker.element.ElementWithAttributePresenceChecker)1