Search in sources :

Example 1 with DeepTextElementBuilder

use of org.asqatasun.rules.textbuilder.DeepTextElementBuilder 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)

Aggregations

DeepTextElementBuilder (org.asqatasun.rules.textbuilder.DeepTextElementBuilder)1 SimpleTextElementBuilder (org.asqatasun.rules.textbuilder.SimpleTextElementBuilder)1 TextElementBuilder (org.asqatasun.rules.textbuilder.TextElementBuilder)1 Element (org.jsoup.nodes.Element)1