use of org.asqatasun.ruleimplementation.ElementHandlerImpl in project Asqatasun by Asqatasun.
the class AbstractDownloadableLinkRuleImplementation method check.
@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
// invoke getElementChecker instead of super.check() to use local
// collection of elements
setServicesToChecker(getElementChecker());
getElementChecker().check(sspHandler, linkWithSimpleExtension, testSolutionHandler);
TestSolution checkerSolution = testSolutionHandler.getTestSolution();
if (checkerSolution.equals(TestSolution.NOT_APPLICABLE) && !getElements().isEmpty()) {
testSolutionHandler.addTestSolution(TestSolution.NEED_MORE_INFO);
sspHandler.getProcessRemarkService().addProcessRemark(TestSolution.NEED_MORE_INFO, RuleCheckHelper.specifyMessageToRule(CHECK_MANUALLY_LINK_WITHOUT_EXT_MSG, this.getTest().getCode()));
return;
}
if (checkerSolution.equals(TestSolution.PASSED)) {
// the test result is NMI
if (getElements().get().size() > linkWithSimpleExtension.get().size()) {
testSolutionHandler.addTestSolution(TestSolution.NEED_MORE_INFO);
sspHandler.getProcessRemarkService().addProcessRemark(TestSolution.NEED_MORE_INFO, RuleCheckHelper.specifyMessageToRule(CHECK_MANUALLY_LINK_WITHOUT_EXT_MSG, this.getTest().getCode()));
return;
}
// we search whether the page contains form, if yes, the result
// is nmi, if not, the test is not applicable
ElementHandler<Element> formHandler = new ElementHandlerImpl();
new SimpleElementSelector(FORM_ELEMENT).selectElements(sspHandler, formHandler);
if (formHandler.isEmpty()) {
testSolutionHandler.cleanTestSolutions();
testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
} else {
testSolutionHandler.addTestSolution(TestSolution.NEED_MORE_INFO);
sspHandler.getProcessRemarkService().addProcessRemark(TestSolution.NEED_MORE_INFO, RuleCheckHelper.specifyMessageToRule(CHECK_DOWNLOADABLE_DOCUMENT_FROM_FORM_MSG, this.getTest().getCode()));
}
}
}
Aggregations