Changed return values to include page values
This commit is contained in:
@@ -22,6 +22,7 @@ package com.omertron.themoviedbapi;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.omertron.themoviedbapi.MovieDbException.MovieDbExceptionType;
|
||||
import com.omertron.themoviedbapi.model.*;
|
||||
import com.omertron.themoviedbapi.results.TmdbResultsList;
|
||||
import com.omertron.themoviedbapi.tools.ApiUrl;
|
||||
import static com.omertron.themoviedbapi.tools.ApiUrl.*;
|
||||
import com.omertron.themoviedbapi.tools.WebBrowser;
|
||||
@@ -375,7 +376,7 @@ public class TheMovieDbApi {
|
||||
* @param country
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<AlternativeTitle> getMovieAlternativeTitles(int movieId, String country, String... appendToResponse) throws MovieDbException {
|
||||
public TmdbResultsList<AlternativeTitle> getMovieAlternativeTitles(int movieId, String country, String... appendToResponse) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/alternative_titles");
|
||||
apiUrl.addArgument(PARAM_ID, movieId);
|
||||
|
||||
@@ -389,7 +390,9 @@ public class TheMovieDbApi {
|
||||
String webpage = WebBrowser.request(url);
|
||||
try {
|
||||
WrapperAlternativeTitles wrapper = mapper.readValue(webpage, WrapperAlternativeTitles.class);
|
||||
return wrapper.getTitles();
|
||||
TmdbResultsList<AlternativeTitle> results = new TmdbResultsList<AlternativeTitle>(wrapper.getTitles());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get movie alternative titles: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -404,9 +407,7 @@ public class TheMovieDbApi {
|
||||
* @param movieId
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<Person> getMovieCasts(int movieId, String... appendToResponse) throws MovieDbException {
|
||||
List<Person> people = new ArrayList<Person>();
|
||||
|
||||
public TmdbResultsList<Person> getMovieCasts(int movieId, String... appendToResponse) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/casts");
|
||||
apiUrl.addArgument(PARAM_ID, movieId);
|
||||
|
||||
@@ -417,22 +418,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperMovieCasts wrapper = mapper.readValue(webpage, WrapperMovieCasts.class);
|
||||
|
||||
// Add a cast member
|
||||
for (PersonCast cast : wrapper.getCast()) {
|
||||
Person person = new Person();
|
||||
person.addCast(cast.getId(), cast.getName(), cast.getProfilePath(), cast.getCharacter(), cast.getOrder());
|
||||
people.add(person);
|
||||
}
|
||||
|
||||
// Add a crew member
|
||||
for (PersonCrew crew : wrapper.getCrew()) {
|
||||
Person person = new Person();
|
||||
person.addCrew(crew.getId(), crew.getName(), crew.getProfilePath(), crew.getDepartment(), crew.getJob());
|
||||
people.add(person);
|
||||
}
|
||||
|
||||
return people;
|
||||
TmdbResultsList<Person> results = new TmdbResultsList<Person>(wrapper.getAll());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get movie casts: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -446,7 +434,7 @@ public class TheMovieDbApi {
|
||||
* @param language
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<Artwork> getMovieImages(int movieId, String language, String... appendToResponse) throws MovieDbException {
|
||||
public TmdbResultsList<Artwork> getMovieImages(int movieId, String language, String... appendToResponse) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/images");
|
||||
apiUrl.addArgument(PARAM_ID, movieId);
|
||||
|
||||
@@ -461,7 +449,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperImages wrapper = mapper.readValue(webpage, WrapperImages.class);
|
||||
return wrapper.getAll();
|
||||
TmdbResultsList<Artwork> results = new TmdbResultsList<Artwork>(wrapper.getAll());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get movie images: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -476,7 +466,7 @@ public class TheMovieDbApi {
|
||||
* @param movieId
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<Keyword> getMovieKeywords(int movieId, String... appendToResponse) throws MovieDbException {
|
||||
public TmdbResultsList<Keyword> getMovieKeywords(int movieId, String... appendToResponse) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/keywords");
|
||||
apiUrl.addArgument(PARAM_ID, movieId);
|
||||
|
||||
@@ -487,7 +477,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperMovieKeywords wrapper = mapper.readValue(webpage, WrapperMovieKeywords.class);
|
||||
return wrapper.getKeywords();
|
||||
TmdbResultsList<Keyword> results = new TmdbResultsList<Keyword>(wrapper.getKeywords());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get movie keywords: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -501,7 +493,7 @@ public class TheMovieDbApi {
|
||||
* @param language
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<ReleaseInfo> getMovieReleaseInfo(int movieId, String language, String... appendToResponse) throws MovieDbException {
|
||||
public TmdbResultsList<ReleaseInfo> getMovieReleaseInfo(int movieId, String language, String... appendToResponse) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/releases");
|
||||
apiUrl.addArgument(PARAM_ID, movieId);
|
||||
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
||||
@@ -513,7 +505,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperReleaseInfo wrapper = mapper.readValue(webpage, WrapperReleaseInfo.class);
|
||||
return wrapper.getCountries();
|
||||
TmdbResultsList<ReleaseInfo> results = new TmdbResultsList<ReleaseInfo>(wrapper.getCountries());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get movie release information: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -529,7 +523,7 @@ public class TheMovieDbApi {
|
||||
* @param language
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<Trailer> getMovieTrailers(int movieId, String language, String... appendToResponse) throws MovieDbException {
|
||||
public TmdbResultsList<Trailer> getMovieTrailers(int movieId, String language, String... appendToResponse) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/trailers");
|
||||
apiUrl.addArgument(PARAM_ID, movieId);
|
||||
|
||||
@@ -544,7 +538,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperTrailers wrapper = mapper.readValue(webpage, WrapperTrailers.class);
|
||||
return wrapper.getAll();
|
||||
TmdbResultsList<Trailer> results = new TmdbResultsList<Trailer>(wrapper.getAll());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get movie trailers: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -557,7 +553,7 @@ public class TheMovieDbApi {
|
||||
* @param movieId
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<Translation> getMovieTranslations(int movieId, String... appendToResponse) throws MovieDbException {
|
||||
public TmdbResultsList<Translation> getMovieTranslations(int movieId, String... appendToResponse) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/translations");
|
||||
apiUrl.addArgument(PARAM_ID, movieId);
|
||||
|
||||
@@ -568,7 +564,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperTranslations wrapper = mapper.readValue(webpage, WrapperTranslations.class);
|
||||
return wrapper.getTranslations();
|
||||
TmdbResultsList<Translation> results = new TmdbResultsList<Translation>(wrapper.getTranslations());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get movie tranlations: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -587,7 +585,7 @@ public class TheMovieDbApi {
|
||||
* @param page
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<MovieDb> getSimilarMovies(int movieId, String language, int page, String... appendToResponse) throws MovieDbException {
|
||||
public TmdbResultsList<MovieDb> getSimilarMovies(int movieId, String language, int page, String... appendToResponse) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/similar_movies");
|
||||
apiUrl.addArgument(PARAM_ID, movieId);
|
||||
|
||||
@@ -606,14 +604,16 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class);
|
||||
return wrapper.getMovies();
|
||||
TmdbResultsList<MovieDb> results = new TmdbResultsList<MovieDb>(wrapper.getMovies());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get similar movies: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Reviews> getReviews(int movieId, String language, int page, String... appendToResponse) throws MovieDbException {
|
||||
public TmdbResultsList<Reviews> getReviews(int movieId, String language, int page, String... appendToResponse) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/reviews");
|
||||
apiUrl.addArgument(PARAM_ID, movieId);
|
||||
|
||||
@@ -632,7 +632,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperReviews wrapper = mapper.readValue(webpage, WrapperReviews.class);
|
||||
return wrapper.getReviews();
|
||||
TmdbResultsList<Reviews> results = new TmdbResultsList<Reviews>(wrapper.getReviews());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get reviews: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -647,7 +649,7 @@ public class TheMovieDbApi {
|
||||
* @param page
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<MovieList> getMovieLists(int movieId, String language, int page, String... appendToResponse) throws MovieDbException {
|
||||
public TmdbResultsList<MovieList> getMovieLists(int movieId, String language, int page, String... appendToResponse) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/lists");
|
||||
apiUrl.addArgument(PARAM_ID, movieId);
|
||||
|
||||
@@ -666,7 +668,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperMovieList wrapper = mapper.readValue(webpage, WrapperMovieList.class);
|
||||
return wrapper.getMovieList();
|
||||
TmdbResultsList<MovieList> results = new TmdbResultsList<MovieList>(wrapper.getMovieList());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get movie lists: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -692,7 +696,7 @@ public class TheMovieDbApi {
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
@Deprecated
|
||||
public List<MovieChanges> getMovieChanges(int movieId, String startDate, String endDate) throws MovieDbException {
|
||||
public TmdbResultsList<MovieChanges> getMovieChanges(int movieId, String startDate, String endDate) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/changes");
|
||||
apiUrl.addArgument(PARAM_ID, movieId);
|
||||
|
||||
@@ -709,7 +713,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperChanges wrapper = mapper.readValue(webpage, WrapperChanges.class);
|
||||
return wrapper.getChanges();
|
||||
TmdbResultsList<MovieChanges> results = new TmdbResultsList<MovieChanges>(wrapper.getChanges());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get movie changes: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -743,7 +749,7 @@ public class TheMovieDbApi {
|
||||
*
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<MovieDb> getUpcoming(String language, int page) throws MovieDbException {
|
||||
public TmdbResultsList<MovieDb> getUpcoming(String language, int page) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "upcoming");
|
||||
|
||||
if (StringUtils.isNotBlank(language)) {
|
||||
@@ -759,7 +765,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class);
|
||||
return wrapper.getMovies();
|
||||
TmdbResultsList<MovieDb> results = new TmdbResultsList<MovieDb>(wrapper.getMovies());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get upcoming movies: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -778,7 +786,7 @@ public class TheMovieDbApi {
|
||||
* @param page
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<MovieDb> getNowPlayingMovies(String language, int page) throws MovieDbException {
|
||||
public TmdbResultsList<MovieDb> getNowPlayingMovies(String language, int page) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "now-playing");
|
||||
|
||||
if (StringUtils.isNotBlank(language)) {
|
||||
@@ -794,7 +802,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class);
|
||||
return wrapper.getMovies();
|
||||
TmdbResultsList<MovieDb> results = new TmdbResultsList<MovieDb>(wrapper.getMovies());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get now playing movies: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -812,7 +822,7 @@ public class TheMovieDbApi {
|
||||
* @param page
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<MovieDb> getPopularMovieList(String language, int page) throws MovieDbException {
|
||||
public TmdbResultsList<MovieDb> getPopularMovieList(String language, int page) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "popular");
|
||||
|
||||
if (StringUtils.isNotBlank(language)) {
|
||||
@@ -828,7 +838,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class);
|
||||
return wrapper.getMovies();
|
||||
TmdbResultsList<MovieDb> results = new TmdbResultsList<MovieDb>(wrapper.getMovies());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get popular movie list: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -846,7 +858,7 @@ public class TheMovieDbApi {
|
||||
* @param page
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<MovieDb> getTopRatedMovies(String language, int page) throws MovieDbException {
|
||||
public TmdbResultsList<MovieDb> getTopRatedMovies(String language, int page) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "top-rated");
|
||||
|
||||
if (StringUtils.isNotBlank(language)) {
|
||||
@@ -862,7 +874,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class);
|
||||
return wrapper.getMovies();
|
||||
TmdbResultsList<MovieDb> results = new TmdbResultsList<MovieDb>(wrapper.getMovies());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get top rated movies: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -925,7 +939,7 @@ public class TheMovieDbApi {
|
||||
* @param language
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<Artwork> getCollectionImages(int collectionId, String language) throws MovieDbException {
|
||||
public TmdbResultsList<Artwork> getCollectionImages(int collectionId, String language) throws MovieDbException {
|
||||
List<Artwork> artwork = new ArrayList<Artwork>();
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_COLLECTION, "/images");
|
||||
apiUrl.addArgument(PARAM_ID, collectionId);
|
||||
@@ -939,25 +953,13 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperImages wrapper = mapper.readValue(webpage, WrapperImages.class);
|
||||
|
||||
// Add all the posters to the list
|
||||
for (Artwork poster : wrapper.getPosters()) {
|
||||
poster.setArtworkType(ArtworkType.POSTER);
|
||||
artwork.add(poster);
|
||||
}
|
||||
|
||||
// Add all the backdrops to the list
|
||||
for (Artwork backdrop : wrapper.getBackdrops()) {
|
||||
backdrop.setArtworkType(ArtworkType.BACKDROP);
|
||||
artwork.add(backdrop);
|
||||
}
|
||||
|
||||
return artwork;
|
||||
TmdbResultsList<Artwork> results = new TmdbResultsList<Artwork>(wrapper.getAll(ArtworkType.POSTER, ArtworkType.BACKDROP));
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get collection images: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//</editor-fold>
|
||||
@@ -995,7 +997,7 @@ public class TheMovieDbApi {
|
||||
* @param personId
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<PersonCredit> getPersonCredits(int personId) throws MovieDbException {
|
||||
public TmdbResultsList<PersonCredit> getPersonCredits(int personId) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_PERSON, "/credits");
|
||||
|
||||
List<PersonCredit> personCredits = new ArrayList<PersonCredit>();
|
||||
@@ -1007,18 +1009,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperPersonCredits wrapper = mapper.readValue(webpage, WrapperPersonCredits.class);
|
||||
|
||||
// Add a cast member
|
||||
for (PersonCredit cast : wrapper.getCast()) {
|
||||
cast.setPersonType(PersonType.CAST);
|
||||
personCredits.add(cast);
|
||||
}
|
||||
// Add a crew member
|
||||
for (PersonCredit crew : wrapper.getCrew()) {
|
||||
crew.setPersonType(PersonType.CREW);
|
||||
personCredits.add(crew);
|
||||
}
|
||||
return personCredits;
|
||||
TmdbResultsList<PersonCredit> results = new TmdbResultsList<PersonCredit>(wrapper.getAll());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get person credits: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -1031,7 +1024,7 @@ public class TheMovieDbApi {
|
||||
* @param personId
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<Artwork> getPersonImages(int personId) throws MovieDbException {
|
||||
public TmdbResultsList<Artwork> getPersonImages(int personId) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_PERSON, "/images");
|
||||
|
||||
List<Artwork> personImages = new ArrayList<Artwork>();
|
||||
@@ -1043,13 +1036,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperImages wrapper = mapper.readValue(webpage, WrapperImages.class);
|
||||
|
||||
// Update the image type
|
||||
for (Artwork artwork : wrapper.getProfiles()) {
|
||||
artwork.setArtworkType(ArtworkType.PROFILE);
|
||||
personImages.add(artwork);
|
||||
}
|
||||
return personImages;
|
||||
TmdbResultsList<Artwork> results = new TmdbResultsList<Artwork>(wrapper.getAll(ArtworkType.PROFILE));
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get person images: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -1084,7 +1073,7 @@ public class TheMovieDbApi {
|
||||
* @return
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<Person> getPersonPopular() throws MovieDbException {
|
||||
public TmdbResultsList<Person> getPersonPopular() throws MovieDbException {
|
||||
return getPersonPopular(0);
|
||||
}
|
||||
|
||||
@@ -1097,7 +1086,7 @@ public class TheMovieDbApi {
|
||||
* @return
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<Person> getPersonPopular(int page) throws MovieDbException {
|
||||
public TmdbResultsList<Person> getPersonPopular(int page) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_PERSON, "/popular");
|
||||
|
||||
if (page > 0) {
|
||||
@@ -1109,7 +1098,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperPersonList wrapper = mapper.readValue(webpage, WrapperPersonList.class);
|
||||
return wrapper.getPersonList();
|
||||
TmdbResultsList<Person> results = new TmdbResultsList<Person>(wrapper.getPersonList());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get person images: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -1171,7 +1162,7 @@ public class TheMovieDbApi {
|
||||
* @param page
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<MovieDb> getCompanyMovies(int companyId, String language, int page) throws MovieDbException {
|
||||
public TmdbResultsList<MovieDb> getCompanyMovies(int companyId, String language, int page) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_COMPANY, "/movies");
|
||||
|
||||
apiUrl.addArgument(PARAM_ID, companyId);
|
||||
@@ -1189,7 +1180,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperCompanyMovies wrapper = mapper.readValue(webpage, WrapperCompanyMovies.class);
|
||||
return wrapper.getResults();
|
||||
TmdbResultsList<MovieDb> results = new TmdbResultsList<MovieDb>(wrapper.getResults());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get company movies: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -1206,7 +1199,7 @@ public class TheMovieDbApi {
|
||||
*
|
||||
* @param language
|
||||
*/
|
||||
public List<Genre> getGenreList(String language) throws MovieDbException {
|
||||
public TmdbResultsList<Genre> getGenreList(String language) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_GENRE, "/list");
|
||||
apiUrl.addArgument(PARAM_LANGUAGE, language);
|
||||
|
||||
@@ -1215,18 +1208,15 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperGenres wrapper = mapper.readValue(webpage, WrapperGenres.class);
|
||||
return wrapper.getGenres();
|
||||
TmdbResultsList<Genre> results = new TmdbResultsList<Genre>(wrapper.getGenres());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get genre list: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public List<MovieDb> getGenreMovies(int genreId, String language, int page) throws MovieDbException {
|
||||
return getGenreMovies(genreId, language, page, Boolean.TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of movies per genre.
|
||||
*
|
||||
@@ -1238,7 +1228,7 @@ public class TheMovieDbApi {
|
||||
* @param language
|
||||
* @param page
|
||||
*/
|
||||
public List<MovieDb> getGenreMovies(int genreId, String language, int page, boolean includeAllMovies) throws MovieDbException {
|
||||
public TmdbResultsList<MovieDb> getGenreMovies(int genreId, String language, int page, boolean includeAllMovies) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_GENRE, "/movies");
|
||||
apiUrl.addArgument(PARAM_ID, genreId);
|
||||
|
||||
@@ -1257,7 +1247,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class);
|
||||
return wrapper.getMovies();
|
||||
TmdbResultsList<MovieDb> results = new TmdbResultsList<MovieDb>(wrapper.getMovies());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get genre movie list: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -1277,7 +1269,7 @@ public class TheMovieDbApi {
|
||||
* @param page The page of results to return. 0 to get the default (first page)
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<MovieDb> searchMovie(String movieName, int searchYear, String language, boolean includeAdult, int page) throws MovieDbException {
|
||||
public TmdbResultsList<MovieDb> searchMovie(String movieName, int searchYear, String language, boolean includeAdult, int page) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_SEARCH, "movie");
|
||||
if (StringUtils.isNotBlank(movieName)) {
|
||||
apiUrl.addArgument(PARAM_QUERY, movieName);
|
||||
@@ -1302,7 +1294,9 @@ public class TheMovieDbApi {
|
||||
String webpage = WebBrowser.request(url);
|
||||
try {
|
||||
WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class);
|
||||
return wrapper.getMovies();
|
||||
TmdbResultsList<MovieDb> results = new TmdbResultsList<MovieDb>(wrapper.getMovies());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to find movie: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -1318,7 +1312,7 @@ public class TheMovieDbApi {
|
||||
* @param page
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<Collection> searchCollection(String query, String language, int page) throws MovieDbException {
|
||||
public TmdbResultsList<Collection> searchCollection(String query, String language, int page) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_SEARCH, "collections");
|
||||
|
||||
if (StringUtils.isNotBlank(query)) {
|
||||
@@ -1338,7 +1332,9 @@ public class TheMovieDbApi {
|
||||
String webpage = WebBrowser.request(url);
|
||||
try {
|
||||
WrapperCollection wrapper = mapper.readValue(webpage, WrapperCollection.class);
|
||||
return wrapper.getResults();
|
||||
TmdbResultsList<Collection> results = new TmdbResultsList<Collection>(wrapper.getResults());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to find collection: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -1355,7 +1351,7 @@ public class TheMovieDbApi {
|
||||
* @param page
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<Person> searchPeople(String personName, boolean includeAdult, int page) throws MovieDbException {
|
||||
public TmdbResultsList<Person> searchPeople(String personName, boolean includeAdult, int page) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_SEARCH, "person");
|
||||
apiUrl.addArgument(PARAM_QUERY, personName);
|
||||
apiUrl.addArgument(PARAM_ADULT, includeAdult);
|
||||
@@ -1369,7 +1365,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperPerson wrapper = mapper.readValue(webpage, WrapperPerson.class);
|
||||
return wrapper.getResults();
|
||||
TmdbResultsList<Person> results = new TmdbResultsList<Person>(wrapper.getResults());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to find person: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -1384,7 +1382,7 @@ public class TheMovieDbApi {
|
||||
* @param page
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<MovieList> searchList(String query, String language, int page) throws MovieDbException {
|
||||
public TmdbResultsList<MovieList> searchList(String query, String language, int page) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_SEARCH, "list");
|
||||
|
||||
if (StringUtils.isNotBlank(query)) {
|
||||
@@ -1404,7 +1402,9 @@ public class TheMovieDbApi {
|
||||
String webpage = WebBrowser.request(url);
|
||||
try {
|
||||
WrapperMovieList wrapper = mapper.readValue(webpage, WrapperMovieList.class);
|
||||
return wrapper.getMovieList();
|
||||
TmdbResultsList<MovieList> results = new TmdbResultsList<MovieList>(wrapper.getMovieList());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to find list: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -1423,7 +1423,7 @@ public class TheMovieDbApi {
|
||||
* @param page
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<Company> searchCompanies(String companyName, int page) throws MovieDbException {
|
||||
public TmdbResultsList<Company> searchCompanies(String companyName, int page) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_SEARCH, "company");
|
||||
apiUrl.addArgument(PARAM_QUERY, companyName);
|
||||
|
||||
@@ -1435,7 +1435,9 @@ public class TheMovieDbApi {
|
||||
String webpage = WebBrowser.request(url);
|
||||
try {
|
||||
WrapperCompany wrapper = mapper.readValue(webpage, WrapperCompany.class);
|
||||
return wrapper.getResults();
|
||||
TmdbResultsList<Company> results = new TmdbResultsList<Company>(wrapper.getResults());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to find company: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -1449,7 +1451,7 @@ public class TheMovieDbApi {
|
||||
* @param page
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<Keyword> searchKeyword(String query, int page) throws MovieDbException {
|
||||
public TmdbResultsList<Keyword> searchKeyword(String query, int page) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_SEARCH, "keyword");
|
||||
|
||||
if (StringUtils.isNotBlank(query)) {
|
||||
@@ -1465,7 +1467,9 @@ public class TheMovieDbApi {
|
||||
String webpage = WebBrowser.request(url);
|
||||
try {
|
||||
WrapperKeywords wrapper = mapper.readValue(webpage, WrapperKeywords.class);
|
||||
return wrapper.getResults();
|
||||
TmdbResultsList<Keyword> results = new TmdbResultsList<Keyword>(wrapper.getResults());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to find keyword: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -1532,7 +1536,7 @@ public class TheMovieDbApi {
|
||||
* @return List of movies with the keyword
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<KeywordMovie> getKeywordMovies(String keywordId, String language, int page) throws MovieDbException {
|
||||
public TmdbResultsList<KeywordMovie> getKeywordMovies(String keywordId, String language, int page) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_KEYWORD, "/movies");
|
||||
apiUrl.addArgument(PARAM_ID, keywordId);
|
||||
|
||||
@@ -1549,7 +1553,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperKeywordMovies wrapper = mapper.readValue(webpage, WrapperKeywordMovies.class);
|
||||
return wrapper.getResults();
|
||||
TmdbResultsList<KeywordMovie> results = new TmdbResultsList<KeywordMovie>(wrapper.getResults());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get top rated movies: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -1568,10 +1574,9 @@ public class TheMovieDbApi {
|
||||
throw new MovieDbException(MovieDbExceptionType.UNKNOWN_CAUSE, "Not implemented yet");
|
||||
}
|
||||
//</editor-fold>
|
||||
//
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Jobs">
|
||||
public List<JobDepartment> getJobs() throws MovieDbException {
|
||||
public TmdbResultsList<JobDepartment> getJobs() throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_JOB, "/list");
|
||||
|
||||
URL url = apiUrl.buildUrl();
|
||||
@@ -1579,7 +1584,9 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperJobList wrapper = mapper.readValue(webpage, WrapperJobList.class);
|
||||
return wrapper.getJobs();
|
||||
TmdbResultsList<JobDepartment> results = new TmdbResultsList<JobDepartment>(wrapper.getJobs());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get job list: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
@@ -1616,12 +1623,12 @@ public class TheMovieDbApi {
|
||||
* @return
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<MovieDb> getDiscover(int page, String language, String sortBy, boolean includeAdult, int year,
|
||||
public TmdbResultsList<MovieDb> getDiscover(int page, String language, String sortBy, boolean includeAdult, int year,
|
||||
int primaryReleaseYear, int voteCountGte, float voteAverageGte, String withGenres, String releaseDateGte,
|
||||
String releaseDateLte, String certificationCountry, String certificationLte, String withCompanies) throws MovieDbException {
|
||||
|
||||
Discover d = new Discover();
|
||||
d.page(page)
|
||||
Discover discover = new Discover();
|
||||
discover.page(page)
|
||||
.language(language)
|
||||
.sortBy(sortBy)
|
||||
.includeAdult(includeAdult)
|
||||
@@ -1636,7 +1643,7 @@ public class TheMovieDbApi {
|
||||
.certificationLte(certificationLte)
|
||||
.withCompanies(withCompanies);
|
||||
|
||||
return getDiscover(d);
|
||||
return getDiscover(discover);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1646,7 +1653,7 @@ public class TheMovieDbApi {
|
||||
* @return
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public List<MovieDb> getDiscover(Discover discover) throws MovieDbException {
|
||||
public TmdbResultsList<MovieDb> getDiscover(Discover discover) throws MovieDbException {
|
||||
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_DISCOVER, "/movie");
|
||||
|
||||
apiUrl.setArguments(discover.getParams());
|
||||
@@ -1656,9 +1663,11 @@ public class TheMovieDbApi {
|
||||
|
||||
try {
|
||||
WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class);
|
||||
return wrapper.getMovies();
|
||||
TmdbResultsList<MovieDb> results = new TmdbResultsList<MovieDb>(wrapper.getMovies());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
LOG.warn("Failed to get job list: {}", ex.getMessage());
|
||||
LOG.warn("Failed to get discover list: {}", ex.getMessage());
|
||||
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,13 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.results;
|
||||
|
||||
import com.omertron.themoviedbapi.wrapper.AbstractWrapper;
|
||||
import com.omertron.themoviedbapi.wrapper.AbstractWrapperAll;
|
||||
import com.omertron.themoviedbapi.wrapper.AbstractWrapperId;
|
||||
|
||||
/**
|
||||
* Abstract class to return the results and the id/page info
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public abstract class TmdbResults {
|
||||
@@ -69,6 +71,10 @@ public abstract class TmdbResults {
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
public void copyWrapper(AbstractWrapper wrapper) {
|
||||
// Nothing to copy, just a placeholder
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the Id from the wrapper
|
||||
*
|
||||
|
||||
@@ -19,17 +19,22 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.results;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* List of the results from TheMovieDb
|
||||
*
|
||||
* @author Stuart
|
||||
* @param <T>
|
||||
*/
|
||||
public final class TmdbResultsList<T> extends TmdbResults {
|
||||
|
||||
private List<T> results = Collections.EMPTY_LIST;
|
||||
private List<T> results;
|
||||
|
||||
public TmdbResultsList(List<T> resultList) {
|
||||
results = new ArrayList<T>(resultList);
|
||||
}
|
||||
|
||||
public List<T> getResults() {
|
||||
return results;
|
||||
|
||||
@@ -19,18 +19,23 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.results;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Map of the results from TheMovieDb
|
||||
*
|
||||
* @author Stuart
|
||||
* @param <K>
|
||||
* @param <V>
|
||||
*/
|
||||
public final class TmdbResultsMap<K, V> extends TmdbResults {
|
||||
|
||||
private Map<K, V> results = Collections.EMPTY_MAP;
|
||||
private Map<K, V> results;
|
||||
|
||||
public TmdbResultsMap(Map<K, V> resultsMap) {
|
||||
results = new HashMap<K, V>(results);
|
||||
}
|
||||
|
||||
public Map<K, V> getResults() {
|
||||
return results;
|
||||
|
||||
@@ -20,10 +20,14 @@
|
||||
package com.omertron.themoviedbapi.wrapper;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class AbstractWrapper {
|
||||
public abstract class AbstractWrapper {
|
||||
|
||||
private Logger log;
|
||||
|
||||
@@ -31,6 +35,22 @@ public class AbstractWrapper {
|
||||
this.log = LoggerFactory.getLogger(classToLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of the enums passed
|
||||
*
|
||||
* @param <E>
|
||||
* @param clz Class of the enum
|
||||
* @param typeList Array of the enums
|
||||
* @return
|
||||
*/
|
||||
public <E extends Enum<E>> List<E> getTypeList(Class<E> clz, E[] typeList) {
|
||||
if (typeList.length > 0) {
|
||||
return new ArrayList<E>(Arrays.asList(typeList));
|
||||
} else {
|
||||
return new ArrayList<E>(EnumSet.allOf(clz));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
|
||||
@@ -85,30 +85,36 @@ public class WrapperImages extends AbstractWrapperAll {
|
||||
types = new ArrayList<ArtworkType>(Arrays.asList(ArtworkType.values()));
|
||||
}
|
||||
|
||||
// Add all the posters to the list
|
||||
if (types.contains(ArtworkType.POSTER)) {
|
||||
// Add all the posters to the list
|
||||
for (Artwork poster : posters) {
|
||||
poster.setArtworkType(ArtworkType.POSTER);
|
||||
artwork.add(poster);
|
||||
}
|
||||
updateArtworkType(posters, ArtworkType.POSTER);
|
||||
artwork.addAll(posters);
|
||||
}
|
||||
|
||||
// Add all the backdrops to the list
|
||||
if (types.contains(ArtworkType.BACKDROP)) {
|
||||
// Add all the backdrops to the list
|
||||
for (Artwork backdrop : backdrops) {
|
||||
backdrop.setArtworkType(ArtworkType.BACKDROP);
|
||||
artwork.add(backdrop);
|
||||
}
|
||||
updateArtworkType(backdrops, ArtworkType.BACKDROP);
|
||||
artwork.addAll(backdrops);
|
||||
}
|
||||
|
||||
// Add all the backdrops to the list
|
||||
if (types.contains(ArtworkType.PROFILE)) {
|
||||
// Add all the backdrops to the list
|
||||
for (Artwork backdrop : profiles) {
|
||||
backdrop.setArtworkType(ArtworkType.PROFILE);
|
||||
artwork.add(backdrop);
|
||||
}
|
||||
updateArtworkType(profiles, ArtworkType.PROFILE);
|
||||
artwork.addAll(profiles);
|
||||
}
|
||||
|
||||
return artwork;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the artwork type for the artwork list
|
||||
*
|
||||
* @param artworkList
|
||||
* @param type
|
||||
*/
|
||||
private void updateArtworkType(List<Artwork> artworkList, ArtworkType type) {
|
||||
for (Artwork artwork : artworkList) {
|
||||
artwork.setArtworkType(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,10 @@
|
||||
package com.omertron.themoviedbapi.wrapper;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.model.Person;
|
||||
import com.omertron.themoviedbapi.model.PersonCast;
|
||||
import com.omertron.themoviedbapi.model.PersonCrew;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -54,4 +56,24 @@ public class WrapperMovieCasts extends AbstractWrapperId {
|
||||
public void setCrew(List<PersonCrew> crew) {
|
||||
this.crew = crew;
|
||||
}
|
||||
|
||||
public List<Person> getAll() {
|
||||
List<Person> people = new ArrayList<Person>();
|
||||
|
||||
// Add a cast member
|
||||
for (PersonCast member : cast) {
|
||||
Person person = new Person();
|
||||
person.addCast(member.getId(), member.getName(), member.getProfilePath(), member.getCharacter(), member.getOrder());
|
||||
people.add(person);
|
||||
}
|
||||
|
||||
// Add a crew member
|
||||
for (PersonCrew member : crew) {
|
||||
Person person = new Person();
|
||||
person.addCrew(member.getId(), member.getName(), member.getProfilePath(), member.getDepartment(), member.getJob());
|
||||
people.add(person);
|
||||
}
|
||||
|
||||
return people;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ package com.omertron.themoviedbapi.wrapper;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.model.PersonCredit;
|
||||
import com.omertron.themoviedbapi.model.PersonType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -53,4 +57,27 @@ public class WrapperPersonCredits extends AbstractWrapperAll {
|
||||
public void setCrew(List<PersonCredit> crew) {
|
||||
this.crew = crew;
|
||||
}
|
||||
|
||||
public List<PersonCredit> getAll(PersonType... typeList) {
|
||||
List<PersonCredit> personCredits = new ArrayList<PersonCredit>();
|
||||
List<PersonType> types = getTypeList(PersonType.class, typeList);
|
||||
|
||||
// Add a cast member
|
||||
if (types.contains(PersonType.CAST)) {
|
||||
for (PersonCredit member : cast) {
|
||||
member.setPersonType(PersonType.CAST);
|
||||
personCredits.add(member);
|
||||
}
|
||||
}
|
||||
|
||||
// Add a crew member
|
||||
if (types.contains(PersonType.CREW)) {
|
||||
for (PersonCredit member : crew) {
|
||||
member.setPersonType(PersonType.CREW);
|
||||
personCredits.add(member);
|
||||
}
|
||||
}
|
||||
|
||||
return personCredits;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,8 @@ import com.omertron.themoviedbapi.model.TokenAuthorisation;
|
||||
import com.omertron.themoviedbapi.model.TokenSession;
|
||||
import com.omertron.themoviedbapi.model.Trailer;
|
||||
import com.omertron.themoviedbapi.model.Translation;
|
||||
import com.omertron.themoviedbapi.results.TmdbResultsList;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.*;
|
||||
import static org.junit.Assert.*;
|
||||
@@ -122,17 +121,17 @@ public class TheMovieDbApiTest {
|
||||
LOG.info("searchMovie");
|
||||
|
||||
// Try a movie with less than 1 page of results
|
||||
List<MovieDb> movieList = tmdb.searchMovie("Blade Runner", 0, "", true, 0);
|
||||
TmdbResultsList<MovieDb> movieList = tmdb.searchMovie("Blade Runner", 0, "", true, 0);
|
||||
// List<MovieDb> movieList = tmdb.searchMovie("Blade Runner", "", true);
|
||||
assertTrue("No movies found, should be at least 1", movieList.size() > 0);
|
||||
assertTrue("No movies found, should be at least 1", movieList.getResults().size() > 0);
|
||||
|
||||
// Try a russian langugage movie
|
||||
movieList = tmdb.searchMovie("О чём говорят мужчины", 0, LANGUAGE_RUSSIAN, true, 0);
|
||||
assertTrue("No 'RU' movies found, should be at least 1", movieList.size() > 0);
|
||||
assertTrue("No 'RU' movies found, should be at least 1", movieList.getResults().size() > 0);
|
||||
|
||||
// Try a movie with more than 20 results
|
||||
movieList = tmdb.searchMovie("Star Wars", 0, LANGUAGE_ENGLISH, false, 0);
|
||||
assertTrue("Not enough movies found, should be over 15, found " + movieList.size(), movieList.size() >= 15);
|
||||
assertTrue("Not enough movies found, should be over 15, found " + movieList.getResults().size(), movieList.getResults().size() >= 15);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,12 +151,12 @@ public class TheMovieDbApiTest {
|
||||
public void testGetMovieAlternativeTitles() throws MovieDbException {
|
||||
LOG.info("getMovieAlternativeTitles");
|
||||
String country = "";
|
||||
List<AlternativeTitle> results = tmdb.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country, "casts,images,keywords,releases,trailers,translations,similar_movies,reviews,lists");
|
||||
assertTrue("No alternative titles found", results.size() > 0);
|
||||
TmdbResultsList<AlternativeTitle> result = tmdb.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country, "casts,images,keywords,releases,trailers,translations,similar_movies,reviews,lists");
|
||||
assertTrue("No alternative titles found", result.getResults().size() > 0);
|
||||
|
||||
country = "US";
|
||||
results = tmdb.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country);
|
||||
assertTrue("No alternative titles found", results.size() > 0);
|
||||
result = tmdb.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country);
|
||||
assertTrue("No alternative titles found", result.getResults().size() > 0);
|
||||
|
||||
}
|
||||
|
||||
@@ -167,15 +166,15 @@ public class TheMovieDbApiTest {
|
||||
@Test
|
||||
public void testGetMovieCasts() throws MovieDbException {
|
||||
LOG.info("getMovieCasts");
|
||||
List<Person> people = tmdb.getMovieCasts(ID_MOVIE_BLADE_RUNNER, "alternative_titles,casts,images,keywords,releases,trailers,translations,similar_movies,reviews,lists");
|
||||
assertTrue("No cast information", people.size() > 0);
|
||||
TmdbResultsList<Person> people = tmdb.getMovieCasts(ID_MOVIE_BLADE_RUNNER, "alternative_titles,casts,images,keywords,releases,trailers,translations,similar_movies,reviews,lists");
|
||||
assertTrue("No cast information", people.getResults().size() > 0);
|
||||
|
||||
String name1 = "Harrison Ford";
|
||||
String name2 = "Charles Knode";
|
||||
boolean foundName1 = Boolean.FALSE;
|
||||
boolean foundName2 = Boolean.FALSE;
|
||||
|
||||
for (Person person : people) {
|
||||
for (Person person : people.getResults()) {
|
||||
if (!foundName1 && person.getName().equalsIgnoreCase(name1)) {
|
||||
foundName1 = Boolean.TRUE;
|
||||
}
|
||||
@@ -195,8 +194,8 @@ public class TheMovieDbApiTest {
|
||||
public void testGetMovieImages() throws MovieDbException {
|
||||
LOG.info("getMovieImages");
|
||||
String language = "";
|
||||
List<Artwork> result = tmdb.getMovieImages(ID_MOVIE_BLADE_RUNNER, language);
|
||||
assertFalse("No artwork found", result.isEmpty());
|
||||
TmdbResultsList<Artwork> result = tmdb.getMovieImages(ID_MOVIE_BLADE_RUNNER, language);
|
||||
assertFalse("No artwork found", result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,8 +204,8 @@ public class TheMovieDbApiTest {
|
||||
@Test
|
||||
public void testGetMovieKeywords() throws MovieDbException {
|
||||
LOG.info("getMovieKeywords");
|
||||
List<Keyword> result = tmdb.getMovieKeywords(ID_MOVIE_BLADE_RUNNER);
|
||||
assertFalse("No keywords found", result.isEmpty());
|
||||
TmdbResultsList<Keyword> result = tmdb.getMovieKeywords(ID_MOVIE_BLADE_RUNNER);
|
||||
assertFalse("No keywords found", result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,8 +214,8 @@ public class TheMovieDbApiTest {
|
||||
@Test
|
||||
public void testGetMovieReleaseInfo() throws MovieDbException {
|
||||
LOG.info("getMovieReleaseInfo");
|
||||
List<ReleaseInfo> result = tmdb.getMovieReleaseInfo(ID_MOVIE_BLADE_RUNNER, "");
|
||||
assertFalse("Release information missing", result.isEmpty());
|
||||
TmdbResultsList<ReleaseInfo> result = tmdb.getMovieReleaseInfo(ID_MOVIE_BLADE_RUNNER, "");
|
||||
assertFalse("Release information missing", result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,8 +224,8 @@ public class TheMovieDbApiTest {
|
||||
@Test
|
||||
public void testGetMovieTrailers() throws MovieDbException {
|
||||
LOG.info("getMovieTrailers");
|
||||
List<Trailer> result = tmdb.getMovieTrailers(ID_MOVIE_BLADE_RUNNER, "");
|
||||
assertFalse("Movie trailers missing", result.isEmpty());
|
||||
TmdbResultsList<Trailer> result = tmdb.getMovieTrailers(ID_MOVIE_BLADE_RUNNER, "");
|
||||
assertFalse("Movie trailers missing", result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,8 +234,8 @@ public class TheMovieDbApiTest {
|
||||
@Test
|
||||
public void testGetMovieTranslations() throws MovieDbException {
|
||||
LOG.info("getMovieTranslations");
|
||||
List<Translation> result = tmdb.getMovieTranslations(ID_MOVIE_BLADE_RUNNER);
|
||||
assertFalse("No translations found", result.isEmpty());
|
||||
TmdbResultsList<Translation> result = tmdb.getMovieTranslations(ID_MOVIE_BLADE_RUNNER);
|
||||
assertFalse("No translations found", result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -305,8 +304,8 @@ public class TheMovieDbApiTest {
|
||||
LOG.info("searchPeople");
|
||||
String personName = "Bruce Willis";
|
||||
boolean includeAdult = false;
|
||||
List<Person> result = tmdb.searchPeople(personName, includeAdult, 0);
|
||||
assertTrue("Couldn't find the person", result.size() > 0);
|
||||
TmdbResultsList<Person> result = tmdb.searchPeople(personName, includeAdult, 0);
|
||||
assertTrue("Couldn't find the person", result.getResults().size() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -326,8 +325,8 @@ public class TheMovieDbApiTest {
|
||||
public void testGetPersonCredits() throws MovieDbException {
|
||||
LOG.info("getPersonCredits");
|
||||
|
||||
List<PersonCredit> people = tmdb.getPersonCredits(ID_PERSON_BRUCE_WILLIS);
|
||||
assertTrue("No cast information", people.size() > 0);
|
||||
TmdbResultsList<PersonCredit> result = tmdb.getPersonCredits(ID_PERSON_BRUCE_WILLIS);
|
||||
assertTrue("No cast information", result.getResults().size() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,8 +336,8 @@ public class TheMovieDbApiTest {
|
||||
public void testGetPersonImages() throws MovieDbException {
|
||||
LOG.info("getPersonImages");
|
||||
|
||||
List<Artwork> artwork = tmdb.getPersonImages(ID_PERSON_BRUCE_WILLIS);
|
||||
assertTrue("No cast information", artwork.size() > 0);
|
||||
TmdbResultsList<Artwork> result = tmdb.getPersonImages(ID_PERSON_BRUCE_WILLIS);
|
||||
assertTrue("No cast information", result.getResults().size() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -382,8 +381,8 @@ public class TheMovieDbApiTest {
|
||||
@Test
|
||||
public void testGetNowPlayingMovies() throws MovieDbException {
|
||||
LOG.info("getNowPlayingMovies");
|
||||
List<MovieDb> results = tmdb.getNowPlayingMovies(LANGUAGE_DEFAULT, 0);
|
||||
assertTrue("No now playing movies found", !results.isEmpty());
|
||||
TmdbResultsList<MovieDb> result = tmdb.getNowPlayingMovies(LANGUAGE_DEFAULT, 0);
|
||||
assertTrue("No now playing movies found", !result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -392,8 +391,8 @@ public class TheMovieDbApiTest {
|
||||
@Test
|
||||
public void testGetPopularMovieList() throws MovieDbException {
|
||||
LOG.info("getPopularMovieList");
|
||||
List<MovieDb> results = tmdb.getPopularMovieList(LANGUAGE_DEFAULT, 0);
|
||||
assertTrue("No popular movies found", !results.isEmpty());
|
||||
TmdbResultsList<MovieDb> result = tmdb.getPopularMovieList(LANGUAGE_DEFAULT, 0);
|
||||
assertTrue("No popular movies found", !result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -402,8 +401,8 @@ public class TheMovieDbApiTest {
|
||||
@Test
|
||||
public void testGetTopRatedMovies() throws MovieDbException {
|
||||
LOG.info("getTopRatedMovies");
|
||||
List<MovieDb> results = tmdb.getTopRatedMovies(LANGUAGE_DEFAULT, 0);
|
||||
assertTrue("No top rated movies found", !results.isEmpty());
|
||||
TmdbResultsList<MovieDb> result = tmdb.getTopRatedMovies(LANGUAGE_DEFAULT, 0);
|
||||
assertTrue("No top rated movies found", !result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -422,8 +421,8 @@ public class TheMovieDbApiTest {
|
||||
@Test
|
||||
public void testGetCompanyMovies() throws MovieDbException {
|
||||
LOG.info("getCompanyMovies");
|
||||
List<MovieDb> results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, LANGUAGE_DEFAULT, 0);
|
||||
assertTrue("No company movies found", !results.isEmpty());
|
||||
TmdbResultsList<MovieDb> result = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, LANGUAGE_DEFAULT, 0);
|
||||
assertTrue("No company movies found", !result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -432,8 +431,8 @@ public class TheMovieDbApiTest {
|
||||
@Test
|
||||
public void testSearchCompanies() throws MovieDbException {
|
||||
LOG.info("searchCompanies");
|
||||
List<Company> results = tmdb.searchCompanies(COMPANY_NAME, 0);
|
||||
assertTrue("No company information found", !results.isEmpty());
|
||||
TmdbResultsList<Company> result = tmdb.searchCompanies(COMPANY_NAME, 0);
|
||||
assertTrue("No company information found", !result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -442,8 +441,8 @@ public class TheMovieDbApiTest {
|
||||
@Test
|
||||
public void testGetSimilarMovies() throws MovieDbException {
|
||||
LOG.info("getSimilarMovies");
|
||||
List<MovieDb> results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, LANGUAGE_DEFAULT, 0);
|
||||
assertTrue("No similar movies found", !results.isEmpty());
|
||||
TmdbResultsList<MovieDb> result = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, LANGUAGE_DEFAULT, 0);
|
||||
assertTrue("No similar movies found", !result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -452,8 +451,8 @@ public class TheMovieDbApiTest {
|
||||
@Test
|
||||
public void testGetGenreList() throws MovieDbException {
|
||||
LOG.info("getGenreList");
|
||||
List<Genre> results = tmdb.getGenreList(LANGUAGE_DEFAULT);
|
||||
assertTrue("No genres found", !results.isEmpty());
|
||||
TmdbResultsList<Genre> result = tmdb.getGenreList(LANGUAGE_DEFAULT);
|
||||
assertTrue("No genres found", !result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -462,8 +461,8 @@ public class TheMovieDbApiTest {
|
||||
@Test
|
||||
public void testGetGenreMovies() throws MovieDbException {
|
||||
LOG.info("getGenreMovies");
|
||||
List<MovieDb> results = tmdb.getGenreMovies(ID_GENRE_ACTION, LANGUAGE_DEFAULT, 0, Boolean.TRUE);
|
||||
assertTrue("No genre movies found", !results.isEmpty());
|
||||
TmdbResultsList<MovieDb> result = tmdb.getGenreMovies(ID_GENRE_ACTION, LANGUAGE_DEFAULT, 0, Boolean.TRUE);
|
||||
assertTrue("No genre movies found", !result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -472,8 +471,8 @@ public class TheMovieDbApiTest {
|
||||
@Test
|
||||
public void testGetUpcoming() throws Exception {
|
||||
LOG.info("getUpcoming");
|
||||
List<MovieDb> results = tmdb.getUpcoming(LANGUAGE_DEFAULT, 0);
|
||||
assertTrue("No upcoming movies found", !results.isEmpty());
|
||||
TmdbResultsList<MovieDb> result = tmdb.getUpcoming(LANGUAGE_DEFAULT, 0);
|
||||
assertTrue("No upcoming movies found", !result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -482,8 +481,8 @@ public class TheMovieDbApiTest {
|
||||
@Test
|
||||
public void testGetCollectionImages() throws Exception {
|
||||
LOG.info("getCollectionImages");
|
||||
List<Artwork> result = tmdb.getCollectionImages(ID_COLLECTION_STAR_WARS, LANGUAGE_DEFAULT);
|
||||
assertFalse("No artwork found", result.isEmpty());
|
||||
TmdbResultsList<Artwork> result = tmdb.getCollectionImages(ID_COLLECTION_STAR_WARS, LANGUAGE_DEFAULT);
|
||||
assertFalse("No artwork found", result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -530,9 +529,9 @@ public class TheMovieDbApiTest {
|
||||
@Test
|
||||
public void testGetMovieLists() throws Exception {
|
||||
LOG.info("getMovieLists");
|
||||
List<MovieList> results = tmdb.getMovieLists(ID_MOVIE_BLADE_RUNNER, LANGUAGE_ENGLISH, 0);
|
||||
assertNotNull("No results found", results);
|
||||
assertTrue("No results found", results.size() > 0);
|
||||
TmdbResultsList<MovieList> result = tmdb.getMovieLists(ID_MOVIE_BLADE_RUNNER, LANGUAGE_ENGLISH, 0);
|
||||
assertNotNull("No results found", result);
|
||||
assertTrue("No results found", result.getResults().size() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -545,17 +544,16 @@ public class TheMovieDbApiTest {
|
||||
|
||||
String startDate = "";
|
||||
String endDate = null;
|
||||
List<MovieChanges> results = Collections.EMPTY_LIST;
|
||||
|
||||
// Get some popular movies
|
||||
List<MovieDb> movieList = tmdb.getPopularMovieList(LANGUAGE_DEFAULT, 0);
|
||||
for (MovieDb movie : movieList) {
|
||||
results = tmdb.getMovieChanges(movie.getId(), startDate, endDate);
|
||||
LOG.info("{} has {} changes.", new Object[]{movie.getTitle(), results.size()});
|
||||
TmdbResultsList<MovieDb> movieList = tmdb.getPopularMovieList(LANGUAGE_DEFAULT, 0);
|
||||
for (MovieDb movie : movieList.getResults()) {
|
||||
TmdbResultsList<MovieChanges> result = tmdb.getMovieChanges(movie.getId(), startDate, endDate);
|
||||
LOG.info("{} has {} changes.", new Object[]{movie.getTitle(), result.getResults().size()});
|
||||
}
|
||||
|
||||
assertNotNull("No results found", results);
|
||||
assertTrue("No results found", results.size() > 0);
|
||||
assertNotNull("No results found", movieList.getResults());
|
||||
assertTrue("No results found", movieList.getResults().size() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -576,9 +574,9 @@ public class TheMovieDbApiTest {
|
||||
LOG.info("searchCollection");
|
||||
String query = "batman";
|
||||
int page = 0;
|
||||
List<Collection> result = tmdb.searchCollection(query, LANGUAGE_DEFAULT, page);
|
||||
TmdbResultsList<Collection> result = tmdb.searchCollection(query, LANGUAGE_DEFAULT, page);
|
||||
assertFalse("No collections found", result == null);
|
||||
assertTrue("No collections found", result.size() > 0);
|
||||
assertTrue("No collections found", result.getResults().size() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -589,9 +587,9 @@ public class TheMovieDbApiTest {
|
||||
LOG.info("searchList");
|
||||
String query = "watch";
|
||||
int page = 0;
|
||||
List<MovieList> result = tmdb.searchList(query, LANGUAGE_DEFAULT, page);
|
||||
assertFalse("No lists found", result == null);
|
||||
assertTrue("No lists found", result.size() > 0);
|
||||
TmdbResultsList<MovieList> result = tmdb.searchList(query, LANGUAGE_DEFAULT, page);
|
||||
assertFalse("No lists found", result.getResults() == null);
|
||||
assertTrue("No lists found", result.getResults().size() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -602,9 +600,9 @@ public class TheMovieDbApiTest {
|
||||
LOG.info("searchKeyword");
|
||||
String query = "action";
|
||||
int page = 0;
|
||||
List<Keyword> result = tmdb.searchKeyword(query, page);
|
||||
assertFalse("No keywords found", result == null);
|
||||
assertTrue("No keywords found", result.size() > 0);
|
||||
TmdbResultsList<Keyword> result = tmdb.searchKeyword(query, page);
|
||||
assertFalse("No keywords found", result.getResults() == null);
|
||||
assertTrue("No keywords found", result.getResults().size() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -664,8 +662,8 @@ public class TheMovieDbApiTest {
|
||||
public void testGetKeywordMovies() throws Exception {
|
||||
LOG.info("getKeywordMovies");
|
||||
int page = 0;
|
||||
List<KeywordMovie> result = tmdb.getKeywordMovies(ID_KEYWORD, LANGUAGE_DEFAULT, page);
|
||||
assertFalse("No keyword movies found", result.isEmpty());
|
||||
TmdbResultsList<KeywordMovie> result = tmdb.getKeywordMovies(ID_KEYWORD, LANGUAGE_DEFAULT, page);
|
||||
assertFalse("No keyword movies found", result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -675,9 +673,9 @@ public class TheMovieDbApiTest {
|
||||
public void testGetReviews() throws Exception {
|
||||
LOG.info("getReviews");
|
||||
int page = 0;
|
||||
List<Reviews> result = tmdb.getReviews(ID_MOVIE_THE_AVENGERS, LANGUAGE_DEFAULT, page);
|
||||
TmdbResultsList<Reviews> result = tmdb.getReviews(ID_MOVIE_THE_AVENGERS, LANGUAGE_DEFAULT, page);
|
||||
|
||||
assertFalse("No reviews found", result.isEmpty());
|
||||
assertFalse("No reviews found", result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -708,8 +706,8 @@ public class TheMovieDbApiTest {
|
||||
public void testGetPersonPopular_int() throws Exception {
|
||||
LOG.info("getPersonPopular");
|
||||
int page = 0;
|
||||
List<Person> result = tmdb.getPersonPopular(page);
|
||||
assertFalse("No popular people", result.isEmpty());
|
||||
TmdbResultsList<Person> result = tmdb.getPersonPopular(page);
|
||||
assertFalse("No popular people", result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -760,8 +758,8 @@ public class TheMovieDbApiTest {
|
||||
@Test
|
||||
public void testGetJobs() throws Exception {
|
||||
LOG.info("getJobs");
|
||||
List<JobDepartment> result = tmdb.getJobs();
|
||||
assertFalse("No jobs found", result.isEmpty());
|
||||
TmdbResultsList<JobDepartment> result = tmdb.getJobs();
|
||||
assertFalse("No jobs found", result.getResults().isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -780,7 +778,7 @@ public class TheMovieDbApiTest {
|
||||
Discover discover = new Discover();
|
||||
discover.year(2013).language(LANGUAGE_ENGLISH);
|
||||
|
||||
List<MovieDb> result = tmdb.getDiscover(discover);
|
||||
assertFalse("No movies discovered", result.isEmpty());
|
||||
TmdbResultsList<MovieDb> result = tmdb.getDiscover(discover);
|
||||
assertFalse("No movies discovered", result.getResults().isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user