2 * rhynodge - AbstruseGooseComicFilterTest.java - Copyright © 2013 David Roden
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.
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.
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/>.
18 package net.pterodactylus.rhynodge.filters.comics;
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;
25 import java.io.IOException;
26 import java.io.InputStream;
27 import java.util.List;
29 import com.google.common.base.Optional;
30 import org.jsoup.Jsoup;
31 import org.jsoup.nodes.Document;
32 import org.junit.Test;
35 * Unit test for {@link AbstruseGooseComicFilter}.
37 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
39 public class AbstruseGooseComicFilterTest {
41 private final AbstruseGooseComicFilter abstruseGooseComicFilter = new AbstruseGooseComicFilter();
42 private final Document document;
44 public AbstruseGooseComicFilterTest() throws IOException {
45 document = loadDocument("/comics/abstrusegoose.html", "http://abstrusegoose.com/");
48 private Document loadDocument(String resourceName, String baseUri) throws IOException {
49 InputStream inputStream = getClass().getResourceAsStream(resourceName);
50 Document document = Jsoup.parse(inputStream, "UTF-8", baseUri);
55 public void extractsComicTitleCorrectly() {
56 Optional<String> title = abstruseGooseComicFilter.extractTitle(document);
57 assertThat(title, is(of("Bizarro")));
61 public void extractComicImagesCorrectly() {
62 List<String> images = abstruseGooseComicFilter.extractImageUrls(document);
63 assertThat(images, contains("http://abstrusegoose.com/strips/bizero.png"));
67 public void extractImageCommentsCorrectly() {
68 List<String> comments = abstruseGooseComicFilter.extractImageComments(document);
69 assertThat(comments, contains("In the additive group of the integers, bizarro zero is... well... zero."));