TV Episodes

master
Stuart Boston 11 years ago
parent f713bde372
commit 9693aa458d

@ -20,7 +20,30 @@
package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.MovieDbException;
import static com.omertron.themoviedbapi.methods.AbstractMethod.MAPPER;
import com.omertron.themoviedbapi.model.StatusCode;
import com.omertron.themoviedbapi.model.artwork.Artwork;
import com.omertron.themoviedbapi.model.media.MediaCreditList;
import com.omertron.themoviedbapi.model.media.MediaState;
import com.omertron.themoviedbapi.model.media.Video;
import com.omertron.themoviedbapi.model.person.ExternalID;
import com.omertron.themoviedbapi.model.tv.TVEpisodeInfo;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import com.omertron.themoviedbapi.tools.ApiUrl;
import com.omertron.themoviedbapi.tools.HttpTools;
import com.omertron.themoviedbapi.tools.MethodBase;
import com.omertron.themoviedbapi.tools.MethodSub;
import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.PostBody;
import com.omertron.themoviedbapi.tools.PostTools;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperChanges;
import com.omertron.themoviedbapi.wrapper.WrapperImages;
import com.omertron.themoviedbapi.wrapper.WrapperVideos;
import java.io.IOException;
import java.net.URL;
import org.slf4j.LoggerFactory;
import org.yamj.api.common.exception.ApiExceptionType;
/**
* Class to hold the TV Methods
@ -53,8 +76,23 @@ public class TmdbTVEpisodes extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public String getEpisodeInfo(int tvID, int seasonNumber, int episodeNumber, String language, String... appendToResponse) throws MovieDbException {
return null;
public TVEpisodeInfo getEpisodeInfo(int tvID, int seasonNumber, int episodeNumber, String language, String... appendToResponse) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, tvID);
parameters.add(Param.SEASON_NUMBER, seasonNumber);
parameters.add(Param.EPISODE_NUMBER, episodeNumber);
parameters.add(Param.LANGUAGE, language);
parameters.add(Param.APPEND, appendToResponse);
URL url = new ApiUrl(apiKey, MethodBase.EPISODE).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, TVEpisodeInfo.class);
} catch (IOException ex) {
LoggerFactory.getLogger("test").warn("{}", ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get TV Episode Info", url, ex);
}
}
/**
@ -66,8 +104,20 @@ public class TmdbTVEpisodes extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public String getEpisodeChanges(int episodeID, String startDate, String endDate) throws MovieDbException {
return null;
public WrapperChanges getEpisodeChanges(int episodeID, String startDate, String endDate) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, episodeID);
parameters.add(Param.START_DATE, startDate);
parameters.add(Param.END_DATE, endDate);
URL url = new ApiUrl(apiKey, MethodBase.EPISODE).subMethod(MethodSub.CHANGES).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, WrapperChanges.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get changes", url, ex);
}
}
/**
@ -83,8 +133,21 @@ public class TmdbTVEpisodes extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public String getEpisodeAccountState(int tvID, int seasonNumber, int episodeNumber, String sessionID) throws MovieDbException {
return null;
public MediaState getEpisodeAccountState(int tvID, int seasonNumber, int episodeNumber, String sessionID) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, tvID);
parameters.add(Param.SESSION_ID, sessionID);
parameters.add(Param.SEASON_NUMBER, seasonNumber);
parameters.add(Param.EPISODE_NUMBER, episodeNumber);
URL url = new ApiUrl(apiKey, MethodBase.EPISODE).subMethod(MethodSub.ACCOUNT_STATES).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, MediaState.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get account state", url, ex);
}
}
/**
@ -96,8 +159,19 @@ public class TmdbTVEpisodes extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public String getEpisodeCredits(int tvID, int seasonNumber, int episodeNumber) throws MovieDbException {
return null;
public MediaCreditList getEpisodeCredits(int tvID, int seasonNumber, int episodeNumber) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, tvID);
parameters.add(Param.SEASON_NUMBER, seasonNumber);
parameters.add(Param.EPISODE_NUMBER, episodeNumber);
URL url = new ApiUrl(apiKey, MethodBase.EPISODE).subMethod(MethodSub.CREDITS).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, MediaCreditList.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get credits", url, ex);
}
}
/**
@ -111,8 +185,21 @@ public class TmdbTVEpisodes extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public String getEpisodeExternalID(int tvID, int seasonNumber, int episodeNumber, String language) throws MovieDbException {
return null;
public ExternalID getEpisodeExternalID(int tvID, int seasonNumber, int episodeNumber, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, tvID);
parameters.add(Param.SEASON_NUMBER, seasonNumber);
parameters.add(Param.EPISODE_NUMBER, episodeNumber);
parameters.add(Param.LANGUAGE, language);
URL url = new ApiUrl(apiKey, MethodBase.EPISODE).subMethod(MethodSub.EXTERNAL_IDS).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, ExternalID.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get external IDs", url, ex);
}
}
/**
@ -125,8 +212,23 @@ public class TmdbTVEpisodes extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public String getEpisodeImages(int tvID, int seasonNumber, int episodeNumber) throws MovieDbException {
return null;
public TmdbResultsList<Artwork> getEpisodeImages(int tvID, int seasonNumber, int episodeNumber) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, tvID);
parameters.add(Param.SEASON_NUMBER, seasonNumber);
parameters.add(Param.EPISODE_NUMBER, episodeNumber);
URL url = new ApiUrl(apiKey, MethodBase.EPISODE).subMethod(MethodSub.IMAGES).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
WrapperImages wrapper = MAPPER.readValue(webpage, WrapperImages.class);
TmdbResultsList<Artwork> results = new TmdbResultsList<Artwork>(wrapper.getAll());
results.copyWrapper(wrapper);
return results;
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get images", url, ex);
}
}
/**
@ -142,8 +244,29 @@ public class TmdbTVEpisodes extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public String postEpisodeRating(int tvID, int seasonNumber, int episodeNumber, int rating, String sessionID, String guestSessionID) throws MovieDbException {
return null;
public StatusCode postEpisodeRating(int tvID, int seasonNumber, int episodeNumber, int rating, String sessionID, String guestSessionID) throws MovieDbException {
if (rating < 0 || rating > RATING_MAX) {
throw new MovieDbException(ApiExceptionType.UNKNOWN_CAUSE, "Rating out of range");
}
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, tvID);
parameters.add(Param.SEASON_NUMBER, seasonNumber);
parameters.add(Param.EPISODE_NUMBER, episodeNumber);
parameters.add(Param.SESSION_ID, sessionID);
parameters.add(Param.GUEST_SESSION_ID, guestSessionID);
URL url = new ApiUrl(apiKey, MethodBase.EPISODE).subMethod(MethodSub.RATING).buildUrl(parameters);
String jsonBody = new PostTools()
.add(PostBody.VALUE, rating)
.build();
String webpage = httpTools.postRequest(url, jsonBody);
try {
return MAPPER.readValue(webpage, StatusCode.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to post rating", url, ex);
}
}
/**
@ -157,8 +280,24 @@ public class TmdbTVEpisodes extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public String getEpisodeVideos(int tvID, int seasonNumber, int episodeNumber, String language) throws MovieDbException {
return null;
public TmdbResultsList<Video> getEpisodeVideos(int tvID, int seasonNumber, int episodeNumber, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, tvID);
parameters.add(Param.SEASON_NUMBER, seasonNumber);
parameters.add(Param.EPISODE_NUMBER, episodeNumber);
parameters.add(Param.LANGUAGE, language);
URL url = new ApiUrl(apiKey, MethodBase.EPISODE).subMethod(MethodSub.VIDEOS).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
WrapperVideos wrapper = MAPPER.readValue(webpage, WrapperVideos.class);
TmdbResultsList<Video> results = new TmdbResultsList<Video>(wrapper.getVideos());
results.copyWrapper(wrapper);
return results;
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get videos", url, ex);
}
}
}

@ -39,7 +39,6 @@ import com.omertron.themoviedbapi.wrapper.WrapperImages;
import com.omertron.themoviedbapi.wrapper.WrapperVideos;
import java.io.IOException;
import java.net.URL;
import org.slf4j.LoggerFactory;
import org.yamj.api.common.exception.ApiExceptionType;
/**
@ -49,8 +48,6 @@ import org.yamj.api.common.exception.ApiExceptionType;
*/
public class TmdbTVSeasons extends AbstractMethod {
private static final int RATING_MAX = 10;
/**
* Constructor
*
@ -84,8 +81,7 @@ public class TmdbTVSeasons extends AbstractMethod {
try {
return MAPPER.readValue(webpage, TVSeasonInfo.class);
} catch (IOException ex) {
LoggerFactory.getLogger("test").warn("{}", ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get TV SeasonInfo", url, ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get TV Season Info", url, ex);
}
}

@ -34,6 +34,8 @@ public class MediaCreditList extends AbstractJsonMapping {
private int id;
@JsonProperty("cast")
private List<MediaCreditCast> cast;
@JsonProperty("guest_stars")
private List<MediaCreditCast> guestStars;
@JsonProperty("crew")
private List<MediaCreditCrew> crew;
@ -61,4 +63,12 @@ public class MediaCreditList extends AbstractJsonMapping {
this.crew = crew;
}
public List<MediaCreditCast> getGuestStars() {
return guestStars;
}
public void setGuestStars(List<MediaCreditCast> guestStars) {
this.guestStars = guestStars;
}
}

@ -36,6 +36,8 @@ public class ExternalID extends AbstractJsonMapping {
private String freebaseMid;
@JsonProperty("freebase_id")
private String freebaseId;
@JsonProperty("tvdb_id")
private String tvdbId;
@JsonProperty("tvrage_id")
private String tvrageId;
@ -79,4 +81,12 @@ public class ExternalID extends AbstractJsonMapping {
this.tvrageId = tvrageId;
}
public String getTvdbId() {
return tvdbId;
}
public void setTvdbId(String tvdbId) {
this.tvdbId = tvdbId;
}
}

@ -20,8 +20,8 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.artwork.Artwork;
import com.omertron.themoviedbapi.enumeration.ArtworkType;
import com.omertron.themoviedbapi.model.artwork.Artwork;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
@ -41,6 +41,8 @@ public class WrapperImages extends AbstractWrapperAll implements Serializable {
private List<Artwork> posters = Collections.emptyList();
@JsonProperty("profiles")
private List<Artwork> profiles = Collections.emptyList();
@JsonProperty("stills")
private List<Artwork> stills = Collections.emptyList();
public List<Artwork> getBackdrops() {
return backdrops;
@ -66,6 +68,10 @@ public class WrapperImages extends AbstractWrapperAll implements Serializable {
this.profiles = profiles;
}
public void setStills(List<Artwork> stills) {
this.stills = stills;
}
/**
* Return a list of all the artwork with their types.
*
@ -102,6 +108,12 @@ public class WrapperImages extends AbstractWrapperAll implements Serializable {
artwork.addAll(profiles);
}
// Add all the stills to the list
if (types.contains(ArtworkType.STILL)) {
updateArtworkType(stills, ArtworkType.STILL);
artwork.addAll(stills);
}
return artwork;
}

@ -20,13 +20,30 @@
package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import static com.omertron.themoviedbapi.AbstractTests.getApiKey;
import static com.omertron.themoviedbapi.AbstractTests.getHttpTools;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.TestID;
import com.omertron.themoviedbapi.enumeration.ArtworkType;
import com.omertron.themoviedbapi.model.StatusCode;
import com.omertron.themoviedbapi.model.artwork.Artwork;
import com.omertron.themoviedbapi.model.media.MediaCreditCast;
import com.omertron.themoviedbapi.model.media.MediaCreditList;
import com.omertron.themoviedbapi.model.media.MediaState;
import com.omertron.themoviedbapi.model.media.Video;
import com.omertron.themoviedbapi.model.person.ExternalID;
import com.omertron.themoviedbapi.model.tv.TVEpisodeInfo;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.apache.commons.lang3.StringUtils;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@ -48,9 +65,9 @@ public class TmdbTVEpisodesTest extends AbstractTests {
doConfiguration();
instance = new TmdbTVEpisodes(getApiKey(), getHttpTools());
TV_IDS.add(new TestID("The Walking Dead", "tt1520211", 1402, "Andrew Lincoln"));
// TV_IDS.add(new TestID("Supernatural", "tt0460681", 1622,"Misha Collins"));
// TV_IDS.add(new TestID("The Big Bang Theory", "tt0898266", 1418,"Kaley Cuoco"));
TV_IDS.add(new TestID("The Walking Dead", "tt1589921", 1402, "Andrew Lincoln"));
TV_IDS.add(new TestID("Supernatural", "tt0713618", 1622, "Misha Collins"));
TV_IDS.add(new TestID("The Big Bang Theory", "tt0775431", 1418, "Kaley Cuoco"));
}
@AfterClass
@ -73,17 +90,19 @@ public class TmdbTVEpisodesTest extends AbstractTests {
@Test
public void testGetEpisodeInfo() throws MovieDbException {
LOG.info("getEpisodeInfo");
int tvID = 0;
int seasonNumber = 0;
int episodeNumber = 0;
int seasonNumber = 1;
int episodeNumber = 1;
String language = LANGUAGE_DEFAULT;
String[] appendToResponse = null;
for (TestID test : TV_IDS) {
String result = instance.getEpisodeInfo(tvID, seasonNumber, episodeNumber, language, appendToResponse);
TVEpisodeInfo result = instance.getEpisodeInfo(test.getTmdb(), seasonNumber, episodeNumber, language, appendToResponse);
assertTrue("No ID", result.getId() > 0);
assertTrue("No name", StringUtils.isNotBlank(result.getName()));
assertTrue("No crew", result.getCrew().size() > 0);
assertTrue("No guest stars", result.getGuestStars().size() > 0);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
@ -94,15 +113,7 @@ public class TmdbTVEpisodesTest extends AbstractTests {
@Test
public void testGetEpisodeChanges() throws MovieDbException {
LOG.info("getEpisodeChanges");
int episodeID = 0;
String startDate = "";
String endDate = "";
for (TestID test : TV_IDS) {
String result = instance.getEpisodeChanges(episodeID, startDate, endDate);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
// This is too empherial to test
}
/**
@ -113,16 +124,15 @@ public class TmdbTVEpisodesTest extends AbstractTests {
@Test
public void testGetEpisodeAccountState() throws MovieDbException {
LOG.info("getEpisodeAccountState");
int tvID = 0;
int seasonNumber = 0;
int episodeNumber = 0;
String sessionID = "";
int seasonNumber = 1;
int episodeNumber = 1;
for (TestID test : TV_IDS) {
String result = instance.getEpisodeAccountState(tvID, seasonNumber, episodeNumber, sessionID);
MediaState result = instance.getEpisodeAccountState(test.getTmdb(), seasonNumber, episodeNumber, getSessionId());
assertNotNull("Null result", result);
assertTrue("Invalid rating", result.getRated() > -2f);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
@ -133,15 +143,27 @@ public class TmdbTVEpisodesTest extends AbstractTests {
@Test
public void testGetEpisodeCredits() throws MovieDbException {
LOG.info("getEpisodeCredits");
int tvID = 0;
int seasonNumber = 0;
int episodeNumber = 0;
int seasonNumber = 1;
int episodeNumber = 1;
for (TestID test : TV_IDS) {
String result = instance.getEpisodeCredits(tvID, seasonNumber, episodeNumber);
MediaCreditList result = instance.getEpisodeCredits(test.getTmdb(), seasonNumber, episodeNumber);
assertNotNull(result);
assertFalse(result.getCast().isEmpty());
boolean found = false;
for (MediaCreditCast p : result.getCast()) {
if (test.getOther().equals(p.getName())) {
found = true;
break;
}
}
assertTrue(test.getOther() + " not found in cast!", found);
assertFalse(result.getCrew().isEmpty());
break;
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
@ -152,16 +174,15 @@ public class TmdbTVEpisodesTest extends AbstractTests {
@Test
public void testGetEpisodeExternalID() throws MovieDbException {
LOG.info("getEpisodeExternalID");
int tvID = 0;
int seasonNumber = 0;
int episodeNumber = 0;
int seasonNumber = 1;
int episodeNumber = 1;
String language = LANGUAGE_DEFAULT;
for (TestID test : TV_IDS) {
String result = instance.getEpisodeExternalID(tvID, seasonNumber, episodeNumber, language);
ExternalID result = instance.getEpisodeExternalID(test.getTmdb(), seasonNumber, episodeNumber, language);
assertEquals("Wrong IMDB ID", test.getImdb(), result.getImdbId());
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
@ -172,15 +193,27 @@ public class TmdbTVEpisodesTest extends AbstractTests {
@Test
public void testGetEpisodeImages() throws MovieDbException {
LOG.info("getEpisodeImages");
int tvID = 0;
int seasonNumber = 0;
int episodeNumber = 0;
int seasonNumber = 1;
int episodeNumber = 1;
boolean foundStill = false;
boolean foundOther = false;
for (TestID test : TV_IDS) {
String result = instance.getEpisodeImages(tvID, seasonNumber, episodeNumber);
TmdbResultsList<Artwork> result = instance.getEpisodeImages(test.getTmdb(), seasonNumber, episodeNumber);
assertFalse("No artwork", result.isEmpty());
for (Artwork artwork : result.getResults()) {
if (artwork.getArtworkType() == ArtworkType.STILL) {
foundStill = true;
continue;
}
foundOther = true;
}
assertTrue("No stills", foundStill);
assertFalse("Something else found!", foundOther);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
@ -191,18 +224,16 @@ public class TmdbTVEpisodesTest extends AbstractTests {
@Test
public void testPostEpisodeRating() throws MovieDbException {
LOG.info("postEpisodeRating");
int tvID = 0;
int seasonNumber = 0;
int episodeNumber = 0;
int rating = 0;
String sessionID = "";
String guestSessionID = "";
int seasonNumber = 1;
int episodeNumber = 1;
String guestSessionID = null;
for (TestID test : TV_IDS) {
String result = instance.postEpisodeRating(tvID, seasonNumber, episodeNumber, rating, sessionID, guestSessionID);
Integer rating = new Random().nextInt(10) + 1;
StatusCode result = instance.postEpisodeRating(test.getTmdb(), seasonNumber, episodeNumber, rating, getSessionId(), guestSessionID);
assertEquals("failed to post rating", 12, result.getCode());
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
@ -213,16 +244,15 @@ public class TmdbTVEpisodesTest extends AbstractTests {
@Test
public void testGetEpisodeVideos() throws MovieDbException {
LOG.info("getEpisodeVideos");
int tvID = 0;
int seasonNumber = 0;
int episodeNumber = 0;
int seasonNumber = 1;
int episodeNumber = 1;
String language = LANGUAGE_DEFAULT;
for (TestID test : TV_IDS) {
String result = instance.getEpisodeVideos(tvID, seasonNumber, episodeNumber, language);
TmdbResultsList<Video> result = instance.getEpisodeVideos(test.getTmdb(), seasonNumber, episodeNumber, language);
LOG.info("Found {} videos", result.getResults().size());
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
}

@ -27,8 +27,6 @@ import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.TestID;
import com.omertron.themoviedbapi.enumeration.ArtworkType;
import com.omertron.themoviedbapi.model.artwork.Artwork;
import com.omertron.themoviedbapi.model.change.ChangeKeyItem;
import com.omertron.themoviedbapi.model.change.ChangeListItem;
import com.omertron.themoviedbapi.model.media.MediaCreditCast;
import com.omertron.themoviedbapi.model.media.MediaCreditList;
import com.omertron.themoviedbapi.model.media.MediaState;
@ -36,14 +34,9 @@ import com.omertron.themoviedbapi.model.media.Video;
import com.omertron.themoviedbapi.model.person.ExternalID;
import com.omertron.themoviedbapi.model.tv.TVSeasonInfo;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import com.omertron.themoviedbapi.tools.MethodBase;
import com.omertron.themoviedbapi.wrapper.WrapperChanges;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.assertEquals;
@ -72,8 +65,8 @@ public class TmdbTVSeasonsTest extends AbstractTests {
instance = new TmdbTVSeasons(getApiKey(), getHttpTools());
TV_IDS.add(new TestID("The Walking Dead", "tt1520211", 1402, "Andrew Lincoln"));
// TV_IDS.add(new TestID("Supernatural", "tt0460681", 1622,"Misha Collins"));
// TV_IDS.add(new TestID("The Big Bang Theory", "tt0898266", 1418,"Kaley Cuoco"));
TV_IDS.add(new TestID("Supernatural", "tt0460681", 1622, "Misha Collins"));
TV_IDS.add(new TestID("The Big Bang Theory", "tt0898266", 1418, "Kaley Cuoco"));
}
@AfterClass
@ -118,29 +111,7 @@ public class TmdbTVSeasonsTest extends AbstractTests {
@Test
public void testGetSeasonChanges() throws MovieDbException {
LOG.info("getSeasonChanges");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String startDate = sdf.format(DateUtils.addDays(new Date(), -14));
String endDate = "";
int maxCheck = 5;
TmdbChanges chgs = new TmdbChanges(getApiKey(), getHttpTools());
List<ChangeListItem> changeList = chgs.getChangeList(MethodBase.TV, null, null, null);
LOG.info("Found {} changes to check, will check maximum of {}", changeList.size(), maxCheck);
int count = 1;
WrapperChanges result;
for (ChangeListItem item : changeList) {
result = instance.getSeasonChanges(item.getId(), startDate, endDate);
for (ChangeKeyItem ci : result.getChangedItems()) {
assertNotNull("Null changes", ci);
}
if (count++ > maxCheck) {
break;
}
}
// This is too empherial to test
}
/**
@ -216,7 +187,7 @@ public class TmdbTVSeasonsTest extends AbstractTests {
public void testGetSeasonImages() throws MovieDbException {
LOG.info("getSeasonImages");
int seasonNumber = 0;
int seasonNumber = 1;
String language = LANGUAGE_DEFAULT;
String[] includeImageLanguage = null;

Loading…
Cancel
Save