use of org.asqatasun.ruleimplementation.TestSolutionHandler in project Asqatasun by Asqatasun.
the class ElementPresenceCheckerTest method testCheckDefaultDetectedUnicityFailedOverrideSolutionResult2.
/**
* Test of doCheck method, of class ElementPresenceChecker.
* @throws java.io.IOException
*/
public void testCheckDefaultDetectedUnicityFailedOverrideSolutionResult2() throws IOException {
LOGGER.debug("elementPresenceChecker-check-default-detection-unicity-failed-override-solution-result2");
Document doc = Jsoup.parse(new File("src/test/resources/presenceChecker/presence-checker-unique-1.html"), Charset.defaultCharset().displayName());
ElementHandler<Element> elementHandler = new ElementHandlerImpl();
elementHandler.addAll(doc.select(HtmlElementStore.A_ELEMENT));
initMockContext(TestSolution.NOT_APPLICABLE, null);
TestSolutionHandler testSolutionHandler = new TestSolutionHandlerImpl();
ElementPresenceChecker instance = new ElementPresenceChecker(new ImmutablePair(TestSolution.NEED_MORE_INFO, "detected"), new ImmutablePair(TestSolution.NOT_APPLICABLE, ""));
instance.check(mockSspHandler, elementHandler, testSolutionHandler);
assertEquals(TestSolution.NOT_APPLICABLE, testSolutionHandler.getTestSolution());
verifyMockContext();
}
use of org.asqatasun.ruleimplementation.TestSolutionHandler in project Asqatasun by Asqatasun.
the class LangChangeChecker method checkLanguageRelevancyRecursively.
/**
* @param sspHandler
* @param element
* @param checkCurrentElement
* @return
*/
private TestSolution checkLanguageRelevancyRecursively(SSPHandler sspHandler, Element element, @Nullable String currentLangRedefinitionValue) {
String currentLangRedefinition = currentLangRedefinitionValue;
TestSolutionHandler tsh = new TestSolutionHandlerImpl();
// children have to be identical to the default one.
if (isLangDefinedForElement(element)) {
String langDefinition = extractLangDefinitionFromElement(element, sspHandler);
String currentLang = extractEffectiveLang(langDefinition);
if (!StringUtils.equalsIgnoreCase(defaultLang, currentLang)) {
currentLangRedefinition = currentLang;
} else {
currentLangRedefinition = null;
}
}
// we extract the textual content of the current element. If not empty
// we check the language relevancy
String extractedText = extractTextFromElement(element, false);
if (isTextTestable(extractedText)) {
newElementTested();
if (StringUtils.isNotBlank(currentLangRedefinition)) {
tsh.addTestSolution(checkLanguageDifferentFromDefault(element, extractedText, currentLangRedefinition));
} else {
tsh.addTestSolution(checkLanguageIdenticalToDefault(element, extractedText));
}
}
for (Element el : element.children()) {
tsh.addTestSolution(checkLanguageRelevancyRecursively(sspHandler, el, currentLangRedefinition));
}
return tsh.getTestSolution();
}
Aggregations