2014-04-19 02:30:29 -04:00
|
|
|
package net.filebot.web;
|
2008-06-21 19:31:19 -04:00
|
|
|
|
2009-05-17 13:22:44 -04:00
|
|
|
import static org.junit.Assert.*;
|
2008-06-21 19:31:19 -04:00
|
|
|
|
|
|
|
import java.util.List;
|
2014-12-10 13:53:58 -05:00
|
|
|
import java.util.Locale;
|
2008-06-21 19:31:19 -04:00
|
|
|
|
2016-03-06 08:57:16 -05:00
|
|
|
import net.sf.ehcache.CacheManager;
|
|
|
|
|
|
|
|
import org.junit.AfterClass;
|
|
|
|
import org.junit.BeforeClass;
|
2008-06-21 19:31:19 -04:00
|
|
|
import org.junit.Test;
|
|
|
|
|
2015-11-04 03:53:52 -05:00
|
|
|
public class TVMazeClientTest {
|
2014-08-07 05:35:19 -04:00
|
|
|
|
2008-07-08 14:26:18 -04:00
|
|
|
/**
|
|
|
|
* 145 episodes / 7 seasons
|
|
|
|
*/
|
2015-11-04 03:53:52 -05:00
|
|
|
private static TVMazeSearchResult buffySearchResult = new TVMazeSearchResult(427, "Buffy the Vampire Slayer");
|
2014-08-07 05:35:19 -04:00
|
|
|
|
2008-06-21 19:31:19 -04:00
|
|
|
@Test
|
|
|
|
public void search() throws Exception {
|
2015-11-04 03:53:52 -05:00
|
|
|
List<SearchResult> results = client.search("Buffy", Locale.ENGLISH);
|
2014-08-07 05:35:19 -04:00
|
|
|
|
2015-11-04 03:53:52 -05:00
|
|
|
TVMazeSearchResult result = (TVMazeSearchResult) results.get(0);
|
2014-08-07 05:35:19 -04:00
|
|
|
|
2008-07-08 14:26:18 -04:00
|
|
|
assertEquals(buffySearchResult.getName(), result.getName());
|
2015-11-04 03:53:52 -05:00
|
|
|
assertEquals(buffySearchResult.getId(), result.getId());
|
2008-06-21 19:31:19 -04:00
|
|
|
}
|
2014-08-07 05:35:19 -04:00
|
|
|
|
2015-11-04 03:53:52 -05:00
|
|
|
private TVMazeClient client = new TVMazeClient();
|
2014-08-07 05:35:19 -04:00
|
|
|
|
2008-06-21 19:31:19 -04:00
|
|
|
@Test
|
|
|
|
public void getEpisodeList() throws Exception {
|
2015-11-04 03:53:52 -05:00
|
|
|
List<Episode> list = EpisodeUtilities.filterBySeason(client.getEpisodeList(buffySearchResult, SortOrder.Airdate, Locale.ENGLISH), 7);
|
2014-08-07 05:35:19 -04:00
|
|
|
|
2008-07-05 23:17:23 -04:00
|
|
|
assertEquals(22, list.size());
|
2014-08-07 05:35:19 -04:00
|
|
|
|
2008-06-21 19:31:19 -04:00
|
|
|
Episode chosen = list.get(21);
|
2014-08-07 05:35:19 -04:00
|
|
|
|
2009-01-24 19:08:57 -05:00
|
|
|
assertEquals("Buffy the Vampire Slayer", chosen.getSeriesName());
|
2014-12-10 13:53:58 -05:00
|
|
|
assertEquals("1997-03-10", chosen.getSeriesInfo().getStartDate().toString());
|
2008-06-21 19:31:19 -04:00
|
|
|
assertEquals("Chosen", chosen.getTitle());
|
2010-10-24 08:10:30 -04:00
|
|
|
assertEquals("22", chosen.getEpisode().toString());
|
|
|
|
assertEquals("7", chosen.getSeason().toString());
|
2011-08-26 05:01:46 -04:00
|
|
|
assertEquals(null, chosen.getAbsolute());
|
2013-07-13 06:01:33 -04:00
|
|
|
assertEquals("2003-05-20", chosen.getAirdate().toString());
|
2008-06-21 19:31:19 -04:00
|
|
|
}
|
2014-08-07 05:35:19 -04:00
|
|
|
|
2008-06-21 19:31:19 -04:00
|
|
|
@Test
|
|
|
|
public void getEpisodeListAll() throws Exception {
|
2015-11-04 03:53:52 -05:00
|
|
|
List<Episode> list = client.getEpisodeList(buffySearchResult, SortOrder.Airdate, Locale.ENGLISH);
|
2014-08-07 05:35:19 -04:00
|
|
|
|
2014-03-18 16:16:39 -04:00
|
|
|
assertEquals(143, list.size());
|
2014-08-07 05:35:19 -04:00
|
|
|
|
2008-06-21 19:31:19 -04:00
|
|
|
Episode first = list.get(0);
|
2014-08-07 05:35:19 -04:00
|
|
|
|
2009-01-24 19:08:57 -05:00
|
|
|
assertEquals("Buffy the Vampire Slayer", first.getSeriesName());
|
2012-02-13 04:54:57 -05:00
|
|
|
assertEquals("Welcome to the Hellmouth (1)", first.getTitle());
|
|
|
|
assertEquals("1", first.getEpisode().toString());
|
|
|
|
assertEquals("1", first.getSeason().toString());
|
2011-08-26 05:01:46 -04:00
|
|
|
assertEquals(null, first.getAbsolute());
|
2013-07-13 06:01:33 -04:00
|
|
|
assertEquals("1997-03-10", first.getAirdate().toString());
|
2008-06-21 19:31:19 -04:00
|
|
|
}
|
2014-08-07 05:35:19 -04:00
|
|
|
|
2008-07-05 23:17:23 -04:00
|
|
|
@Test
|
|
|
|
public void getEpisodeListLinkAll() throws Exception {
|
2015-11-04 03:53:52 -05:00
|
|
|
assertEquals("http://www.tvmaze.com/shows/427", client.getEpisodeListLink(buffySearchResult).toString());
|
2008-07-05 23:17:23 -04:00
|
|
|
}
|
2014-08-07 05:35:19 -04:00
|
|
|
|
2016-03-06 08:57:16 -05:00
|
|
|
@BeforeClass
|
|
|
|
@AfterClass
|
|
|
|
public static void clearCache() {
|
|
|
|
CacheManager.getInstance().clearAll();
|
|
|
|
}
|
|
|
|
|
2008-06-21 19:31:19 -04:00
|
|
|
}
|