use of org.asqatasun.entity.audit.TestSolution 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()));
}
}
}
use of org.asqatasun.entity.audit.TestSolution in project Asqatasun by Asqatasun.
the class AttributeWithValuePresenceChecker method checkAttributeWithValuePresence.
/**
* This methods checks whether a given attribute is present for a set of
* elements
*
* @param elements
* @param testSolutionHandler
*/
private void checkAttributeWithValuePresence(Elements elements, TestSolutionHandler testSolutionHandler) {
if (elements.isEmpty()) {
testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
return;
}
TestSolution testSolution = TestSolution.PASSED;
for (Element el : elements) {
if (!el.hasAttr(attributeName) || (el.hasAttr(attributeName) && !el.attr(attributeName).equals(attributeValue))) {
testSolution = setTestSolution(testSolution, getFailureSolution());
createSourceCodeRemark(getFailureSolution(), el, getFailureMsgCode());
} else if (StringUtils.isNotBlank(getSuccessMsgCode())) {
testSolution = setTestSolution(testSolution, getSuccessSolution());
createSourceCodeRemark(getSuccessSolution(), el, getSuccessMsgCode());
}
}
testSolutionHandler.addTestSolution(testSolution);
}
use of org.asqatasun.entity.audit.TestSolution in project Asqatasun by Asqatasun.
the class IdUnicityChecker method checkIdUnicity.
/**
* This methods checks whether a given id is unique for a set of
* elements
*
* @param sspHandler
* @param elements
* @param testSolutionHandler
*/
private void checkIdUnicity(SSPHandler sspHandler, Elements elements, TestSolutionHandler testSolutionHandler) {
if (elements.isEmpty() || !elements.hasAttr(ID_ATTR)) {
testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
return;
}
TestSolution testSolution = getSuccessSolution();
for (Element el : elements) {
if (el.hasAttr(ID_ATTR) && StringUtils.isNotBlank(el.id()) && getIdPresenceCounter(sspHandler, el.id()) > 1) {
testSolution = getFailureSolution();
addSourceCodeRemark(getFailureSolution(), el, getFailureMsgCode());
}
}
testSolutionHandler.addTestSolution(testSolution);
}
use of org.asqatasun.entity.audit.TestSolution in project Asqatasun by Asqatasun.
the class TextEmptinessChecker method checkEmptiness.
/**
* This methods checks whether a given attribute is empty for a set of
* elements
*
* @param elements
* @param testSolutionHandler
*/
private void checkEmptiness(Elements elements, TestSolutionHandler testSolutionHandler) {
if (elements.isEmpty()) {
testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
return;
}
TestSolution testSolution = TestSolution.NOT_APPLICABLE;
String textElement;
for (Element el : elements) {
textElement = testableTextBuilder.buildTextFromElement(el);
if (textElement == null) {
testSolution = setTestSolution(testSolution, TestSolution.NOT_APPLICABLE);
} else if (isElementEmpty(textElement)) {
testSolution = setTestSolution(testSolution, getFailureSolution());
addSourceCodeRemark(getFailureSolution(), el, getFailureMsgCode());
} else {
testSolution = setTestSolution(testSolution, getSuccessSolution());
addSourceCodeRemark(getSuccessSolution(), el, getSuccessMsgCode());
}
}
testSolutionHandler.addTestSolution(testSolution);
}
use of org.asqatasun.entity.audit.TestSolution in project Asqatasun by Asqatasun.
the class LangChangeChecker method checkLanguageChange.
/**
*
* @param element
* @param sspHandler
* @return
*/
private TestSolution checkLanguageChange(Element element, SSPHandler sspHandler) {
String langDefinition = extractLangDefinitionFromElement(element, sspHandler);
defaultLang = extractEffectiveLang(langDefinition);
TestSolution declarationValidity = checkLanguageDeclarationValidity(element, langDefinition, defaultLang, false);
if (declarationValidity.equals(TestSolution.FAILED)) {
return TestSolution.NOT_APPLICABLE;
}
// the handler may contain the html element or nothing
return checkLanguageRelevancyRecursively(sspHandler, element, null);
}
Aggregations