Skip to content

Commit 02918f8

Browse files
committed
update test
1 parent 1192183 commit 02918f8

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/test/java/im/nll/data/extractor/ExtractorsTest.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ public void testToBeanListFilter() throws Exception {
370370
}
371371

372372
@Test
373-
public void testToBeanListFilterAll() throws Exception {
373+
public void testToBeanListFilterBefore() throws Exception {
374374
List<Language> languages = Extractors.on(listHtml)
375375
.before(value -> "all-" + value)
376376
.split(xpath("//tr[@class='item']"))
@@ -386,6 +386,24 @@ public void testToBeanListFilterAll() throws Exception {
386386
Assert.assertEquals(second.getUrl(), "url:all-https://www.ruby-lang.org");
387387
}
388388

389+
@Test
390+
public void testToBeanListFilterBeforeAndAfter() throws Exception {
391+
List<Language> languages = Extractors.on(listHtml)
392+
.before(value -> "before-" + value)
393+
.after(value -> value + "-after")
394+
.split(xpath("//tr[@class='item']"))
395+
.extract("type", xpath("//td[1]/text()")).filter(value -> "type:" + value)
396+
.extract("name", xpath("//td[2]/text()")).filter(value -> "name:" + value)
397+
.extract("url", xpath("//td[3]/text()")).filter(value -> "url:" + value)
398+
.asBeanList(Language.class);
399+
Assert.assertNotNull(languages);
400+
Language second = languages.get(1);
401+
Assert.assertEquals(languages.size(), 3);
402+
Assert.assertEquals(second.getType(), "type:before-dynamic-after");
403+
Assert.assertEquals(second.getName(), "name:before-Ruby-after");
404+
Assert.assertEquals(second.getUrl(), "url:before-https://www.ruby-lang.org-after");
405+
}
406+
389407
@Test
390408
public void testToBeanListByJson() throws Exception {
391409
List<Book> books = Extractors.on(jsonString).split(json("$..book.*"))

0 commit comments

Comments
 (0)