1 package net.pterodactylus.rhynodge.filters.comics;
3 import java.io.IOException;
5 import net.pterodactylus.rhynodge.Filter;
6 import net.pterodactylus.rhynodge.State;
7 import net.pterodactylus.rhynodge.filters.ResourceLoader;
8 import net.pterodactylus.rhynodge.states.ComicState;
9 import net.pterodactylus.rhynodge.states.ComicState.Comic;
10 import net.pterodactylus.rhynodge.states.HtmlState;
12 import org.hamcrest.MatcherAssert;
13 import org.hamcrest.Matchers;
14 import org.jsoup.nodes.Document;
15 import org.junit.Test;
18 * Unit test for {@link SaturdayMorningBreakfastCerealComicFilter}.
20 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
22 public class SaturdayMorningBreakfastCerealComicFilterTest {
24 private final Filter smbcFilter = new SaturdayMorningBreakfastCerealComicFilter();
25 private final HtmlState htmlState;
27 public SaturdayMorningBreakfastCerealComicFilterTest() throws IOException {
28 Document document = ResourceLoader.loadDocument(SinfestComicFilter.class, "saturday-morning-breakfast-cereal.html", "http://www.smbc-comics.com/");
29 htmlState = new HtmlState("http://www.smbc-comics.com/", document);
33 public void htmlCanBeParsed() {
34 State state = smbcFilter.filter(htmlState);
35 MatcherAssert.assertThat(state, Matchers.instanceOf(ComicState.class));
39 public void comicIsParsedCorrectly() {
40 ComicState comicState = (ComicState) smbcFilter.filter(htmlState);
41 MatcherAssert.assertThat(comicState.comics(), Matchers.hasSize(1));
42 Comic comic = comicState.comics().get(0);
43 MatcherAssert.assertThat(comic.title(), Matchers.is(""));
44 MatcherAssert.assertThat(comic.strips(), Matchers.hasSize(2));
45 MatcherAssert.assertThat(comic.strips().get(0).imageUrl(), Matchers.is("http://www.smbc-comics.com/comics/1430750631-20150504.png"));
46 MatcherAssert.assertThat(comic.strips().get(0).comment(), Matchers.is("And they say there's no use for a liberal arts degree!"));
47 MatcherAssert.assertThat(comic.strips().get(1).imageUrl(), Matchers.is("http://smbc-comics.com/comics/1430750631-20150504after.png"));
48 MatcherAssert.assertThat(comic.strips().get(1).comment(), Matchers.is(""));