Search in sources :

Example 16 with TestSolutionHandler

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();
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Element(org.jsoup.nodes.Element) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) TestSolutionHandlerImpl(org.asqatasun.ruleimplementation.TestSolutionHandlerImpl) TestSolutionHandler(org.asqatasun.ruleimplementation.TestSolutionHandler) Document(org.jsoup.nodes.Document) File(java.io.File)

Example 17 with TestSolutionHandler

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();
}
Also used : Element(org.jsoup.nodes.Element) TestSolutionHandlerImpl(org.asqatasun.ruleimplementation.TestSolutionHandlerImpl) TestSolutionHandler(org.asqatasun.ruleimplementation.TestSolutionHandler)

Aggregations

TestSolutionHandler (org.asqatasun.ruleimplementation.TestSolutionHandler)17 TestSolutionHandlerImpl (org.asqatasun.ruleimplementation.TestSolutionHandlerImpl)16 Element (org.jsoup.nodes.Element)15 ElementHandlerImpl (org.asqatasun.ruleimplementation.ElementHandlerImpl)14 ProcessRemark (org.asqatasun.entity.audit.ProcessRemark)6 File (java.io.File)2 Document (org.jsoup.nodes.Document)2 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1 SSP (org.asqatasun.entity.audit.SSP)1 TestSolution (org.asqatasun.entity.audit.TestSolution)1 SSPHandler (org.asqatasun.processor.SSPHandler)1 ProcessRemarkService (org.asqatasun.service.ProcessRemarkService)1 Elements (org.jsoup.select.Elements)1