use of org.asqatasun.entity.audit.TestSolution in project Asqatasun by Asqatasun.
the class AttributeOnChildElementPresenceChecker method checkChildElementWithAttributePresence.
/**
* This methods checks whether elements have a child element of with a given
* attribute.
*
* @param elements
* @param testSolutionHandler
*/
private void checkChildElementWithAttributePresence(Elements elements, TestSolutionHandler testSolutionHandler) {
if (elements.isEmpty()) {
testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
return;
}
TestSolution testSolution = TestSolution.PASSED;
for (Element el : elements) {
if (!el.getElementsByAttribute(attributeName).isEmpty()) {
testSolution = setTestSolution(testSolution, getSuccessSolution());
addSourceCodeRemark(getSuccessSolution(), el, getSuccessMsgCode());
} else {
testSolution = setTestSolution(testSolution, getFailureSolution());
addSourceCodeRemark(getFailureSolution(), el, getFailureMsgCode());
}
}
testSolutionHandler.addTestSolution(testSolution);
}
use of org.asqatasun.entity.audit.TestSolution in project Asqatasun by Asqatasun.
the class AttributePresenceChecker method checkAttributePresence.
/**
* This methods checks whether a given attribute is present for a set of
* elements
*
* @param elements
* @param testSolutionHandler
*/
private void checkAttributePresence(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)) {
testSolution = setTestSolution(testSolution, getFailureSolution());
createSourceCodeRemark(getFailureSolution(), el, getFailureMsgCode());
} else {
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 ElementPresenceChecker method checkElementPresence.
/**
* This methods checks whether a given element is present on the page.
*
* @param elements
* @param testSolutionHandler
*/
private void checkElementPresence(Elements elements, TestSolutionHandler testSolutionHandler) {
TestSolution checkResult = getFailureSolution();
if (!elements.isEmpty() && ((!checkUnicity) || (checkUnicity && elements.size() == 1))) {
checkResult = getSuccessSolution();
for (Element el : elements) {
createSourceCodeRemark(getSuccessSolution(), el, getSuccessMsgCode());
}
} else if (checkUnicity && elements.size() > 1 && StringUtils.isNotBlank(messageCodeOnMultipleElements)) {
for (Element el : elements) {
addSourceCodeRemark(getFailureSolution(), el, messageCodeOnMultipleElements);
}
} else if (StringUtils.isNotBlank(getFailureMsgCode())) {
getProcessRemarkService().addProcessRemark(getFailureSolution(), getFailureMsgCode());
}
testSolutionHandler.addTestSolution(checkResult);
}
use of org.asqatasun.entity.audit.TestSolution in project Asqatasun by Asqatasun.
the class HeadingsHierarchyChecker method checkHeadingsHierarchy.
/**
* This methods checks whether the headings hierarchy is well-structured
*
* @param elements
* @param testSolutionHandler
*/
private void checkHeadingsHierarchy(Elements elements, TestSolutionHandler testSolutionHandler) {
if (elements.isEmpty()) {
testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
return;
}
TestSolution checkResult = TestSolution.PASSED;
Iterator<Element> iter = elements.iterator();
// we get the index of the first element for further test
Element element = iter.next();
int indexOfReference = getHeaderIndex(element);
int currentIndex;
int previousIndex = indexOfReference;
Element elementOfReference = element;
Element previousElement = element;
while (iter.hasNext()) {
element = iter.next();
currentIndex = getHeaderIndex(element);
if (currentIndex != -1) {
if (currentIndex - previousIndex >= 2) {
checkResult = TestSolution.FAILED;
addSourceCodeRemark(TestSolution.FAILED, element, HEADER_NOT_HIERARCHICALLY_WELL_DEFINED_MSG, getEvidenceElement(PREVIOUS_H_TAG_INDEX_EE, getEvidenceElementMsg(previousIndex, previousElement)));
} else if (currentIndex < indexOfReference) {
checkResult = TestSolution.FAILED;
addSourceCodeRemark(TestSolution.FAILED, element, HEADER_NOT_HIERARCHICALLY_WELL_DEFINED_MSG, getEvidenceElement(FIRST_H_TAG_INDEX_EE, getEvidenceElementMsg(indexOfReference, elementOfReference)));
}
previousIndex = currentIndex;
previousElement = element;
}
}
testSolutionHandler.addTestSolution(checkResult);
}
use of org.asqatasun.entity.audit.TestSolution in project Asqatasun by Asqatasun.
the class SeoRule01081 method processImpl.
@Override
protected ProcessResult processImpl(SSPHandler sspHandler) {
ProcessRemarkService processRemarkService = sspHandler.getProcessRemarkService();
processRemarkService.resetService();
TestSolution testSolution = TestSolution.PASSED;
try {
URL url = new URL(sspHandler.getSSP().getURI());
if (StringUtils.isNotBlank(url.getPath()) && url.getPath().contains("_")) {
testSolution = TestSolution.FAILED;
processRemarkService.addProcessRemark(TestSolution.FAILED, RemarkMessageStore.URL_PATH_UNDERSCORE_DETECTED);
}
} catch (MalformedURLException ex) {
testSolution = TestSolution.NOT_APPLICABLE;
}
return processResultDataService.getDefiniteResult(test, sspHandler.getPage(), testSolution, processRemarkService.getRemarkList());
}
Aggregations