Search in sources :

Example 1 with SimpleTextElementBuilder

use of org.asqatasun.rules.textbuilder.SimpleTextElementBuilder in project Asqatasun by Asqatasun.

the class SeoRule07051 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    if (titleElement.isEmpty() || h1Elements.isEmpty()) {
        testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
        return;
    }
    String titleValue = new SimpleTextElementBuilder().buildTextFromElement(titleElement.get().iterator().next());
    TextElementBuilder h1ValueBuilder = new DeepTextElementBuilder();
    for (Element el : h1Elements.get()) {
        String h1 = h1ValueBuilder.buildTextFromElement(el);
        if (StringUtils.equalsIgnoreCase(h1, titleValue)) {
            sspHandler.getProcessRemarkService().addProcessRemark(TestSolution.FAILED, IDENTICAL_H1_AND_TITLE_MSG);
            testSolutionHandler.addTestSolution(TestSolution.FAILED);
            return;
        }
    }
    testSolutionHandler.addTestSolution(TestSolution.PASSED);
}
Also used : SimpleTextElementBuilder(org.asqatasun.rules.textbuilder.SimpleTextElementBuilder) DeepTextElementBuilder(org.asqatasun.rules.textbuilder.DeepTextElementBuilder) TextElementBuilder(org.asqatasun.rules.textbuilder.TextElementBuilder) DeepTextElementBuilder(org.asqatasun.rules.textbuilder.DeepTextElementBuilder) SimpleTextElementBuilder(org.asqatasun.rules.textbuilder.SimpleTextElementBuilder) Element(org.jsoup.nodes.Element)

Example 2 with SimpleTextElementBuilder

use of org.asqatasun.rules.textbuilder.SimpleTextElementBuilder in project Asqatasun by Asqatasun.

the class SeoRule06031 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    if (elementHandler.isEmpty()) {
        testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
        return;
    }
    // in case of more than one title, keep the first.
    if (elementHandler.get().size() > 1) {
        Element element = elementHandler.get().iterator().next();
        elementHandler.clean().add(element);
    }
    ElementChecker checker = new TextLengthChecker(new SimpleTextElementBuilder(), TITLE_MAX_LENGTH, TITLE_EXCEEDS_LIMIT_MSG, // evidence elements
    HtmlElementStore.TEXT_ELEMENT2);
    checker.check(sspHandler, elementHandler, testSolutionHandler);
}
Also used : TextLengthChecker(org.asqatasun.rules.elementchecker.text.TextLengthChecker) SimpleTextElementBuilder(org.asqatasun.rules.textbuilder.SimpleTextElementBuilder) Element(org.jsoup.nodes.Element) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker)

Example 3 with SimpleTextElementBuilder

use of org.asqatasun.rules.textbuilder.SimpleTextElementBuilder in project Asqatasun by Asqatasun.

the class TextPertinenceCheckerTest method testGetTextElementBuilder.

/**
 * Test of getTextElementBuilder method, of class TextPertinenceChecker.
 */
public void testGetTextElementBuilder() {
    LOGGER.debug("getTextElementBuilder");
    TextPertinenceChecker instance = new TextPertinenceChecker(true, new TextAttributeOfElementBuilder(AttributeStore.ALT_ATTR), "blacklistNomenclature", TestSolution.NEED_MORE_INFO, "notPertinent", "manualCheck");
    TextElementBuilder result = instance.getTextElementBuilder();
    assertTrue(result instanceof SimpleTextElementBuilder);
}
Also used : SimpleTextElementBuilder(org.asqatasun.rules.textbuilder.SimpleTextElementBuilder) TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder) TextElementBuilder(org.asqatasun.rules.textbuilder.TextElementBuilder) SimpleTextElementBuilder(org.asqatasun.rules.textbuilder.SimpleTextElementBuilder)

Aggregations

SimpleTextElementBuilder (org.asqatasun.rules.textbuilder.SimpleTextElementBuilder)3 TextElementBuilder (org.asqatasun.rules.textbuilder.TextElementBuilder)2 Element (org.jsoup.nodes.Element)2 ElementChecker (org.asqatasun.rules.elementchecker.ElementChecker)1 TextLengthChecker (org.asqatasun.rules.elementchecker.text.TextLengthChecker)1 DeepTextElementBuilder (org.asqatasun.rules.textbuilder.DeepTextElementBuilder)1 TextAttributeOfElementBuilder (org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder)1