use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.
the class LinkTitlePertinenceChecker method addCheckers.
/**
*/
private void addCheckers() {
ElementChecker ec = new TextEmptinessChecker(titleAttrElementBuilder, EMPTY_LINK_TITLE_MSG, null, getEeAttributeNames());
ec.setTextElementBuilder(linkTextElementBuilder);
addChecker(ec);
ec = new TextOnlyContainsNonAlphanumericalCharactersChecker(titleAttrElementBuilder, getFailureSolution(), NOT_PERTINENT_LINK_TITLE_MSG, getEeAttributeNames());
ec.setTextElementBuilder(linkTextElementBuilder);
addChecker(ec);
ec = new TextBelongsToBlackListChecker(titleAttrElementBuilder, LINK_TEXT_BL_NOM_NAME, getFailureSolution(), NOT_PERTINENT_LINK_TITLE_MSG, getEeAttributeNames());
// this set is used extract linkText
ec.setTextElementBuilder(linkTextElementBuilder);
addChecker(ec);
TestSolution strictCheckerSolution = TestSolution.FAILED;
String strictCheckerMsg = NOT_PERTINENT_LINK_TITLE_MSG;
if (isEqualContentAuthorized) {
strictCheckerSolution = NEED_MORE_INFO;
strictCheckerMsg = SUSPECTED_PERTINENT_LINK_TITLE_MSG;
}
TextNotIdenticalToAttributeChecker strictChecker = new TextNotIdenticalToAttributeChecker(getTextElementBuilder(), titleAttrElementBuilder, new ImmutablePair<>(strictCheckerSolution, strictCheckerMsg), new ImmutablePair<>(PASSED, ""), getEeAttributeNames());
strictChecker.setStrictEquality(true);
strictChecker.setTextElementBuilder(linkTextElementBuilder);
addChecker(strictChecker);
ElementChecker containChecker = new TextNotIdenticalToAttributeChecker(getTextElementBuilder(), titleAttrElementBuilder, new ImmutablePair<>(NEED_MORE_INFO, SUSPECTED_PERTINENT_LINK_TITLE_MSG), new ImmutablePair<>(NEED_MORE_INFO, SUSPECTED_NOT_PERTINENT_LINK_TITLE_MSG), getEeAttributeNames());
containChecker.setTextElementBuilder(linkTextElementBuilder);
addChecker(containChecker);
}
use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.
the class Rgaa30Rule100102 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);
}
}
use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.
the class Rgaa30Rule080901 method check.
@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
if (linkWithoutTarget.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);
}
use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.
the class Rgaa40Rule100102 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);
}
}
use of org.asqatasun.rules.elementchecker.ElementChecker in project Asqatasun by Asqatasun.
the class Rgaa40Rule080901 method check.
@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
if (linkWithoutTarget.isEmpty() && tagWithoutContent.isEmpty() && consecutiveBrElement.isEmpty()) {
sspHandler.getProcessRemarkService().addProcessRemark(TestSolution.NEED_MORE_INFO, RuleCheckHelper.specifyMessageToRule(NO_PATTERN_DETECTED_MSG, this.getTest().getCode()));
testSolutionHandler.addTestSolution(TestSolution.NEED_MORE_INFO);
return;
}
// Links without target
ElementChecker linkWithoutTargetChecker = new ElementPresenceChecker(new ImmutablePair(TestSolution.FAILED, LINK_WITHOUT_TARGET_MSG), new ImmutablePair(TestSolution.PASSED, ""));
linkWithoutTargetChecker.check(sspHandler, linkWithoutTarget, testSolutionHandler);
// Tags (p, li, ...) without content
ElementChecker tagWithoutContentChecker = new ElementPresenceChecker(new ImmutablePair(TestSolution.FAILED, TAGS_WITHOUT_CONTENT_USED_FOR_LAYOUT_PURPOSE_MSG), new ImmutablePair(TestSolution.PASSED, ""));
tagWithoutContentChecker.check(sspHandler, tagWithoutContent, testSolutionHandler);
// Consecutive <br> tags without text in between
ElementChecker consecutiveBrElementChecker = new ElementPresenceChecker(new ImmutablePair(TestSolution.FAILED, CONSECUTIVE_TAGS_USED_FOR_LAYOUT_PURPOSE_MSG), new ImmutablePair(TestSolution.PASSED, ""));
consecutiveBrElementChecker.check(sspHandler, consecutiveBrElement, testSolutionHandler);
}
Aggregations