### Question:
Elements extends ArrayList<Element> { private Elements siblings(String query, boolean next, boolean all) { Elements els = new Elements(); Evaluator eval = query != null? QueryParser.parse(query) : null; for (Element e : this) { do { Element sib = next ? e.nextElementSibling() : e.previousElementSibling(); if (sib == null) break; if (eval == null) els.add(sib); else if (sib.is(eval)) els.add(sib); e = sib; } while (all); } return els; } Elements();  Elements(int initialCapacity);  Elements(Collection<Element> elements);  Elements(List<Element> elements);  Elements(Element... elements); @Override Elements clone(); String attr(String attributeKey); boolean hasAttr(String attributeKey); List<String> eachAttr(String attributeKey); Elements attr(String attributeKey, String attributeValue); Elements removeAttr(String attributeKey); Elements addClass(String className); Elements removeClass(String className); Elements toggleClass(String className); boolean hasClass(String className); String val(); Elements val(String value); String text(); boolean hasText(); List<String> eachText(); String html(); String outerHtml(); @Override String toString(); Elements tagName(String tagName); Elements html(String html); Elements prepend(String html); Elements append(String html); Elements before(String html); Elements after(String html); Elements wrap(String html); Elements unwrap(); Elements empty(); Elements remove(); Elements select(String query); Elements not(String query); Elements eq(int index); boolean is(String query); Elements next(); Elements next(String query); Elements nextAll(); Elements nextAll(String query); Elements prev(); Elements prev(String query); Elements prevAll(); Elements prevAll(String query); Elements parents(); Element first(); Element last(); Elements traverse(NodeVisitor nodeVisitor); List<FormElement> forms();  }### Answer:
@Test public void siblings() { Document doc = Jsoup.parse("<div><p>1<p>2<p>3<p>4<p>5<p>6</div><div><p>7<p>8<p>9<p>10<p>11<p>12</div>"); Elements els = doc.select("p:eq(3)"); assertEquals(2, els.size()); Elements next = els.next(); assertEquals(2, next.size()); assertEquals("5", next.first().text()); assertEquals("11", next.last().text()); assertEquals(0, els.next("p:contains(6)").size()); final Elements nextF = els.next("p:contains(5)"); assertEquals(1, nextF.size()); assertEquals("5", nextF.first().text()); Elements nextA = els.nextAll(); assertEquals(4, nextA.size()); assertEquals("5", nextA.first().text()); assertEquals("12", nextA.last().text()); Elements nextAF = els.nextAll("p:contains(6)"); assertEquals(1, nextAF.size()); assertEquals("6", nextAF.first().text()); Elements prev = els.prev(); assertEquals(2, prev.size()); assertEquals("3", prev.first().text()); assertEquals("9", prev.last().text()); assertEquals(0, els.prev("p:contains(1)").size()); final Elements prevF = els.prev("p:contains(3)"); assertEquals(1, prevF.size()); assertEquals("3", prevF.first().text()); Elements prevA = els.prevAll(); assertEquals(6, prevA.size()); assertEquals("3", prevA.first().text()); assertEquals("7", prevA.last().text()); Elements prevAF = els.prevAll("p:contains(1)"); assertEquals(1, prevAF.size()); assertEquals("1", prevAF.first().text()); }