Search in sources :

Example 1 with ElementChecker

use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.

the class Rgaa32016Rule060501 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(new ImmutablePair(TestSolution.FAILED, EMPTY_LINK_MSG), new ImmutablePair(TestSolution.PASSED, ""), HREF_ATTR);
    ec.check(sspHandler, emptyLinksHandler, testSolutionHandler);
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Example 2 with ElementChecker

use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.

the class Rgaa32016Rule080901 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(new ImmutablePair(TestSolution.FAILED, LINK_WITHOUT_TARGET_MSG), new ImmutablePair(TestSolution.PASSED, ""));
    linkWithoutTargetChecker.check(sspHandler, linkWithoutTarget, testSolutionHandler);
    ElementChecker fieldsetNotWithinFormChecker = new ElementPresenceChecker(new ImmutablePair(TestSolution.NEED_MORE_INFO, FIELDSET_NOT_WITHIN_FORM_MSG), new ImmutablePair(TestSolution.PASSED, ""));
    fieldsetNotWithinFormChecker.check(sspHandler, fieldsetNotWithinForm, testSolutionHandler);
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Example 3 with ElementChecker

use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.

the class Rgaa32016Rule100102 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler 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 : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) ElementWithAttributePresenceChecker(org.asqatasun.rules.elementchecker.element.ElementWithAttributePresenceChecker) ElementHandler(org.asqatasun.ruleimplementation.ElementHandler) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with ElementChecker

use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.

the class AbstractDecorativeImageEmptyAlternativePageRuleImplementation method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    ElementChecker elementWithEmptyAlternativeWithMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(PASSED, ""), new ImmutablePair<>(NOT_APPLICABLE, ""), eeList);
    elementWithEmptyAlternativeWithMarkerChecker.check(sspHandler, elementWithEmptyAlternativeWithMarkerHandler, testSolutionHandler);
    ElementChecker elementWithNotEmptyAlternativeWithMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(FAILED, DECORATIVE_ELEMENT_WITH_NOT_EMPTY_TEXTUAL_ALTERNATIVE_MSG), new ImmutablePair<>(NOT_APPLICABLE, ""), eeList);
    elementWithNotEmptyAlternativeWithMarkerChecker.check(sspHandler, elementWithNotEmptyAlternativeWithMarkerHandler, testSolutionHandler);
    ElementChecker elementWithNotEmptyAlternativeWithoutMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(NEED_MORE_INFO, CHECK_NATURE_OF_IMAGE_WITH_TEXTUAL_ALTERNATIVE_MSG), new ImmutablePair<>(NOT_APPLICABLE, ""), eeList);
    elementWithNotEmptyAlternativeWithoutMarkerChecker.check(sspHandler, elementWithNotEmptyAlternativeWithoutMarkerHandler, testSolutionHandler);
    ElementChecker elementWithEmptyAlternativeWithoutMarkerChecker = new ElementPresenceChecker(new ImmutablePair<>(NEED_MORE_INFO, CHECK_NATURE_OF_IMAGE_WITHOUT_TEXTUAL_ALTERNATIVE_MSG), new ImmutablePair<>(NOT_APPLICABLE, ""), eeList);
    elementWithEmptyAlternativeWithoutMarkerChecker.check(sspHandler, elementWithEmptyAlternativeWithoutMarkerHandler, testSolutionHandler);
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Example 5 with ElementChecker

use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.

the class Aw22Rule08091 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)

Aggregations

ElementChecker (org.asqatasun.rules.elementchecker.ElementChecker)39 ElementPresenceChecker (org.asqatasun.rules.elementchecker.element.ElementPresenceChecker)30 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)21 HashMap (java.util.HashMap)8 Map (java.util.Map)8 ElementHandler (org.asqatasun.ruleimplementation.ElementHandler)8 ElementWithAttributePresenceChecker (org.asqatasun.rules.elementchecker.element.ElementWithAttributePresenceChecker)5 TextEmptinessChecker (org.asqatasun.rules.elementchecker.text.TextEmptinessChecker)5 TextAttributeOfElementBuilder (org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder)5 Element (org.jsoup.nodes.Element)5 ElementHandlerImpl (org.asqatasun.ruleimplementation.ElementHandlerImpl)4 AttributePresenceChecker (org.asqatasun.rules.elementchecker.attribute.AttributePresenceChecker)4 IdUnicityChecker (org.asqatasun.rules.elementchecker.attribute.IdUnicityChecker)3 TextLengthChecker (org.asqatasun.rules.elementchecker.text.TextLengthChecker)2 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 SimpleTextElementBuilder (org.asqatasun.rules.textbuilder.SimpleTextElementBuilder)1