1 package net.pterodactylus.rhynodge.filters.comics;
3 import static org.hamcrest.MatcherAssert.assertThat;
4 import static org.hamcrest.Matchers.hasSize;
5 import static org.hamcrest.Matchers.is;
7 import java.io.IOException;
9 import net.pterodactylus.rhynodge.Filter;
10 import net.pterodactylus.rhynodge.State;
11 import net.pterodactylus.rhynodge.filters.ResourceLoader;
12 import net.pterodactylus.rhynodge.states.ComicState;
13 import net.pterodactylus.rhynodge.states.ComicState.Comic;
14 import net.pterodactylus.rhynodge.states.HtmlState;
16 import org.hamcrest.Matchers;
17 import org.jsoup.nodes.Document;
18 import org.junit.Test;
21 * Unit test for {@link SaturdayMorningBreakfastCerealComicFilter}.
23 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
25 public class SaturdayMorningBreakfastCerealComicFilterTest {
27 private final Filter smbcFilter = new SaturdayMorningBreakfastCerealComicFilter();
28 private final HtmlState htmlState;
30 public SaturdayMorningBreakfastCerealComicFilterTest() throws IOException {
31 Document document = ResourceLoader.loadDocument(SinfestComicFilter.class, "saturday-morning-breakfast-cereal.html", "http://www.smbc-comics.com/");
32 htmlState = new HtmlState("http://www.smbc-comics.com/", document);
36 public void htmlCanBeParsed() {
37 State state = smbcFilter.filter(htmlState);
38 assertThat(state, Matchers.instanceOf(ComicState.class));
42 public void comicIsParsedCorrectly() {
43 ComicState comicState = (ComicState) smbcFilter.filter(htmlState);
44 assertThat(comicState.comics(), hasSize(1));
45 Comic comic = comicState.comics().get(0);
46 assertThat(comic.title(), is(""));
47 assertThat(comic.strips(), hasSize(2));
48 assertThat(comic.strips().get(0).imageUrl(), is("http://www.smbc-comics.com/comics/1496144390-soonish6%20(1).png"));
49 assertThat(comic.strips().get(0).comment(), is("It's not an old man rant if you put it in the mouths of children!"));
50 assertThat(comic.strips().get(1).imageUrl(), is("http://smbc-comics.com/comics/1496144435-soonish6after.png"));
51 assertThat(comic.strips().get(1).comment(), is(""));