1 package net.pterodactylus.rhynodge.filters.torrents;
3 import java.io.IOException;
5 import net.pterodactylus.rhynodge.State;
6 import net.pterodactylus.rhynodge.states.HtmlState;
7 import net.pterodactylus.rhynodge.states.TorrentState;
9 import org.hamcrest.MatcherAssert;
10 import org.hamcrest.Matchers;
11 import org.jsoup.Jsoup;
12 import org.jsoup.nodes.Document;
13 import org.junit.Test;
16 * Unit test for {@link TorrentzEuFilter}.
18 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
20 public class TorrentzEuFilterTest {
22 private final TorrentzEuFilter torrentzEuFilter = new TorrentzEuFilter();
25 public void filterCanExtractAllTorrents() throws IOException {
26 Document document = Jsoup.parse(getClass().getResourceAsStream("torrentz-eu-results.html"), "UTF-8", "http://torrentz.eu/searchA?f=Ubuntu+ISO");
27 HtmlState htmlState = new HtmlState("http://torrentz.eu/searchA?f=Ubuntu+ISO", document);
28 State newState = torrentzEuFilter.filter(htmlState);
29 MatcherAssert.assertThat(newState, Matchers.notNullValue());
30 MatcherAssert.assertThat(newState, Matchers.instanceOf(TorrentState.class));
31 TorrentState torrentState = (TorrentState) newState;
32 MatcherAssert.assertThat(torrentState.torrentFiles(), Matchers.hasSize(2));
33 MatcherAssert.assertThat(torrentState.torrentFiles(), Matchers.contains(
34 TorrentMatcher.isTorrent("Ubuntu 14 04 64Bit ISO File", "981 MB", 0, 1),
35 TorrentMatcher.isTorrent("Ubuntu 14 04 LTS Desktop 64bit ISO", "964 MB", 75, 5)