Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
fivesmallq committed Apr 23, 2016
1 parent 1192183 commit 02918f8
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/test/java/im/nll/data/extractor/ExtractorsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public void testToBeanListFilter() throws Exception {
}

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

@Test
public void testToBeanListFilterBeforeAndAfter() throws Exception {
List<Language> languages = Extractors.on(listHtml)
.before(value -> "before-" + value)
.after(value -> value + "-after")
.split(xpath("//tr[@class='item']"))
.extract("type", xpath("//td[1]/text()")).filter(value -> "type:" + value)
.extract("name", xpath("//td[2]/text()")).filter(value -> "name:" + value)
.extract("url", xpath("//td[3]/text()")).filter(value -> "url:" + value)
.asBeanList(Language.class);
Assert.assertNotNull(languages);
Language second = languages.get(1);
Assert.assertEquals(languages.size(), 3);
Assert.assertEquals(second.getType(), "type:before-dynamic-after");
Assert.assertEquals(second.getName(), "name:before-Ruby-after");
Assert.assertEquals(second.getUrl(), "url:before-https://www.ruby-lang.org-after");
}

@Test
public void testToBeanListByJson() throws Exception {
List<Book> books = Extractors.on(jsonString).split(json("$..book.*"))
Expand Down

0 comments on commit 02918f8

Please sign in to comment.