--- /dev/null
+package net.pterodactylus.rhynodge.filters.comics;
+
+import java.io.IOException;
+
+import net.pterodactylus.rhynodge.Filter;
+import net.pterodactylus.rhynodge.State;
+import net.pterodactylus.rhynodge.filters.ResourceLoader;
+import net.pterodactylus.rhynodge.states.ComicState;
+import net.pterodactylus.rhynodge.states.ComicState.Comic;
+import net.pterodactylus.rhynodge.states.HtmlState;
+
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.Matchers;
+import org.jsoup.nodes.Document;
+import org.junit.Test;
+
+/**
+ * Unit test for {@link SaturdayMorningBreakfastCerealComicFilter}.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class SaturdayMorningBreakfastCerealComicFilterTest {
+
+ private final Filter smbcFilter = new SaturdayMorningBreakfastCerealComicFilter();
+ private final HtmlState htmlState;
+
+ public SaturdayMorningBreakfastCerealComicFilterTest() throws IOException {
+ Document document = ResourceLoader.loadDocument(SinfestComicFilter.class, "saturday-morning-breakfast-cereal.html", "http://www.smbc-comics.com/");
+ htmlState = new HtmlState("http://www.smbc-comics.com/", document);
+ }
+
+ @Test
+ public void htmlCanBeParsed() {
+ State state = smbcFilter.filter(htmlState);
+ MatcherAssert.assertThat(state, Matchers.instanceOf(ComicState.class));
+ }
+
+ @Test
+ public void comicIsParsedCorrectly() {
+ ComicState comicState = (ComicState) smbcFilter.filter(htmlState);
+ MatcherAssert.assertThat(comicState.comics(), Matchers.hasSize(1));
+ Comic comic = comicState.comics().get(0);
+ MatcherAssert.assertThat(comic.title(), Matchers.is(""));
+ MatcherAssert.assertThat(comic.strips(), Matchers.hasSize(2));
+ MatcherAssert.assertThat(comic.strips().get(0).imageUrl(), Matchers.is("http://www.smbc-comics.com/comics/1430750631-20150504.png"));
+ MatcherAssert.assertThat(comic.strips().get(0).comment(), Matchers.is("And they say there's no use for a liberal arts degree!"));
+ MatcherAssert.assertThat(comic.strips().get(1).imageUrl(), Matchers.is("http://smbc-comics.com/comics/1430750631-20150504after.png"));
+ MatcherAssert.assertThat(comic.strips().get(1).comment(), Matchers.is(""));
+ }
+
+}
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head><script>
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+ })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+ ga('create', 'UA-3727700-1', 'auto');
+ ga('send', 'pageview');
+
+</script>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>Saturday Morning Breakfast Cereal</title>
+ <link href="smbc.css" rel="stylesheet" type="text/css" />
+ <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
+ <link rel="icon" href="/favicon.ico" type="image/x-icon">
+ <script>
+ function getLink(matchClass) {
+ var elems = document.getElementsByTagName('a'), i;
+ var linkname = "";
+ for (i in elems) {
+ if(((' ' + elems[i].className + ' ').indexOf(' ' + matchClass + ' ')
+ > -1) && (linkname == "")) {
+ linkname = elems[i].href;
+ }
+ }
+ return linkname;
+ }
+ function leftArrowPressed() {
+ var prev = getLink("prev");
+ window.location = prev;
+ }
+
+ function rightArrowPressed() {
+ var next = getLink("next");
+ window.location = next;
+ }
+
+ function randomPressed() {
+ window.location = "http://smbc-comics.com/index.php?id=3346";
+ }
+
+ document.onkeydown = function(evt) {
+ evt = evt || window.event;
+ switch (evt.keyCode) {
+ case 37:
+ leftArrowPressed();
+ break;
+ case 89:
+ leftArrowPressed();
+ break;
+ case 90:
+ leftArrowPressed();
+ break;
+ case 39:
+ rightArrowPressed();
+ break;
+ case 67:
+ rightArrowPressed();
+ break;
+ case 86:
+ toggleBlock('aftercomic');
+ break;
+ case 88:
+ randomPressed();
+ break;
+ }
+ };
+
+ </script>
+ <!-- End Project Wonderful Ad Box Loader -->
+</head>
+<body>
+<div id="header">
+ <a id="logo" href="index.php"></a>
+ <div id="leaderboard"><iframe id='aeb4facd' name='aeb4facd' src='http://162.218.115.228/delivery/afr.php?n=aeb4facd&zoneid=142&target=_blank&cb=INSERT_RANDOM_NUMBER_HERE' frameborder='0' scrolling='no' width='728' height='90' allowtransparency='true'><a href='http://162.218.115.228/delivery/ck.php?n=a613cf58&cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://162.218.115.228/delivery/avw.php?zoneid=142&cb=INSERT_RANDOM_NUMBER_HERE&n=a613cf58' border='0' alt='' /></a></iframe>
+ <script type='text/javascript' src='http://162.218.115.228/delivery/ag.php'></script></div>
+ <div id="menu">
+ <a href="archives.php" id="archives"></a>
+ <a href="mailto:zach@smbc-comics.com" id="contact"></a>
+ <a href="http://www.smbc-comics.com/smbcforum" id="forum"></a>
+ <a href="http://smbc.myshopify.com/" id="store"></a>
+ </div>
+ <a id="patreon" href="http://www.patreon.com/ZachWeinersmith"></a>
+</div>
+<div id="wrapper">
+ <div id="comicleft"><div id="navtop">
+ <div class="nav"><a href="/index.php?id=1" class="first" rel="start"></a><a href="/index.php?id=3724" class="prev" rel="prev"></a><a href="http://smbc-comics.com/rss.php" class="rss" rel="rss"></a><div class="navspace2"><div class="nextdis"></div><div class="lastdis"></div></div></div> <div class="navmid"><a class="midprev" href="index.php?id=3724"></a><a class="random" href="index.php?id=3346"></a><a class="midnext"></a></div>
+ </div>
+ <div style="clear:both;"></div>
+ <div id="comicbody"><img title="And they say there's no use for a liberal arts degree!" src="comics/1430750631-20150504.png" id="comic" border="0" /><br /></a></div><div style="clear:both;"></div>
+ <div id="navbottom">
+ <div class="nav"><a href="/index.php?id=1" class="first" rel="start"></a><a href="/index.php?id=3724" class="prev" rel="prev"></a><a href="http://smbc-comics.com/rss.php" class="rss" rel="rss"></a><div class="navspace2"><div class="nextdis"></div><div class="lastdis"></div></div></div> <div class="navmid"><a class="midprev" href="index.php?id=3724"></a><a class="random" href="index.php?id=3346"></a><a class="midnext"></a></div>
+ </div>
+ <div id="ibar"></div>
+ <script src="http://cdn.thehiveworks.com/jumpbar.js"></script>
+ <div id="sharewrap">
+ <div id="sharebuttons">
+ <a id="twittershare" onclick="window.open('https://twitter.com/share?url=http://smbc-comics.com/index.php?id=3725&text=Saturday Morning Breakfast Cereal%20%23smbc%20%23hiveworks','name','width=600,height=400')"></a><a id="facebookshare" onclick="window.open('https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fwww.smbc-comics.com%2F%3Fid%3D3725&t=Saturday+Morning+Breakfast+Cereal','name','width=600,height=400')"></a><a id="redditshare" onclick="window.location = '//www.reddit.com/submit?url=www.smbc-comics.com%2F%3Fid%3D3725'; return false"></a><a id="pinterestshare" onclick="window.open('http://www.pinterest.com/pin/create/button/?url=http%3A%2F%2Fwww.smbc-comics.com%2F%3Fid%3D3725&media=http%3A%2F%2Fwww.smbc-comics.com%2Fcomics%2F1430750631-20150504.png&description=Saturday%20Morning%20Breakfast%20Cereal','name','width=600,height=400')"></a><a id="stumbleuponshare" onclick="window.open('http://www.stumbleupon.com/badge/?url=http%3A%2F%2Fwww.smbc-comics.com%2F%3Fid%3D3725%23comic','name','width=600,height=400')"></a>
+ </div>
+ <script>
+
+ function getBlock(name) {
+ if (document.getElementById) {
+ return document.getElementById(name);
+ } else if (document.all) {
+ return document.all[name];
+ } else if (document.layers) {
+ return document.layers[name];
+ }
+ }
+ function getStyle(name) {
+ return getBlock(name).style;
+ }
+
+ function hideBlock(name) {
+ getStyle(name).display="none";
+ }
+
+ function showBlock(name) {
+ getStyle(name).display="";
+ }
+
+ function toggleBlock(name){
+ if(getStyle(name).display == "none"){
+ showBlock(name);
+ }else{
+ hideBlock(name);
+ }
+ }
+ </script><a id="extracomic" onclick='toggleBlock("aftercomic")'></a>
+ <div id="aftercomic" onclick='toggleBlock("aftercomic")' style="display:none;">
+ <img src='http://smbc-comics.com/comics/1430750631-20150504after.png'>
+ </div>
+ </div>
+ <div style="clear:both; width:700px; height:50px;"></div>
+ <div id="blogarea">
+ <div id="blogtop"></div>
+ <div id="newsarea"><div class="cc-newscontent"><div class="cc-publishtime">May 4, 2015<br /></div><p> Oh, that? That's just ALL OF STARPOCALYPSE FOR FREE!</p>
+ <p> </p>
+ <p><iframe width="400" height="225" src="https://www.youtube.com/embed/9LvJ7B29UpM" frameborder="0" allowfullscreen=""></iframe></p></div><div style="padding:10px;clear:both;"><a href="http://www.smbc-comics.com/smbcforum/viewforum.php?f=40">Discuss this comic in the forum</a></div><div class="cc-newscontent"><div class="cc-publishtime">May 3, 2015<br /></div></div><div style="padding:10px;clear:both;"><a href="http://www.smbc-comics.com/smbcforum/viewforum.php?f=40">Discuss this comic in the forum</a></div><div class="cc-newscontent"><div class="cc-publishtime">May 2, 2015<br /></div></div><div style="padding:10px;clear:both;"><a href="http://www.smbc-comics.com/smbcforum/viewforum.php?f=40">Discuss this comic in the forum</a></div><div class="cc-newscontent"><div class="cc-publishtime">May 1, 2015<br /></div></div><div style="padding:10px;clear:both;"><a href="http://www.smbc-comics.com/smbcforum/viewforum.php?f=40">Discuss this comic in the forum</a></div><div class="cc-newscontent"><div class="cc-publishtime">April 30, 2015<br /></div></div><div style="padding:10px;clear:both;"><a href="http://www.smbc-comics.com/smbcforum/viewforum.php?f=40">Discuss this comic in the forum</a></div></div></div>
+ <div id="blogright">
+ <div id="newinstore">
+ <div id="storetop"></div>
+ <a href="http://smbc.myshopify.com/collections/frontpage/products/marxist-shirt"><img src="http://i.imgur.com/T9BvdED.png" /></a><a href="http://smbc.myshopify.com/collections/frontpage/products/science-shirt"><img src="images/store shirt5.png" /></a> </div>
+ <div id="videosandstuff"><iframe src="//player.vimeo.com/video/81175630
+" width="300" height="206" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen style="margin-top:110px; margin-left:28px;"></iframe></div>
+ </div>
+
+ <div style="clear:both; width:750px;height:20px;"></div>
+ <div id="footer">
+ <a id="footarchives" href="archives.php"></a><a id="footcontact" href="mailto:zach@smbc-comics.com"></a><a id="footforum" href="http://www.smbc-comics.com/smbcforum"></a><a id="footstore" href="http://smbc.myshopify.com/"></a><a id="foothome" href="index.php"></a><a id="footrss" href="rss.php"></a><a id="footprivacy" href="privacy.php"></a><a id="footdomain" href="index.php"></a>
+ </div>
+ </div>
+ <div id="rightside">
+ <div id="boxad"><iframe id='ac4bea1c' name='ac4bea1c' src='http://162.218.115.228/delivery/afr.php?n=ac4bea1c&zoneid=143&target=_blank&cb=INSERT_RANDOM_NUMBER_HERE' frameborder='0' scrolling='no' width='300' height='250' allowtransparency='true'><a href='http://162.218.115.228/delivery/ck.php?n=a72c4e2c&cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://162.218.115.228/delivery/avw.php?zoneid=143&cb=INSERT_RANDOM_NUMBER_HERE&n=a72c4e2c' border='0' alt='' /></a></iframe>
+ <script type='text/javascript' src='http://162.218.115.228/delivery/ag.php'></script></div>
+ <div id="linkarea">
+ <div id="linksleft">
+ <div><a href="http://zachweinersmith.tumblr.com/">Tumblr</a></div>
+ <div> </div>
+ <div><a href="http://cereales.lapin.org/">SMBC en Francais</a></div>
+ <div class="linkdiv"> </div>
+ <div class="linkdiv"><a href="http://bahfest.com/">BAHFest</a></div>
+ <div class="linkdiv"> </div>
+ <div><a href="http://www.weinersmith.com/">WEINERSMITH</a><a href="http://www.weinersmith.com/"><br />
+ <br />
+ </a></div>
+ <div><a href="http://www.weeklyweinersmith.com/">WEEKLY WEINERSMITH</a></div>
+ <div class="linkdiv"> </div>
+ <div><a href="http://www.theweinerworks.com/">THE WEINERWORKS</a></div> <a href="http://www.thehiveworks.com/" id="hiveworks"></a>
+ </div>
+ <div id="linksright">
+ <a href="mailto:zach@smbc-comics.com">EMAIL ZACH</a>
+ <a href="http://www.facebook.com/smbccomics">FACEBOOK FAN CLUB</a>
+ </div>
+ <a href="https://www.facebook.com/smbccomics" id="smbconfacebook"></a>
+ <div id="upcoming">
+ <img src="images/upcomingappearances.jpg" /><br />
+ <p style="text-align: center;"><b>BAHFest West 2015</b></p>
+ <p style="text-align: center;">Oct 22, San Francisco</p>
+ <p style="text-align: center;"><strong>BAHFest East 2015</strong></p>
+ <p style="text-align: center;">September 19, MIT</p>
+ <p style="text-align: center;"><strong>BAHFest Seattle 2015</strong></p>
+ <p style="text-align: center;">Date TBD, Seattle</p> </div>
+ </div>
+ <a id="zachontwitter" href="https://twitter.com/ZachWeiner"></a>
+ <div id="twitterbox">
+ <a class="twitter-timeline" width="355px" href="https://twitter.com/ZachWeiner" data-widget-id="352280515333746688">Tweets by @ZachWeiner</a>
+ <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
+ </div>
+ <div id="towerarea">
+ <div class="tower"><iframe id='a2150812' name='a2150812' src='http://162.218.115.228/delivery/afr.php?n=a2150812&zoneid=144&target=_blank&cb=INSERT_RANDOM_NUMBER_HERE' frameborder='0' scrolling='no' width='160' height='600' allowtransparency='true'><a href='http://162.218.115.228/delivery/ck.php?n=abf320e5&cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://162.218.115.228/delivery/avw.php?zoneid=144&cb=INSERT_RANDOM_NUMBER_HERE&n=abf320e5' border='0' alt='' /></a></iframe>
+ <script type='text/javascript' src='http://162.218.115.228/delivery/ag.php'></script></div>
+ <div class="tower">
+ <!--/* SMBC 160x600 Lower */-->
+
+ <iframe id='aed1444f' name='aed1444f' src='http://162.218.115.228/delivery/afr.php?n=aed1444f&zoneid=145&target=_blank&cb=INSERT_RANDOM_NUMBER_HERE' frameborder='0' scrolling='no' width='160' height='600' allowtransparency='true'><a href='http://162.218.115.228/delivery/ck.php?n=adc7f5c4&cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://162.218.115.228/delivery/avw.php?zoneid=145&cb=INSERT_RANDOM_NUMBER_HERE&n=adc7f5c4' border='0' alt='' /></a></iframe>
+ <script type='text/javascript' src='http://162.218.115.228/delivery/ag.php'></script>
+ </div>
+ </div>
+ <div style="clear:both;"></div>
+ </div>
+ <div style="clear:both;"></div>
+</div>
+</body>
+</html>