public Iterable<Node> get() { Document document; try { document = Jsoup.parse(stream.get(), null, "#"); } catch (IOException e) { throw new RuntimeException(e); } List<Element> res = document.select(selector.get()); List<Node> copy = new ArrayList<Node>(res); return copy; }
@Test public void testRegularText() throws Exception { Value<String> text = mock(Value.class); when(text.get()).thenReturn("text"); Texter a = new Texter(text); Document document = Jsoup.parseBodyFragment("<html><body><outer>test</outer></body></html>"); Element element = document.getElementsByTag("outer").first(); List<Node> processed = a.process(element); // verify that bind and get were called, in this order InOrder inOrder = inOrder(text); inOrder.verify(text).get(); assertXMLEqual( new StringReader("<body><outer>text</outer></body>"), new StringReader(html(processed))); }