package com.jakewharton.trakt.services;

import java.util.Calendar;
import java.util.List;
import com.jakewharton.trakt.BaseTestCase;
import com.jakewharton.trakt.entities.CalendarDate;
import com.jakewharton.trakt.entities.TvShow;
import com.jakewharton.trakt.entities.TvShowEpisode;
import com.jakewharton.trakt.entities.TvShowSeason;
import com.jakewharton.trakt.entities.CalendarDate.CalendarTvShowEpisode;

public class UserServiceTest extends BaseTestCase {
	public void test_calendarShows() {
		Calendar d_2002_09_22 = Calendar.getInstance();
		d_2002_09_22.set(2004, 8, 22, 0, 0, 0);
		
		List<CalendarDate> dates = getManager().userService().calendarShows("JakeWharton").date(d_2002_09_22.getTime()).days(1).fire();
		assertNotNull("Result list was null.", dates);
		assertFalse("Result list was empty.", dates.isEmpty());
		
		CalendarDate date = dates.get(0);
		assertNotNull("First result was null.", date);
		
		List<CalendarTvShowEpisode> dateEpisodes = date.getEpisodes();
		assertNotNull("Date episode list was null.", dateEpisodes);
		assertFalse("Date episode list was empty.", dateEpisodes.isEmpty());
		
		CalendarTvShowEpisode dateEpisode = dateEpisodes.get(0);
		assertNotNull("Date episode was null.", dateEpisode);
		
		TvShowEpisode showEpisode = dateEpisode.getEpisode();
		assertNotNull("Show episode was null.", showEpisode);
		assertNotNull("Show season was null.", showEpisode.getSeason());
		assertEquals("Show season does not match.", showEpisode.getSeason().intValue(), 1);
		assertNotNull("Show number was null.", showEpisode.getNumber());
		assertEquals("Show number does not match.", showEpisode.getNumber().intValue(), 1);
		assertNotNull("Show title was null.", showEpisode.getTitle());
		assertEquals("Show title does not match.", showEpisode.getTitle(), "Pilot (1)");
		
		TvShow show = dateEpisode.getShow();
		assertNotNull("Show was null.", show);
		assertNotNull("Show title was null.", show.getTitle());
		assertEquals("Show title does not match.", show.getTitle(), "Lost");
	}
	
	public void test_libraryShowsWatched() {
		List<TvShow> shows = getManager().userService().libraryShowsWatched("JakeWharton").fire();
		assertNotNull("Result list was null.", shows);
		assertFalse("Result list was empty.", shows.isEmpty());
		
		TvShow show = shows.get(0);
		assertNotNull("First result was null.", show);
		assertNotNull("Show title was null.", show.getTitle());
		assertEquals("Show title does not match.", show.getTitle(), "South Park");
		assertNotNull("Show year was null.", show.getYear());
		assertEquals("Show year does not match.", show.getYear().intValue(), 1997);
		assertNotNull("Show URL was null.", show.getUrl());
		assertNotNull("Show IMDB ID was null.", show.getImdbId());
		assertEquals("Show IMDB ID does not match.", show.getImdbId(), "tt0121955");
		assertNotNull("Show TVDB ID was null.", show.getTvdbId());
		assertEquals("Show TVDB ID does not match.", show.getTvdbId(), "75897");
		assertNotNull("Show TV Rage ID was null.", show.getTvRageId());
		assertEquals("Show TV Rage ID does not match.", show.getTvRageId(), "5266");
		assertNotNull("Show images was null.", show.getImages());
		assertNotNull("Show poster image was null.", show.getImages().getPoster());
		assertNotNull("Show fanart image was null.", show.getImages().getFanart());
		
		List<TvShowSeason> seasons = show.getSeasons();
		assertNotNull("Show seasons list was null.", seasons);
		assertFalse("Show seasons list was empty.", seasons.isEmpty());
		
		TvShowSeason season = seasons.get(0);
		assertNotNull("Show first season was null.", season);
		assertNotNull("Show season number was null.", season.getSeason());
		
		TvShowSeason.Episodes seasonEpisodes = season.getEpisodes();
		assertNotNull("Show episodes was null.", seasonEpisodes);
		assertNotNull("Show episodes list was null.", seasonEpisodes.getNumbers());
		assertFalse("Show episodes list was empty.", seasonEpisodes.getNumbers().isEmpty());
	}
}

@@ -1451,32 +1451,35 @@
 oes not match.%22,
+ 1,
  showEpisode.get
@@ -1489,35 +1489,32 @@
 son().intValue()
-, 1
 );%0A%09%09assertNotNu
@@ -1604,32 +1604,35 @@
 oes not match.%22,
+ 1,
  showEpisode.get
@@ -1654,76 +1654,8 @@
 ue()
-, 1);%0A%09%09assertNotNull(%22Show title was null.%22, showEpisode.getTitle()
 );%0A%09
@@ -1693,24 +1693,37 @@
 not match.%22,
+ %22Pilot (1)%22,
  showEpisode
@@ -1733,29 +1733,16 @@
 tTitle()
-, %22Pilot (1)%22
 );%0A%09%09%0A%09%09
@@ -1823,66 +1823,8 @@
 w);%0A
-%09%09assertNotNull(%22Show title was null.%22, show.getTitle());%0A
 %09%09as
@@ -1855,32 +1855,40 @@
 oes not match.%22,
+ %22Lost%22,
  show.getTitle()
@@ -1887,24 +1887,16 @@
 tTitle()
-, %22Lost%22
 );%0A%09%7D%0A%09%0A
@@ -2223,66 +2223,8 @@
 w);%0A
-%09%09assertNotNull(%22Show title was null.%22, show.getTitle());%0A
 %09%09as
@@ -2255,32 +2255,46 @@
 oes not match.%22,
+ %22South Park%22,
  show.getTitle()
@@ -2293,30 +2293,16 @@
 tTitle()
-, %22South Park%22
 );%0A%09%09ass
@@ -2496,179 +2496,57 @@
 sert
-NotNull(%22Show IMDB ID was null.%22, show.getImdbId());%0A%09%09assertEquals(%22Show IMDB ID does not match.%22, show.getImdbId(), %22tt0121955%22);%0A%09%09assertNotNull(%22Show TVDB ID was null.
+Equals(%22Show IMDB ID does not match.%22, %22tt0121955
 %22, s
@@ -2548,26 +2548,26 @@
 5%22, show.get
-Tv
+Im
 dbId());%0A%09%09a
@@ -2614,78 +2614,14 @@
 .%22, 
-show.getTvdbId(), %2275897%22);%0A%09%09assertNotNull(%22Show TV Rage ID was null.
+%2275897
 %22, s
@@ -2625,28 +2625,26 @@
 , show.getTv
-Rage
+db
 Id());%0A%09%09ass
@@ -2679,32 +2679,40 @@
 oes not match.%22,
+ %225266%22,
  show.getTvRageI
@@ -2714,24 +2714,16 @@
 RageId()
-, %225266%22
 );%0A%09%09ass

Correct order of expected and actual values.