From 7a9ea47d4bbd79a3ae1f6dc54e81fe88d0bbc65a Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Tue, 3 Mar 2015 19:56:59 +0000 Subject: [PATCH] More movie methods --- .../omertron/themoviedbapi/TheMovieDbApi.java | 266 +----------------- .../themoviedbapi/methods/AbstractMethod.java | 2 +- .../themoviedbapi/methods/TmdbLists.java | 8 +- .../themoviedbapi/methods/TmdbMovies.java | 71 ++--- .../themoviedbapi/methods/TmdbSearch.java | 2 +- .../{model => model2/movie}/MovieDb.java | 15 +- .../{model => model2/movie}/ReleaseInfo.java | 14 +- .../{model => model2/movie}/Translation.java | 2 +- .../{model => model2/movie}/Video.java | 8 +- .../themoviedbapi/wrapper/WrapperMovie.java | 2 +- .../wrapper/WrapperReleaseInfo.java | 2 +- .../wrapper/WrapperTranslations.java | 2 +- ...perMovieList.java => WrapperUserList.java} | 14 +- .../themoviedbapi/wrapper/WrapperVideos.java | 4 +- .../themoviedbapi/methods/TmdbMoviesTest.java | 90 +++--- .../themoviedbapi/methods/TmdbSearchTest.java | 2 +- 16 files changed, 122 insertions(+), 382 deletions(-) rename src/main/java/com/omertron/themoviedbapi/{model => model2/movie}/MovieDb.java (96%) rename src/main/java/com/omertron/themoviedbapi/{model => model2/movie}/ReleaseInfo.java (88%) rename src/main/java/com/omertron/themoviedbapi/{model => model2/movie}/Translation.java (98%) rename src/main/java/com/omertron/themoviedbapi/{model => model2/movie}/Video.java (95%) rename src/main/java/com/omertron/themoviedbapi/wrapper/{WrapperMovieList.java => WrapperUserList.java} (76%) diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index bdb729d53..feae06ee7 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -43,11 +43,7 @@ import com.omertron.themoviedbapi.methods.TmdbReviews; import com.omertron.themoviedbapi.methods.TmdbSearch; import com.omertron.themoviedbapi.methods.TmdbTV; import com.omertron.themoviedbapi.model.Genre; -import com.omertron.themoviedbapi.model.MovieDb; -import com.omertron.themoviedbapi.model.MovieList; -import com.omertron.themoviedbapi.model.ReleaseInfo; -import com.omertron.themoviedbapi.model.Translation; -import com.omertron.themoviedbapi.model.Video; +import com.omertron.themoviedbapi.model2.movie.MovieDb; import com.omertron.themoviedbapi.model.keyword.KeywordMovie; import com.omertron.themoviedbapi.model2.Certification; import com.omertron.themoviedbapi.model2.FindResults; @@ -68,7 +64,6 @@ import com.omertron.themoviedbapi.model2.discover.Discover; import com.omertron.themoviedbapi.model2.keyword.Keyword; import com.omertron.themoviedbapi.model2.list.ListItem; import com.omertron.themoviedbapi.model2.list.UserList; -import com.omertron.themoviedbapi.model2.movie.AlternativeTitle; import com.omertron.themoviedbapi.model2.movie.MovieBasic; import com.omertron.themoviedbapi.model2.network.Network; import com.omertron.themoviedbapi.model2.person.CreditInfo; @@ -924,266 +919,7 @@ public class TheMovieDbApi { // // - /** - * This method is used to retrieve all of the basic movie information. - * - * It will return the single highest rated poster and backdrop. - * - * ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies - * found. - * - * @param movieId - * @param language - * @param appendToResponse - * @return - * @throws MovieDbException - */ - public MovieDb getMovieInfo(int movieId, String language, String... appendToResponse) throws MovieDbException { - return tmdbMovies.getMovieInfo(movieId, language, appendToResponse); - } - /** - * This method is used to retrieve all of the basic movie information. - * - * It will return the single highest rated poster and backdrop. - * - * ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies - * found. - * - * @param imdbId - * @param language - * @param appendToResponse - * @return - * @throws MovieDbException - */ - public MovieDb getMovieInfoImdb(String imdbId, String language, String... appendToResponse) throws MovieDbException { - return tmdbMovies.getMovieInfoImdb(imdbId, language, appendToResponse); - } - - /** - * This method is used to retrieve all of the alternative titles we have for - * a particular movie. - * - * @param movieId - * @param country - * @param appendToResponse - * @return - * @throws MovieDbException - */ - public TmdbResultsList getMovieAlternativeTitles(int movieId, String country, String... appendToResponse) throws MovieDbException { - return tmdbMovies.getMovieAlternativeTitles(movieId, country, appendToResponse); - } - - /** - * Get the cast information for a specific movie id. - * - * TODO: Add a function to enrich the data with the people methods - * - * @param movieId - * @param appendToResponse - * @return - * @throws MovieDbException - */ - public TmdbResultsList getMovieCasts(int movieId, String... appendToResponse) throws MovieDbException { - return tmdbMovies.getMovieCasts(movieId, appendToResponse); - } - - /** - * This method should be used when you’re wanting to retrieve all of the - * images for a particular movie. - * - * @param movieId - * @param language - * @param appendToResponse - * @return - * @throws MovieDbException - */ - public TmdbResultsList getMovieImages(int movieId, String language, String... appendToResponse) throws MovieDbException { - return tmdbMovies.getMovieImages(movieId, language, appendToResponse); - } - - /** - * This method is used to retrieve all of the keywords that have been added - * to a particular movie. - * - * Currently, only English keywords exist. - * - * @param movieId - * @param appendToResponse - * @return - * @throws MovieDbException - */ - public TmdbResultsList getMovieKeywords(int movieId, String... appendToResponse) throws MovieDbException { - return tmdbMovies.getMovieKeywords(movieId, appendToResponse); - } - - /** - * This method is used to retrieve all of the release and certification data - * we have for a specific movie. - * - * @param movieId - * @param language - * @param appendToResponse - * @return - * @throws MovieDbException - */ - public TmdbResultsList getMovieReleaseInfo(int movieId, String language, String... appendToResponse) throws MovieDbException { - return tmdbMovies.getMovieReleaseInfo(movieId, language, appendToResponse); - } - - /** - * This method is used to retrieve all of the trailers for a particular - * movie. - * - * Supported sites are YouTube and QuickTime. - * - * @param movieId - * @param language - * @param appendToResponse - * @return - * @throws MovieDbException - */ - public TmdbResultsList // diff --git a/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java b/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java index ac5a7ca54..0c5ba1998 100644 --- a/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java +++ b/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java @@ -22,7 +22,7 @@ package com.omertron.themoviedbapi.methods; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.omertron.themoviedbapi.MovieDbException; -import com.omertron.themoviedbapi.model.MovieDb; +import com.omertron.themoviedbapi.model2.movie.MovieDb; import com.omertron.themoviedbapi.model2.collection.Collection; import com.omertron.themoviedbapi.model2.company.Company; import com.omertron.themoviedbapi.model2.keyword.Keyword; diff --git a/src/main/java/com/omertron/themoviedbapi/methods/TmdbLists.java b/src/main/java/com/omertron/themoviedbapi/methods/TmdbLists.java index f7a5711c4..79ba8424b 100644 --- a/src/main/java/com/omertron/themoviedbapi/methods/TmdbLists.java +++ b/src/main/java/com/omertron/themoviedbapi/methods/TmdbLists.java @@ -22,7 +22,7 @@ package com.omertron.themoviedbapi.methods; import com.fasterxml.jackson.core.type.TypeReference; import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.model.ListItemStatus; -import com.omertron.themoviedbapi.model.MovieDb; +import com.omertron.themoviedbapi.model2.movie.MovieDb; import com.omertron.themoviedbapi.model.MovieDbListStatus; import com.omertron.themoviedbapi.model2.StatusCode; import com.omertron.themoviedbapi.model2.list.ListItem; @@ -130,8 +130,7 @@ public class TmdbLists extends AbstractMethod { } /** - * This method lets users delete a list that they created. A valid session - * id is required. + * This method lets users delete a list that they created. A valid session id is required. * * @param sessionId * @param listId @@ -219,8 +218,7 @@ public class TmdbLists extends AbstractMethod { * * This is a irreversible action and should be treated with caution. * - * A valid session id is required. A call without confirm=true will return - * status code 29. + * A valid session id is required. A call without confirm=true will return status code 29. * * @param sessionId * @param listId diff --git a/src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java b/src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java index 2e14e95b2..9de802866 100644 --- a/src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java +++ b/src/main/java/com/omertron/themoviedbapi/methods/TmdbMovies.java @@ -20,15 +20,15 @@ package com.omertron.themoviedbapi.methods; import com.omertron.themoviedbapi.MovieDbException; -import com.omertron.themoviedbapi.model.MovieDb; -import com.omertron.themoviedbapi.model.MovieList; -import com.omertron.themoviedbapi.model.ReleaseInfo; -import com.omertron.themoviedbapi.model.Translation; -import com.omertron.themoviedbapi.model.Video; +import com.omertron.themoviedbapi.model2.movie.MovieDb; +import com.omertron.themoviedbapi.model2.movie.ReleaseInfo; +import com.omertron.themoviedbapi.model2.movie.Translation; +import com.omertron.themoviedbapi.model2.movie.Video; import com.omertron.themoviedbapi.model2.media.MediaState; import com.omertron.themoviedbapi.model2.StatusCode; import com.omertron.themoviedbapi.model2.artwork.Artwork; import com.omertron.themoviedbapi.model2.keyword.Keyword; +import com.omertron.themoviedbapi.model2.list.UserList; import com.omertron.themoviedbapi.model2.media.MediaCreditList; import com.omertron.themoviedbapi.model2.movie.AlternativeTitle; import com.omertron.themoviedbapi.results.TmdbResultsList; @@ -44,12 +44,12 @@ import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles; import com.omertron.themoviedbapi.wrapper.WrapperImages; import com.omertron.themoviedbapi.wrapper.WrapperMovie; import com.omertron.themoviedbapi.wrapper.WrapperMovieKeywords; -import com.omertron.themoviedbapi.wrapper.WrapperMovieList; import com.omertron.themoviedbapi.wrapper.WrapperReleaseInfo; import com.omertron.themoviedbapi.wrapper.WrapperTranslations; import com.omertron.themoviedbapi.wrapper.WrapperVideos; import java.io.IOException; import java.net.URL; +import java.util.List; import org.yamj.api.common.exception.ApiExceptionType; /** @@ -77,8 +77,7 @@ public class TmdbMovies extends AbstractMethod { * * It will return the single highest rated poster and backdrop. * - * ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies - * found. + * ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies found. * * @param movieId * @param language @@ -110,8 +109,7 @@ public class TmdbMovies extends AbstractMethod { * * It will return the single highest rated poster and backdrop. * - * ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies - * found. + * ApiExceptionType.MOVIE_ID_NOT_FOUND will be thrown if there are no movies found. * * @param imdbId * @param language @@ -140,8 +138,8 @@ public class TmdbMovies extends AbstractMethod { } /** - * This method lets a user get the status of whether or not the movie has - * been rated or added to their favourite or movie watch list. + * This method lets a user get the status of whether or not the movie has been rated or added to their favourite or movie watch + * list. * * A valid session id is required. * @@ -166,8 +164,7 @@ public class TmdbMovies extends AbstractMethod { } /** - * This method is used to retrieve all of the alternative titles we have for - * a particular movie. + * This method is used to retrieve all of the alternative titles we have for a particular movie. * * @param movieId * @param country @@ -216,8 +213,7 @@ public class TmdbMovies extends AbstractMethod { } /** - * This method should be used when you’re wanting to retrieve all of the - * images for a particular movie. + * This method should be used when you’re wanting to retrieve all of the images for a particular movie. * * @param movieId * @param language @@ -245,8 +241,7 @@ public class TmdbMovies extends AbstractMethod { } /** - * This method is used to retrieve all of the keywords that have been added - * to a particular movie. + * This method is used to retrieve all of the keywords that have been added to a particular movie. * * Currently, only English keywords exist. * @@ -274,8 +269,7 @@ public class TmdbMovies extends AbstractMethod { } /** - * This method is used to retrieve all of the release and certification data - * we have for a specific movie. + * This method is used to retrieve all of the release and certification data we have for a specific movie. * * @param movieId * @param language @@ -303,8 +297,7 @@ public class TmdbMovies extends AbstractMethod { } /** - * This method is used to retrieve all of the trailers for a particular - * movie. + * This method is used to retrieve all of the trailers for a particular movie. * * Supported sites are YouTube and QuickTime. * @@ -334,8 +327,7 @@ public class TmdbMovies extends AbstractMethod { } /** - * This method is used to retrieve a list of the available translations for - * a specific movie. + * This method is used to retrieve a list of the available translations for a specific movie. * * @param movieId * @param appendToResponse @@ -361,11 +353,9 @@ public class TmdbMovies extends AbstractMethod { } /** - * The similar movies method will let you retrieve the similar movies for a - * particular movie. + * The similar movies method will let you retrieve the similar movies for a particular movie. * - * This data is created dynamically but with the help of users votes on - * TMDb. + * This data is created dynamically but with the help of users votes on TMDb. * * The data is much better with movies that have more keywords * @@ -428,7 +418,7 @@ public class TmdbMovies extends AbstractMethod { * @return * @throws MovieDbException */ - public TmdbResultsList getMovieLists(int movieId, Integer page, String language, String... appendToResponse) throws MovieDbException { + public TmdbResultsList getMovieLists(int movieId, Integer page, String language, String... appendToResponse) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, movieId); parameters.add(Param.LANGUAGE, language); @@ -436,16 +426,10 @@ public class TmdbMovies extends AbstractMethod { parameters.add(Param.APPEND, appendToResponse); URL url = new ApiUrl(apiKey, MethodBase.MOVIE).setSubMethod(MethodSub.LISTS).buildUrl(parameters); - String webpage = httpTools.getRequest(url); - - try { - WrapperMovieList wrapper = MAPPER.readValue(webpage, WrapperMovieList.class); - TmdbResultsList results = new TmdbResultsList(wrapper.getMovieList()); - results.copyWrapper(wrapper); - return results; - } catch (IOException ex) { - throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie lists", url, ex); - } + List wrapper = processWrapperList(getTypeReference(UserList.class), url, "movie lists"); + TmdbResultsList results = new TmdbResultsList(null); + results.getResults().addAll(wrapper); + return results; } /** @@ -455,8 +439,7 @@ public class TmdbMovies extends AbstractMethod { * * By default, only the last 24 hours of changes are returned. * - * The maximum number of days that can be returned in a single request is - * 14. + * The maximum number of days that can be returned in a single request is 14. * * The language is present on fields that are translatable. * @@ -565,8 +548,7 @@ public class TmdbMovies extends AbstractMethod { /** * This method is used to retrieve the movies currently in theatres. * - * This is a curated list that will normally contain 100 movies. The default - * response will return 20 movies. + * This is a curated list that will normally contain 100 movies. The default response will return 20 movies. * * TODO: Implement more than 20 movies * @@ -624,8 +606,7 @@ public class TmdbMovies extends AbstractMethod { } /** - * This method is used to retrieve the top rated movies that have over 10 - * votes on TMDb. + * This method is used to retrieve the top rated movies that have over 10 votes on TMDb. * * The default response will return 20 movies. * diff --git a/src/main/java/com/omertron/themoviedbapi/methods/TmdbSearch.java b/src/main/java/com/omertron/themoviedbapi/methods/TmdbSearch.java index 106de17a1..19f9d8c0d 100644 --- a/src/main/java/com/omertron/themoviedbapi/methods/TmdbSearch.java +++ b/src/main/java/com/omertron/themoviedbapi/methods/TmdbSearch.java @@ -22,7 +22,7 @@ package com.omertron.themoviedbapi.methods; import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.enumeration.SearchType; import static com.omertron.themoviedbapi.methods.AbstractMethod.MAPPER; -import com.omertron.themoviedbapi.model.MovieDb; +import com.omertron.themoviedbapi.model2.movie.MovieDb; import com.omertron.themoviedbapi.model2.media.MediaBasic; import com.omertron.themoviedbapi.model2.keyword.Keyword; import com.omertron.themoviedbapi.model2.collection.Collection; diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java b/src/main/java/com/omertron/themoviedbapi/model2/movie/MovieDb.java similarity index 96% rename from src/main/java/com/omertron/themoviedbapi/model/MovieDb.java rename to src/main/java/com/omertron/themoviedbapi/model2/movie/MovieDb.java index 909cd92c6..ca44b1bc2 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java +++ b/src/main/java/com/omertron/themoviedbapi/model2/movie/MovieDb.java @@ -17,8 +17,9 @@ * along with TheMovieDB API. If not, see . * */ -package com.omertron.themoviedbapi.model; +package com.omertron.themoviedbapi.model2.movie; +import com.omertron.themoviedbapi.model.*; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.person.PersonCast; import com.omertron.themoviedbapi.model.person.PersonCrew; @@ -26,14 +27,14 @@ import com.omertron.themoviedbapi.model2.AbstractJsonMapping; import com.omertron.themoviedbapi.model2.artwork.Artwork; import com.omertron.themoviedbapi.model2.collection.Collection; import com.omertron.themoviedbapi.model2.keyword.Keyword; -import com.omertron.themoviedbapi.model2.movie.AlternativeTitle; +import com.omertron.themoviedbapi.model2.list.UserList; import com.omertron.themoviedbapi.model2.review.Review; import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles; import com.omertron.themoviedbapi.wrapper.WrapperImages; import com.omertron.themoviedbapi.wrapper.WrapperMovie; import com.omertron.themoviedbapi.wrapper.WrapperMovieCasts; import com.omertron.themoviedbapi.wrapper.WrapperMovieKeywords; -import com.omertron.themoviedbapi.wrapper.WrapperMovieList; +import com.omertron.themoviedbapi.wrapper.WrapperUserList; import com.omertron.themoviedbapi.wrapper.WrapperReleaseInfo; import com.omertron.themoviedbapi.wrapper.WrapperReviews; import com.omertron.themoviedbapi.wrapper.WrapperTranslations; @@ -120,7 +121,7 @@ public class MovieDb extends AbstractJsonMapping { @JsonProperty("reviews") private WrapperReviews reviews; @JsonProperty("lists") - private WrapperMovieList lists; + private WrapperUserList lists; @JsonProperty("video") private Boolean video = null; @@ -373,8 +374,8 @@ public class MovieDb extends AbstractJsonMapping { return similarMovies.getMovies(); } - public List getLists() { - return lists.getMovieList(); + public List getLists() { + return lists.getUserList(); } public List getReviews() { @@ -415,7 +416,7 @@ public class MovieDb extends AbstractJsonMapping { this.similarMovies = similarMovies; } - public void setLists(WrapperMovieList lists) { + public void setLists(WrapperUserList lists) { this.lists = lists; } diff --git a/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java b/src/main/java/com/omertron/themoviedbapi/model2/movie/ReleaseInfo.java similarity index 88% rename from src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java rename to src/main/java/com/omertron/themoviedbapi/model2/movie/ReleaseInfo.java index 799e7fd86..54ec2b494 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model2/movie/ReleaseInfo.java @@ -17,7 +17,7 @@ * along with TheMovieDB API. If not, see . * */ -package com.omertron.themoviedbapi.model; +package com.omertron.themoviedbapi.model2.movie; import com.omertron.themoviedbapi.model2.AbstractJsonMapping; import com.fasterxml.jackson.annotation.JsonProperty; @@ -40,6 +40,8 @@ public class ReleaseInfo extends AbstractJsonMapping { private String certification; @JsonProperty("release_date") private String releaseDate; + @JsonProperty("primary") + private boolean primary; public String getCertification() { return certification; @@ -65,6 +67,14 @@ public class ReleaseInfo extends AbstractJsonMapping { this.releaseDate = releaseDate; } + public boolean isPrimary() { + return primary; + } + + public void setPrimary(boolean primary) { + this.primary = primary; + } + @Override public boolean equals(Object obj) { if (obj instanceof ReleaseInfo) { @@ -73,6 +83,7 @@ public class ReleaseInfo extends AbstractJsonMapping { .append(country, other.country) .append(certification, other.certification) .append(releaseDate, other.releaseDate) + .append(primary, other.primary) .isEquals(); } else { return false; @@ -85,6 +96,7 @@ public class ReleaseInfo extends AbstractJsonMapping { .append(country) .append(certification) .append(releaseDate) + .append(primary) .toHashCode(); } } diff --git a/src/main/java/com/omertron/themoviedbapi/model/Translation.java b/src/main/java/com/omertron/themoviedbapi/model2/movie/Translation.java similarity index 98% rename from src/main/java/com/omertron/themoviedbapi/model/Translation.java rename to src/main/java/com/omertron/themoviedbapi/model2/movie/Translation.java index a9fc11390..dfa796565 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Translation.java +++ b/src/main/java/com/omertron/themoviedbapi/model2/movie/Translation.java @@ -17,7 +17,7 @@ * along with TheMovieDB API. If not, see . * */ -package com.omertron.themoviedbapi.model; +package com.omertron.themoviedbapi.model2.movie; import com.omertron.themoviedbapi.model2.AbstractJsonMapping; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/omertron/themoviedbapi/model/Video.java b/src/main/java/com/omertron/themoviedbapi/model2/movie/Video.java similarity index 95% rename from src/main/java/com/omertron/themoviedbapi/model/Video.java rename to src/main/java/com/omertron/themoviedbapi/model2/movie/Video.java index f166e3869..7971823dc 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Video.java +++ b/src/main/java/com/omertron/themoviedbapi/model2/movie/Video.java @@ -17,7 +17,7 @@ * along with TheMovieDB API. If not, see . * */ -package com.omertron.themoviedbapi.model; +package com.omertron.themoviedbapi.model2.movie; import com.omertron.themoviedbapi.model2.AbstractJsonMapping; import com.fasterxml.jackson.annotation.JsonProperty; @@ -44,7 +44,7 @@ public class Video extends AbstractJsonMapping { @JsonProperty("site") private String site; @JsonProperty("size") - private String size; + private int size; @JsonProperty("type") private String type; @@ -56,7 +56,7 @@ public class Video extends AbstractJsonMapping { return name; } - public String getSize() { + public int getSize() { return size; } @@ -84,7 +84,7 @@ public class Video extends AbstractJsonMapping { this.name = name; } - public void setSize(String size) { + public void setSize(int size) { this.size = size; } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java index 996c14636..191dfa0b4 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java @@ -20,7 +20,7 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.MovieDb; +import com.omertron.themoviedbapi.model2.movie.MovieDb; import java.io.Serializable; import java.util.List; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java index 390961aa3..914afd499 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java @@ -20,7 +20,7 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.ReleaseInfo; +import com.omertron.themoviedbapi.model2.movie.ReleaseInfo; import java.io.Serializable; import java.util.List; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java index 83d346863..5d65035b1 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java @@ -20,7 +20,7 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.Translation; +import com.omertron.themoviedbapi.model2.movie.Translation; import java.io.Serializable; import java.util.List; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperUserList.java similarity index 76% rename from src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java rename to src/main/java/com/omertron/themoviedbapi/wrapper/WrapperUserList.java index 6e9607e24..400f42d3a 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperUserList.java @@ -20,7 +20,7 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.MovieList; +import com.omertron.themoviedbapi.model2.list.UserList; import java.io.Serializable; import java.util.List; @@ -28,17 +28,17 @@ import java.util.List; * * @author Stuart */ -public class WrapperMovieList extends AbstractWrapperAll implements Serializable { +public class WrapperUserList extends AbstractWrapperAll implements Serializable { private static final long serialVersionUID = 1L; @JsonProperty("results") - private List movieList; + private List userList; - public List getMovieList() { - return movieList; + public List getUserList() { + return userList; } - public void setMovieList(List movieList) { - this.movieList = movieList; + public void setUserList(List userList) { + this.userList = userList; } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperVideos.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperVideos.java index 71024e850..f6f5640bf 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperVideos.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperVideos.java @@ -21,7 +21,7 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonSetter; import com.omertron.themoviedbapi.model.Trailer; -import com.omertron.themoviedbapi.model.Video; +import com.omertron.themoviedbapi.model2.movie.Video; import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -71,7 +71,7 @@ public class WrapperVideos extends AbstractWrapperId implements Serializable { video.setId(""); video.setLanguage(""); - video.setSize(""); + video.setSize(0); video.setName(trailer.getName()); video.setKey(trailer.getSource()); video.setType(trailer.getType()); diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java index 1018697f5..9b0de8663 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java @@ -22,13 +22,14 @@ package com.omertron.themoviedbapi.methods; import com.omertron.themoviedbapi.AbstractTests; import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.TestID; -import com.omertron.themoviedbapi.model.MovieDb; -import com.omertron.themoviedbapi.model.MovieList; -import com.omertron.themoviedbapi.model.ReleaseInfo; -import com.omertron.themoviedbapi.model.Translation; -import com.omertron.themoviedbapi.model.Video; +import com.omertron.themoviedbapi.enumeration.ArtworkType; +import com.omertron.themoviedbapi.model2.movie.MovieDb; +import com.omertron.themoviedbapi.model2.movie.ReleaseInfo; +import com.omertron.themoviedbapi.model2.movie.Translation; +import com.omertron.themoviedbapi.model2.movie.Video; import com.omertron.themoviedbapi.model2.artwork.Artwork; import com.omertron.themoviedbapi.model2.keyword.Keyword; +import com.omertron.themoviedbapi.model2.list.UserList; import com.omertron.themoviedbapi.model2.media.MediaCreditCast; import com.omertron.themoviedbapi.model2.media.MediaCreditList; import com.omertron.themoviedbapi.model2.media.MediaState; @@ -73,7 +74,7 @@ public class TmdbMoviesTest extends AbstractTests { * * @throws com.omertron.themoviedbapi.MovieDbException */ -// @Test + @Test public void testGetMovieInfo() throws MovieDbException { LOG.info("getMovieInfo"); @@ -93,7 +94,7 @@ public class TmdbMoviesTest extends AbstractTests { * * @throws com.omertron.themoviedbapi.MovieDbException */ -// @Test + @Test public void testGetMovieInfoImdb() throws MovieDbException { LOG.info("getMovieInfoImdb"); String language = LANGUAGE_DEFAULT; @@ -111,7 +112,7 @@ public class TmdbMoviesTest extends AbstractTests { * * @throws com.omertron.themoviedbapi.MovieDbException */ -// @Test + @Test public void testGetMovieAccountState() throws MovieDbException { LOG.info("getMovieAccountState"); @@ -127,7 +128,7 @@ public class TmdbMoviesTest extends AbstractTests { * * @throws com.omertron.themoviedbapi.MovieDbException */ -// @Test + @Test public void testGetMovieAlternativeTitles() throws MovieDbException { LOG.info("getMovieAlternativeTitles"); @@ -145,7 +146,7 @@ public class TmdbMoviesTest extends AbstractTests { * * @throws com.omertron.themoviedbapi.MovieDbException */ -// @Test + @Test public void testGetMovieCredits() throws MovieDbException { LOG.info("getMovieCredits"); @@ -182,11 +183,27 @@ public class TmdbMoviesTest extends AbstractTests { String language = LANGUAGE_DEFAULT; String[] appendToResponse = null; + boolean foundBackdrop = false; + boolean foundPoster = false; + boolean foundOther = false; + for (TestID test : FILM_IDS) { TmdbResultsList result = instance.getMovieImages(test.getTmdb(), language, appendToResponse); + assertFalse("No artwork", result.isEmpty()); + for (Artwork artwork : result.getResults()) { + if (artwork.getArtworkType() == ArtworkType.BACKDROP) { + foundBackdrop = true; + continue; + } else if (artwork.getArtworkType() == ArtworkType.POSTER) { + foundPoster = true; + continue; + } + foundOther = true; + } + assertTrue("No backdrops", foundBackdrop); + assertTrue("No posters", foundPoster); + 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."); } /** @@ -194,7 +211,7 @@ public class TmdbMoviesTest extends AbstractTests { * * @throws com.omertron.themoviedbapi.MovieDbException */ -// @Test + @Test public void testGetMovieKeywords() throws MovieDbException { LOG.info("getMovieKeywords"); @@ -202,9 +219,8 @@ public class TmdbMoviesTest extends AbstractTests { for (TestID test : FILM_IDS) { TmdbResultsList result = instance.getMovieKeywords(test.getTmdb(), appendToResponse); + assertFalse("No keywords", result.isEmpty()); } - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); } /** @@ -212,7 +228,7 @@ public class TmdbMoviesTest extends AbstractTests { * * @throws com.omertron.themoviedbapi.MovieDbException */ -// @Test + @Test public void testGetMovieReleaseInfo() throws MovieDbException { LOG.info("getMovieReleaseInfo"); @@ -221,9 +237,8 @@ public class TmdbMoviesTest extends AbstractTests { for (TestID test : FILM_IDS) { TmdbResultsList result = instance.getMovieReleaseInfo(test.getTmdb(), language, appendToResponse); + assertFalse("No release info", result.isEmpty()); } - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); } /** @@ -231,7 +246,7 @@ public class TmdbMoviesTest extends AbstractTests { * * @throws com.omertron.themoviedbapi.MovieDbException */ -// @Test + @Test public void testGetMovieVideos() throws MovieDbException { LOG.info("getMovieVideos"); @@ -240,9 +255,8 @@ public class TmdbMoviesTest extends AbstractTests { for (TestID test : FILM_IDS) { TmdbResultsList