filebot/test/net/filebot/web/TVMazeClientTest.java

71 lines
2.1 KiB
Java
Raw Normal View History

2014-04-19 02:30:29 -04:00
package net.filebot.web;
2016-03-07 01:38:23 -05:00
import static net.filebot.web.EpisodeUtilities.*;
2009-05-17 13:22:44 -04:00
import static org.junit.Assert.*;
import java.util.List;
import java.util.Locale;
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
*/
2016-03-26 13:40:54 -04:00
SearchResult buffySearchResult = new SearchResult(427, "Buffy the Vampire Slayer");
2014-08-07 05:35: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
2016-03-26 13:40:54 -04:00
SearchResult result = 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());
}
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
@Test
public void getEpisodeList() throws Exception {
2016-03-07 01:38:23 -05:00
List<Episode> list = filterBySeason(client.getEpisodeList(buffySearchResult, SortOrder.Airdate, Locale.ENGLISH), 7);
2014-08-07 05:35:19 -04:00
assertEquals(22, list.size());
2014-08-07 05:35:19 -04:00
Episode chosen = list.get(21);
2014-08-07 05:35:19 -04:00
assertEquals("Buffy the Vampire Slayer", chosen.getSeriesName());
assertEquals("1997-03-10", chosen.getSeriesInfo().getStartDate().toString());
assertEquals("Chosen", chosen.getTitle());
assertEquals("22", chosen.getEpisode().toString());
assertEquals("7", chosen.getSeason().toString());
assertEquals(null, chosen.getAbsolute());
assertEquals("2003-05-20", chosen.getAirdate().toString());
assertEquals("40175", chosen.getId().toString());
}
2014-08-07 05:35: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
assertEquals(143, list.size());
2014-08-07 05:35:19 -04:00
Episode first = list.get(0);
2014-08-07 05:35:19 -04: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());
assertEquals(null, first.getAbsolute());
assertEquals("1997-03-10", first.getAirdate().toString());
assertEquals("40033", first.getId().toString());
}
2014-08-07 05:35:19 -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());
}
2014-08-07 05:35:19 -04:00
}