Search in sources :

Example 41 with ElementHandlerImpl

use of org.asqatasun.ruleimplementation.ElementHandlerImpl in project Asqatasun by Asqatasun.

the class ImageElementSelectorTest method testSelectElements6_2.

/**
     * Test of selectElements method, of class ImageElementSelector.
     */
public void testSelectElements6_2() {
    LOGGER.debug("selectElements6-2");
    Document doc = null;
    try {
        doc = Jsoup.parse(new File("src/test/resources/images/image-composite-2.html"), Charset.defaultCharset().displayName());
    } catch (IOException ex) {
    }
    initMockContext(HtmlElementStore.IMG_ELEMENT, doc);
    ElementHandler<Element> elementHandler = new ElementHandlerImpl();
    ImageElementSelector instance = new ImageElementSelector(HtmlElementStore.IMG_ELEMENT, false, true);
    instance.selectElements(sspHandler, elementHandler);
    assertTrue(elementHandler.isEmpty());
    verifyMockContext();
}
Also used : Element(org.jsoup.nodes.Element) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) IOException(java.io.IOException) Document(org.jsoup.nodes.Document) File(java.io.File)

Example 42 with ElementHandlerImpl

use of org.asqatasun.ruleimplementation.ElementHandlerImpl in project Asqatasun by Asqatasun.

the class ImageElementSelectorTest method testSelectElements5_3.

/**
     * Test of selectElements method, of class ImageElementSelector.
     */
public void testSelectElements5_3() {
    LOGGER.debug("selectElements5-3");
    Document doc = null;
    try {
        doc = Jsoup.parse(new File("src/test/resources/images/image-composite-3.html"), Charset.defaultCharset().displayName());
    } catch (IOException ex) {
    }
    initMockContext(HtmlElementStore.IMG_ELEMENT, doc);
    ElementHandler<Element> elementHandler = new ElementHandlerImpl();
    ImageElementSelector instance = new ImageElementSelector(HtmlElementStore.IMG_ELEMENT, true, true);
    instance.selectElements(sspHandler, elementHandler);
    assertTrue(elementHandler.isEmpty());
    verifyMockContext();
}
Also used : Element(org.jsoup.nodes.Element) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) IOException(java.io.IOException) Document(org.jsoup.nodes.Document) File(java.io.File)

Example 43 with ElementHandlerImpl

use of org.asqatasun.ruleimplementation.ElementHandlerImpl in project Asqatasun by Asqatasun.

the class CompositeChecker method doCheck.

@Override
protected void doCheck(SSPHandler sspHandler, Elements elements, TestSolutionHandler testSolutionHandler) {
    setServicesToCheckers();
    ElementHandler<Element> elementHandler = new ElementHandlerImpl();
    for (Element element : elements) {
        elementHandler.clean().add(element);
        testSolutionHandler.addTestSolution(callCheckers(sspHandler, elementHandler));
    }
}
Also used : Element(org.jsoup.nodes.Element) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl)

Example 44 with ElementHandlerImpl

use of org.asqatasun.ruleimplementation.ElementHandlerImpl in project Asqatasun by Asqatasun.

the class Rgaa30Rule060304 method testTitleAttributeLink.

/**
     * 
     * @param sspHandler
     * @param el
     * @param linkText
     * @return 
     */
private TestSolution testTitleAttributeLink(SSPHandler sspHandler, Element el, String linkText) {
    // content identical to the link text, returns not applicable.
    if (!el.hasAttr(TITLE_ATTR)) {
        return TestSolution.NOT_APPLICABLE;
    }
    String attrValue = el.attr(TITLE_ATTR);
    if (StringUtils.isBlank(attrValue)) {
        return TestSolution.NOT_APPLICABLE;
    }
    if (StringUtils.equalsIgnoreCase(attrValue, linkText)) {
        return TestSolution.NOT_APPLICABLE;
    }
    ElementHandler<Element> elHandler = new ElementHandlerImpl(el);
    TestSolutionHandler tsHandler = new TestSolutionHandlerImpl();
    titlePertinenceElementChecker.check(sspHandler, elHandler, tsHandler);
    return tsHandler.getTestSolution();
}
Also used : Element(org.jsoup.nodes.Element) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) TestSolutionHandlerImpl(org.asqatasun.ruleimplementation.TestSolutionHandlerImpl) TestSolutionHandler(org.asqatasun.ruleimplementation.TestSolutionHandler)

Example 45 with ElementHandlerImpl

use of org.asqatasun.ruleimplementation.ElementHandlerImpl in project Asqatasun by Asqatasun.

the class Rgaa30Rule080301 method removeElementWithParentWithLangAttr.

/**
     * Remove elements from the current elementHandler when an element has a
     * parent with a lang attribute
     *
     * @param elementHandler
     */
private void removeElementWithParentWithLangAttr() {
    if (elementWithLang.isEmpty()) {
        return;
    }
    ElementHandler<Element> elementWithParentWithLang = new ElementHandlerImpl();
    for (Element el : elementWithoutLang.get()) {
        if (isElementHasParentWithLang(el)) {
            elementWithParentWithLang.add(el);
        }
    }
    elementWithoutLang.removeAll(elementWithParentWithLang);
    elementWithLang.addAll(elementWithParentWithLang.get());
}
Also used : Element(org.jsoup.nodes.Element) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl)

Aggregations

ElementHandlerImpl (org.asqatasun.ruleimplementation.ElementHandlerImpl)88 Element (org.jsoup.nodes.Element)87 Document (org.jsoup.nodes.Document)51 File (java.io.File)49 IOException (java.io.IOException)44 TestSolutionHandler (org.asqatasun.ruleimplementation.TestSolutionHandler)14 TestSolutionHandlerImpl (org.asqatasun.ruleimplementation.TestSolutionHandlerImpl)14 SimpleElementSelector (org.asqatasun.rules.elementselector.SimpleElementSelector)9 ProcessRemark (org.asqatasun.entity.audit.ProcessRemark)6 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)5 ElementHandler (org.asqatasun.ruleimplementation.ElementHandler)5 Nomenclature (org.asqatasun.entity.reference.Nomenclature)4 ElementChecker (org.asqatasun.rules.elementchecker.ElementChecker)4 ElementPresenceChecker (org.asqatasun.rules.elementchecker.element.ElementPresenceChecker)4 ElementSelector (org.asqatasun.rules.elementselector.ElementSelector)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 TextEmptinessChecker (org.asqatasun.rules.elementchecker.text.TextEmptinessChecker)3 InputFormElementWithExplicitLabelSelector (org.asqatasun.rules.elementselector.InputFormElementWithExplicitLabelSelector)3 InputFormElementWithInplicitLabelSelector (org.asqatasun.rules.elementselector.InputFormElementWithInplicitLabelSelector)3