2008-07-07 19:38:17 -04:00
|
|
|
|
|
|
|
package net.sourceforge.filebot.web;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
|
|
|
import java.net.URL;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import org.junit.BeforeClass;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
|
|
|
|
public class AnidbClientTest {
|
|
|
|
|
2008-07-08 14:26:18 -04:00
|
|
|
/**
|
|
|
|
* 74 episodes
|
|
|
|
*/
|
|
|
|
private static HyperLink monsterSearchResult;
|
2008-07-07 19:38:17 -04:00
|
|
|
|
2008-07-08 14:26:18 -04:00
|
|
|
/**
|
|
|
|
* 45 episodes, direct result page (short_link)
|
|
|
|
*/
|
|
|
|
private static HyperLink twelvekingdomsSearchResult;
|
2008-07-07 19:38:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
public static void setUpBeforeClass() throws Exception {
|
2008-07-08 14:26:18 -04:00
|
|
|
monsterSearchResult = new HyperLink("Monster", new URL("http://anidb.net/perl-bin/animedb.pl?show=anime&aid=1539"));
|
|
|
|
twelvekingdomsSearchResult = new HyperLink("Juuni Kokuki", new URL("http://anidb.net/a26"));
|
2008-07-07 19:38:17 -04:00
|
|
|
}
|
|
|
|
|
2008-07-08 14:26:18 -04:00
|
|
|
private AnidbClient anidb = new AnidbClient();
|
|
|
|
|
|
|
|
|
2008-07-07 19:38:17 -04:00
|
|
|
@Test
|
|
|
|
public void search() throws Exception {
|
|
|
|
List<SearchResult> results = anidb.search("one piece");
|
|
|
|
|
|
|
|
HyperLink result = (HyperLink) results.get(0);
|
|
|
|
|
|
|
|
assertEquals("One Piece", result.getName());
|
|
|
|
assertEquals("http://anidb.net/perl-bin/animedb.pl?show=anime&aid=69", result.getURL().toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void searchResultPageRedirect() throws Exception {
|
|
|
|
List<SearchResult> results = anidb.search("twelve kingdoms");
|
|
|
|
|
|
|
|
assertEquals(1, results.size());
|
|
|
|
|
|
|
|
HyperLink result = (HyperLink) results.get(0);
|
|
|
|
|
|
|
|
assertEquals("Juuni Kokuki", result.getName());
|
|
|
|
assertEquals("http://anidb.net/a26", result.getURL().toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getEpisodeListAll() throws Exception {
|
2008-07-08 14:26:18 -04:00
|
|
|
List<Episode> list = anidb.getEpisodeList(monsterSearchResult);
|
2008-07-07 19:38:17 -04:00
|
|
|
|
|
|
|
assertEquals(74, list.size());
|
|
|
|
|
|
|
|
Episode first = list.get(0);
|
|
|
|
|
2009-01-24 19:08:57 -05:00
|
|
|
assertEquals("Monster", first.getSeriesName());
|
2008-07-07 19:38:17 -04:00
|
|
|
assertEquals("Herr Dr. Tenma", first.getTitle());
|
2009-01-04 13:28:28 -05:00
|
|
|
assertEquals("1", first.getEpisodeNumber());
|
|
|
|
assertEquals(null, first.getSeasonNumber());
|
2008-07-07 19:38:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getEpisodeListAllShortLink() throws Exception {
|
2008-07-08 14:26:18 -04:00
|
|
|
List<Episode> list = anidb.getEpisodeList(twelvekingdomsSearchResult);
|
2008-07-07 19:38:17 -04:00
|
|
|
|
|
|
|
assertEquals(45, list.size());
|
|
|
|
|
|
|
|
Episode first = list.get(0);
|
|
|
|
|
2009-01-24 19:08:57 -05:00
|
|
|
assertEquals("Juuni Kokuki", first.getSeriesName());
|
2008-07-07 19:38:17 -04:00
|
|
|
assertEquals("Shadow of the Moon, The Sea of Shadow - Chapter 1", first.getTitle());
|
2009-01-04 13:28:28 -05:00
|
|
|
assertEquals("1", first.getEpisodeNumber());
|
|
|
|
assertEquals(null, first.getSeasonNumber());
|
2008-07-07 19:38:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getEpisodeListLink() throws Exception {
|
2008-07-08 14:26:18 -04:00
|
|
|
assertEquals(monsterSearchResult.getURL().toString(), anidb.getEpisodeListLink(monsterSearchResult).toURL().toString());
|
2008-07-07 19:38:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|