Rename comic loader to resource loader
[rhynodge.git] / src / test / java / net / pterodactylus / rhynodge / filters / comics / AbstruseGooseComicFilterTest.java
1 /*
2  * rhynodge - AbstruseGooseComicFilterTest.java - Copyright © 2013 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.rhynodge.filters.comics;
19
20 import static com.google.common.base.Optional.of;
21 import static org.hamcrest.MatcherAssert.assertThat;
22 import static org.hamcrest.Matchers.contains;
23 import static org.hamcrest.Matchers.is;
24
25 import java.io.IOException;
26 import java.util.List;
27
28 import net.pterodactylus.rhynodge.filters.ResourceLoader;
29
30 import com.google.common.base.Optional;
31 import org.jsoup.nodes.Document;
32 import org.junit.Test;
33
34 /**
35  * Unit test for {@link AbstruseGooseComicFilter}.
36  *
37  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
38  */
39 public class AbstruseGooseComicFilterTest {
40
41         private final AbstruseGooseComicFilter abstruseGooseComicFilter = new AbstruseGooseComicFilter();
42         private final Document document;
43
44         public AbstruseGooseComicFilterTest() throws IOException {
45                 document = ResourceLoader.loadDocument("abstruse-goose.html", "http://abstrusegoose.com/");
46         }
47
48         @Test
49         public void extractsComicTitleCorrectly() {
50                 Optional<String> title = abstruseGooseComicFilter.extractTitle(document);
51                 assertThat(title, is(of("The Sudokomic Game")));
52         }
53
54         @Test
55         public void extractComicImagesCorrectly() {
56                 List<String> images = abstruseGooseComicFilter.extractImageUrls(document);
57                 assertThat(images, contains("http://abstrusegoose.com/strips/another_fun_game_is_comic_tac_toe.png"));
58         }
59
60         @Test
61         public void extractImageCommentsCorrectly() {
62                 List<String> comments = abstruseGooseComicFilter.extractImageComments(document);
63                 assertThat(comments, contains("This is the best I could do on short notice."));
64         }
65
66 }