use of org.jsoup.nodes.Element in project Asqatasun by Asqatasun.
the class TextEmptinessCheckerTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
mockTextElementBuilder = createMock(TextElementBuilder.class);
mockSSPHandler = createMock(SSPHandler.class);
elements = new Elements();
element = new Element(Tag.valueOf("div"), "");
mockTestSolutionHandler = createMock(TestSolutionHandler.class);
mockProcessRemarkService = createMock(ProcessRemarkService.class);
}
use of org.jsoup.nodes.Element in project Asqatasun by Asqatasun.
the class ImageElementSelector method excludeLinksFromSelection.
/**
*
* @param elementHandler
*/
private void excludeLinksFromSelection(ElementHandler<Element> elementHandler) {
if (!excludeCompositeLink && !excludeImageLink) {
return;
}
ElementHandler<Element> linkHandler = new ElementHandlerImpl();
for (Element el : elementHandler.get()) {
Element link = el.parents().select(A_ELEMENT).first();
if (excludeImageLink && isImageLink(link, el)) {
linkHandler.add(el);
} else if (excludeCompositeLink && isCompositeLink(link, el)) {
linkHandler.add(el);
}
}
elementHandler.removeAll(linkHandler);
}
use of org.jsoup.nodes.Element in project Asqatasun by Asqatasun.
the class DeepTextElementBuilder method buildTextFromElement.
@Override
public String buildTextFromElement(Element element) {
StringBuilder elementText = new StringBuilder();
if (element.hasAttr(ALT_ATTR)) {
elementText.append(SPACER);
elementText.append(altAttrTextBuilder.buildTextFromElement(element));
}
for (Node child : element.childNodes()) {
if (child instanceof TextNode && !((TextNode) child).isBlank()) {
elementText.append(SPACER);
elementText.append(StringUtils.trim(((TextNode) child).text()));
} else if (child instanceof Element) {
elementText.append(SPACER);
elementText.append(buildTextFromElement((Element) child));
}
}
return StringUtils.trim(elementText.toString());
}
use of org.jsoup.nodes.Element in project Asqatasun by Asqatasun.
the class TextNotIdenticalToAttributeCheckerTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
mockTextElementBuilder = createMock(TextElementBuilder.class);
mockSSPHandler = createMock(SSPHandler.class);
elements = new Elements();
element = new Element(Tag.valueOf("div"), "");
element.attr(AttributeStore.ALT_ATTR, "test");
mockTestSolutionHandler = createMock(TestSolutionHandler.class);
mockProcessRemarkService = createMock(ProcessRemarkService.class);
}
use of org.jsoup.nodes.Element in project Asqatasun by Asqatasun.
the class ElementPresenceCheckerTest method testCheckDefaultDetectedUnicityFailedOverrideSolutionResult1.
/**
* Test of doCheck method, of class ElementPresenceChecker.
* @throws java.io.IOException
*/
public void testCheckDefaultDetectedUnicityFailedOverrideSolutionResult1() throws IOException {
LOGGER.debug("elementPresenceChecker-check-default-detection-unicity-failed-override-solution-result1");
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.DIV_ELEMENT));
initMockContext((Elements) elementHandler.get(), TestSolution.NEED_MORE_INFO, "detected");
TestSolutionHandler testSolutionHandler = new TestSolutionHandlerImpl();
ElementPresenceChecker instance = new ElementPresenceChecker(true, TestSolution.NEED_MORE_INFO, TestSolution.NOT_APPLICABLE, "detected", "notDetected", null);
instance.check(mockSspHandler, elementHandler, testSolutionHandler);
assertEquals(TestSolution.NEED_MORE_INFO, testSolutionHandler.getTestSolution());
verifyMockContext();
}
Aggregations