5b9e9163671e66997c7f8a1e110cd83edeef9c12
[rhynodge.git] / src / test / java / net / pterodactylus / rhynodge / filters / comics / BusinessCatComicFilterTest.java
1 package net.pterodactylus.rhynodge.filters.comics;
2
3 import java.io.IOException;
4 import java.io.InputStream;
5
6 import com.google.common.base.Optional;
7 import org.hamcrest.MatcherAssert;
8 import org.hamcrest.Matchers;
9 import org.jsoup.Jsoup;
10 import org.jsoup.nodes.Document;
11 import org.junit.Test;
12
13 /**
14  * Unit test for {@link BusinessCatComicFilter}.
15  */
16 public class BusinessCatComicFilterTest {
17
18         private final BusinessCatComicFilter filter = new BusinessCatComicFilter();
19         private final Document document;
20
21         public BusinessCatComicFilterTest() throws IOException {
22                 document = loadDocument("business-cat.html", "http://www.businesscat.happyjar.com//");
23         }
24
25         private Document loadDocument(String resourceName, String baseUri) throws IOException {
26                 InputStream inputStream = getClass().getResourceAsStream(resourceName);
27                 Document document = Jsoup.parse(inputStream, "UTF-8", baseUri);
28                 return document;
29         }
30
31         @Test
32         public void imageTitleCanBeExtracted() {
33                 MatcherAssert.assertThat(filter.extractTitle(document), Matchers.is(Optional.of("Running Late")));
34         }
35
36         @Test
37         public void imageUrlsCanBeExtracted() {
38                 MatcherAssert.assertThat(filter.extractImageUrls(document), Matchers.contains("http://www.businesscat.happyjar.com/wp-content/uploads/2015/01/2015-01-23-Running-Late.png"));
39         }
40
41         @Test
42         public void imageCommentsCanBeExtracted() {
43                 MatcherAssert.assertThat(filter.extractImageComments(document), Matchers.empty());
44         }
45
46 }