Partial Movies

This commit is contained in:
Stuart Boston
2015-03-03 17:45:15 +00:00
parent 4db6d22d5b
commit d80f15a52d
25 changed files with 468 additions and 159 deletions
@@ -42,7 +42,6 @@ import com.omertron.themoviedbapi.methods.TmdbPeople;
import com.omertron.themoviedbapi.methods.TmdbReviews;
import com.omertron.themoviedbapi.methods.TmdbSearch;
import com.omertron.themoviedbapi.methods.TmdbTV;
import com.omertron.themoviedbapi.model.AlternativeTitle;
import com.omertron.themoviedbapi.model.Genre;
import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.model.MovieList;
@@ -52,7 +51,7 @@ import com.omertron.themoviedbapi.model.Video;
import com.omertron.themoviedbapi.model.keyword.KeywordMovie;
import com.omertron.themoviedbapi.model2.Certification;
import com.omertron.themoviedbapi.model2.FindResults;
import com.omertron.themoviedbapi.model2.MediaBasic;
import com.omertron.themoviedbapi.model2.media.MediaBasic;
import com.omertron.themoviedbapi.model2.StatusCode;
import com.omertron.themoviedbapi.model2.account.Account;
import com.omertron.themoviedbapi.model2.artwork.Artwork;
@@ -69,11 +68,10 @@ 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;
import com.omertron.themoviedbapi.model2.person.CreditMovieBasic;
import com.omertron.themoviedbapi.model2.person.CreditTVBasic;
import com.omertron.themoviedbapi.model2.person.ExternalID;
import com.omertron.themoviedbapi.model2.person.Person;
import com.omertron.themoviedbapi.model2.person.PersonCredits;
@@ -1225,7 +1223,7 @@ public class TheMovieDbApi {
* @return
* @throws MovieDbException
*/
public PersonCredits<CreditMovieBasic> getPersonMovieCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
public PersonCredits getPersonMovieCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
return tmdbPeople.getPersonMovieCredits(personId, language, appendToResponse);
}
@@ -1244,7 +1242,7 @@ public class TheMovieDbApi {
* @return
* @throws MovieDbException
*/
public PersonCredits<CreditTVBasic> getPersonTVCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
public PersonCredits getPersonTVCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
return tmdbPeople.getPersonTVCredits(personId, language, appendToResponse);
}
@@ -1263,7 +1261,7 @@ public class TheMovieDbApi {
* @return
* @throws MovieDbException
*/
public PersonCredits<CreditTVBasic> getPersonCombinedCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
public PersonCredits getPersonCombinedCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
return tmdbPeople.getPersonCombinedCredits(personId, language, appendToResponse);
}
@@ -20,16 +20,17 @@
package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model.AlternativeTitle;
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.model.person.Person;
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.media.MediaCreditList;
import com.omertron.themoviedbapi.model2.movie.AlternativeTitle;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import com.omertron.themoviedbapi.tools.ApiUrl;
import com.omertron.themoviedbapi.tools.HttpTools;
@@ -42,7 +43,6 @@ import com.omertron.themoviedbapi.tools.TmdbParameters;
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.WrapperReleaseInfo;
@@ -150,14 +150,19 @@ public class TmdbMovies extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public String getMovieAccountState(int movieId, String sessionId) throws MovieDbException {
public MediaState getMovieAccountState(int movieId, String sessionId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, movieId);
parameters.add(Param.SESSION, sessionId);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).buildUrl(parameters);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).setSubMethod(MethodSub.ACCOUNT_STATES).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
return null;
try {
return MAPPER.readValue(webpage, MediaState.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie info", url, ex);
}
}
/**
@@ -196,41 +201,17 @@ public class TmdbMovies extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public String getMovieCredits(int movieId, String... appendToResponse) throws MovieDbException {
public MediaCreditList getMovieCredits(int movieId, String... appendToResponse) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, movieId);
parameters.add(Param.APPEND, appendToResponse);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).buildUrl(parameters);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).setSubMethod(MethodSub.CREDITS).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
return null;
}
/**
* 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<Person> getMovieCasts(int movieId, String... appendToResponse) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, movieId);
parameters.add(Param.APPEND, appendToResponse);
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).setSubMethod(MethodSub.CASTS).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
WrapperMovieCasts wrapper = MAPPER.readValue(webpage, WrapperMovieCasts.class);
TmdbResultsList<Person> results = new TmdbResultsList<Person>(wrapper.getAll());
results.copyWrapper(wrapper);
return results;
return MAPPER.readValue(webpage, MediaCreditList.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie casts", url, ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie credits", url, ex);
}
}
@@ -24,9 +24,6 @@ import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.enumeration.ArtworkType;
import com.omertron.themoviedbapi.model2.artwork.Artwork;
import com.omertron.themoviedbapi.model2.artwork.ArtworkMedia;
import com.omertron.themoviedbapi.model2.person.CreditBasic;
import com.omertron.themoviedbapi.model2.person.CreditMovieBasic;
import com.omertron.themoviedbapi.model2.person.CreditTVBasic;
import com.omertron.themoviedbapi.model2.person.ExternalID;
import com.omertron.themoviedbapi.model2.person.Person;
import com.omertron.themoviedbapi.model2.person.PersonCredits;
@@ -94,7 +91,7 @@ public class TmdbPeople extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public PersonCredits<CreditMovieBasic> getPersonMovieCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
public PersonCredits getPersonMovieCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, personId);
parameters.add(Param.LANGUAGE, language);
@@ -104,8 +101,7 @@ public class TmdbPeople extends AbstractMethod {
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, new TypeReference<PersonCredits<CreditMovieBasic>>() {
});
return MAPPER.readValue(webpage, PersonCredits.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person movie credits", url, ex);
}
@@ -126,7 +122,7 @@ public class TmdbPeople extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public PersonCredits<CreditTVBasic> getPersonTVCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
public PersonCredits getPersonTVCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, personId);
parameters.add(Param.LANGUAGE, language);
@@ -136,8 +132,7 @@ public class TmdbPeople extends AbstractMethod {
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, new TypeReference<PersonCredits<CreditTVBasic>>() {
});
return MAPPER.readValue(webpage, PersonCredits.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person TV credits", url, ex);
}
@@ -158,7 +153,7 @@ public class TmdbPeople extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public PersonCredits<CreditTVBasic> getPersonCombinedCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
public PersonCredits getPersonCombinedCredits(int personId, String language, String... appendToResponse) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, personId);
parameters.add(Param.LANGUAGE, language);
@@ -168,8 +163,7 @@ public class TmdbPeople extends AbstractMethod {
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, new TypeReference<PersonCredits<? extends CreditBasic>>() {
});
return MAPPER.readValue(webpage, PersonCredits.class);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person combined credits", url, ex);
}
@@ -23,7 +23,7 @@ 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.MediaBasic;
import com.omertron.themoviedbapi.model2.media.MediaBasic;
import com.omertron.themoviedbapi.model2.keyword.Keyword;
import com.omertron.themoviedbapi.model2.collection.Collection;
import com.omertron.themoviedbapi.model2.company.Company;
@@ -19,14 +19,15 @@
*/
package com.omertron.themoviedbapi.model;
import com.omertron.themoviedbapi.model2.artwork.Artwork;
import com.omertron.themoviedbapi.model2.review.Review;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
import com.omertron.themoviedbapi.model2.collection.Collection;
import com.omertron.themoviedbapi.model2.keyword.Keyword;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.person.PersonCast;
import com.omertron.themoviedbapi.model.person.PersonCrew;
import com.fasterxml.jackson.annotation.JsonProperty;
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.review.Review;
import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles;
import com.omertron.themoviedbapi.wrapper.WrapperImages;
import com.omertron.themoviedbapi.wrapper.WrapperMovie;
@@ -24,7 +24,7 @@ import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.omertron.themoviedbapi.enumeration.MediaType;
import com.omertron.themoviedbapi.model2.MediaBasic;
import com.omertron.themoviedbapi.model2.media.MediaBasic;
import com.omertron.themoviedbapi.model2.movie.MovieBasic;
import com.omertron.themoviedbapi.model2.tv.TVBasic;
import com.omertron.themoviedbapi.model2.tv.TVEpisodeBasic;
@@ -17,9 +17,10 @@
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model2;
package com.omertron.themoviedbapi.model2.media;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
/**
* Basic media information
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2004-2015 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model2.media;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
/**
*
* @author Stuart.Boston
*/
public class MediaCredit extends AbstractJsonMapping {
@JsonProperty("credit_id")
private String creditId;
@JsonProperty("id")
private int id;
@JsonProperty("profile_path")
private String profilePath;
@JsonProperty("name")
private String name;
public String getCreditId() {
return creditId;
}
public void setCreditId(String creditId) {
this.creditId = creditId;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getProfilePath() {
return profilePath;
}
public void setProfilePath(String profilePath) {
this.profilePath = profilePath;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2004-2015 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model2.media;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
* @author Stuart.Boston
*/
public class MediaCreditCast extends MediaCredit {
@JsonProperty("cast_id")
private int castId = 0;
@JsonProperty("character")
private String character;
@JsonProperty("order")
private int order;
public int getCastId() {
return castId;
}
public void setCastId(int castId) {
this.castId = castId;
}
public String getCharacter() {
return character;
}
public void setCharacter(String character) {
this.character = character;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
}
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2004-2015 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model2.media;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
* @author Stuart.Boston
*/
public class MediaCreditCrew extends MediaCredit {
@JsonProperty("department")
private String department;
@JsonProperty("job")
private String job;
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
}
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2004-2015 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model2.media;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
import java.util.List;
/**
* @author stuart.boston
*/
public class MediaCreditList extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
@JsonProperty("id")
private int id;
@JsonProperty("cast")
private List<MediaCreditCast> cast;
@JsonProperty("crew")
private List<MediaCreditCrew> crew;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public List<MediaCreditCast> getCast() {
return cast;
}
public void setCast(List<MediaCreditCast> cast) {
this.cast = cast;
}
public List<MediaCreditCrew> getCrew() {
return crew;
}
public void setCrew(List<MediaCreditCrew> crew) {
this.crew = crew;
}
}
@@ -0,0 +1,85 @@
/*
* Copyright (c) 2004-2015 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model2.media;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
/**
*
* @author Stuart.Boston
*/
public class MediaState extends AbstractJsonMapping {
@JsonProperty("id")
private int id;
@JsonProperty("favorite")
private boolean favorite;
@JsonProperty("watchlist")
private boolean watchlist;
@JsonProperty("rated")
private RatedValue rated;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public boolean isFavorite() {
return favorite;
}
public void setFavorite(boolean favorite) {
this.favorite = favorite;
}
public boolean isWatchlist() {
return watchlist;
}
public void setWatchlist(boolean watchlist) {
this.watchlist = watchlist;
}
public float getRated() {
return rated.getValue();
}
public void setRated(RatedValue rated) {
this.rated = rated;
}
public class RatedValue extends AbstractJsonMapping {
@JsonProperty("value")
private float value = -1f;
public float getValue() {
return value;
}
public void setValue(float value) {
this.value = value;
}
}
}
@@ -17,7 +17,7 @@
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
package com.omertron.themoviedbapi.model2.movie;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
@@ -20,7 +20,7 @@
package com.omertron.themoviedbapi.model2.movie;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model2.MediaBasic;
import com.omertron.themoviedbapi.model2.media.MediaBasic;
/**
* Basic Movie information
@@ -24,23 +24,19 @@ import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
import com.omertron.themoviedbapi.model2.MediaBasic;
import java.util.List;
/**
* @author stuart.boston
* @param <T>
*/
public class PersonCredits<T> extends AbstractJsonMapping {
public class PersonCredits extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
@JsonProperty("id")
private int id;
// @JsonProperty("cast")
private List<T> cast;
// @JsonProperty("crew")
private List<T> crew;
private List<? extends CreditBasic> cast;
private List<? extends CreditBasic> crew;
public int getId() {
return id;
@@ -50,7 +46,7 @@ public class PersonCredits<T> extends AbstractJsonMapping {
this.id = id;
}
public List<T> getCast() {
public List<? extends CreditBasic> getCast() {
return cast;
}
@@ -58,18 +54,18 @@ public class PersonCredits<T> extends AbstractJsonMapping {
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "media_type",
defaultImpl = MediaBasic.class
defaultImpl = CreditBasic.class
)
@JsonSubTypes({
@JsonSubTypes.Type(value = CreditMovieBasic.class, name = "movie"),
@JsonSubTypes.Type(value = CreditTVBasic.class, name = "tv")
})
@JsonSetter("cast")
public void setCast(List<T> cast) {
public void setCast(List<? extends CreditBasic> cast) {
this.cast = cast;
}
public List<T> getCrew() {
public List<? extends CreditBasic> getCrew() {
return crew;
}
@@ -77,14 +73,14 @@ public class PersonCredits<T> extends AbstractJsonMapping {
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "media_type",
defaultImpl = MediaBasic.class
defaultImpl = CreditBasic.class
)
@JsonSubTypes({
@JsonSubTypes.Type(value = CreditMovieBasic.class, name = "movie"),
@JsonSubTypes.Type(value = CreditTVBasic.class, name = "tv")
})
@JsonSetter("crew")
public void setCrew(List<T> crew) {
public void setCrew(List<? extends CreditBasic> crew) {
this.crew = crew;
}
}
@@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.omertron.themoviedbapi.model2.MediaBasic;
import com.omertron.themoviedbapi.model2.media.MediaBasic;
import com.omertron.themoviedbapi.model2.movie.MovieBasic;
import com.omertron.themoviedbapi.model2.tv.TVBasic;
import com.omertron.themoviedbapi.model2.tv.TVEpisodeBasic;
@@ -20,7 +20,7 @@
package com.omertron.themoviedbapi.model2.tv;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model2.MediaBasic;
import com.omertron.themoviedbapi.model2.media.MediaBasic;
import java.util.List;
/**
@@ -20,7 +20,7 @@
package com.omertron.themoviedbapi.model2.tv;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model2.MediaBasic;
import com.omertron.themoviedbapi.model2.media.MediaBasic;
/**
* TV Favorite information
@@ -24,6 +24,7 @@ import org.apache.commons.lang3.StringUtils;
public enum MethodSub {
ACCOUNT_STATES("account_states"),
ADD_ITEM("add_item"),
ALT_TITLES("alternative_titles"),
CASTS("casts"),
@@ -20,7 +20,7 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.AlternativeTitle;
import com.omertron.themoviedbapi.model2.movie.AlternativeTitle;
import java.io.Serializable;
import java.util.List;
@@ -22,7 +22,7 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.omertron.themoviedbapi.model2.MediaBasic;
import com.omertron.themoviedbapi.model2.media.MediaBasic;
import com.omertron.themoviedbapi.model2.movie.MovieBasic;
import com.omertron.themoviedbapi.model2.tv.TVBasic;
import com.omertron.themoviedbapi.model2.tv.TVEpisodeBasic;
@@ -24,7 +24,7 @@ public class TestID {
private String name;
private String imdb;
private int tmdb;
private String other = null;
private String other;
public TestID() {
}
@@ -35,6 +35,13 @@ public class TestID {
this.tmdb = tmdb;
}
public TestID(String name, String imdb, int tmdb, String other) {
this.name = name;
this.imdb = imdb;
this.tmdb = tmdb;
this.other = other;
}
public String getName() {
return name;
}
@@ -22,18 +22,25 @@ 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.AlternativeTitle;
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.model.person.Person;
import com.omertron.themoviedbapi.model2.artwork.Artwork;
import com.omertron.themoviedbapi.model2.keyword.Keyword;
import com.omertron.themoviedbapi.model2.media.MediaCreditCast;
import com.omertron.themoviedbapi.model2.media.MediaCreditList;
import com.omertron.themoviedbapi.model2.media.MediaState;
import com.omertron.themoviedbapi.model2.movie.AlternativeTitle;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -55,9 +62,9 @@ public class TmdbMoviesTest extends AbstractTests {
doConfiguration();
instance = new TmdbMovies(getApiKey(), getHttpTools());
FILM_IDS.add(new TestID("Blade Runner", "", 78));
FILM_IDS.add(new TestID("Jupiter Ascending", "tt1617661", 76757));
FILM_IDS.add(new TestID("Lucy", "tt2872732", 240832));
FILM_IDS.add(new TestID("Blade Runner", "tt0083658", 78, "Harrison Ford"));
FILM_IDS.add(new TestID("Jupiter Ascending", "tt1617661", 76757, "Mila Kunis"));
FILM_IDS.add(new TestID("Lucy", "tt2872732", 240832, "Morgan Freeman"));
}
@@ -66,18 +73,19 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetMovieInfo() throws MovieDbException {
LOG.info("getMovieInfo");
String language = "";
String language = LANGUAGE_DEFAULT;
String[] appendToResponse = null;
for (TestID test : FILM_IDS) {
MovieDb result = instance.getMovieInfo(test.getTmdb(), language, appendToResponse);
assertEquals("Wrong IMDB ID", test.getImdb(), result.getImdbID());
assertEquals("Wrong title", test.getName(), result.getTitle());
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
@@ -85,17 +93,17 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetMovieInfoImdb() throws MovieDbException {
LOG.info("getMovieInfoImdb");
String language = "";
String language = LANGUAGE_DEFAULT;
String[] appendToResponse = null;
for (TestID test : FILM_IDS) {
MovieDb result = instance.getMovieInfoImdb(test.getImdb(), language, appendToResponse);
assertEquals("Wrong TMDB ID", test.getTmdb(), result.getId());
assertEquals("Wrong title", test.getName(), result.getTitle());
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
@@ -103,15 +111,15 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetMovieAccountState() throws MovieDbException {
LOG.info("getMovieAccountState");
for (TestID test : FILM_IDS) {
String result = instance.getMovieAccountState(test.getTmdb(), getSessionId());
MediaState result = instance.getMovieAccountState(test.getTmdb(), getSessionId());
assertNotNull("Null result", result);
assertTrue("Invalid rating", result.getRated() > -2f);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
@@ -119,7 +127,7 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetMovieAlternativeTitles() throws MovieDbException {
LOG.info("getMovieAlternativeTitles");
@@ -128,9 +136,8 @@ public class TmdbMoviesTest extends AbstractTests {
for (TestID test : FILM_IDS) {
TmdbResultsList<AlternativeTitle> result = instance.getMovieAlternativeTitles(test.getTmdb(), country, appendToResponse);
assertFalse("No alt titles", result.isEmpty());
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
@@ -138,35 +145,29 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetMovieCredits() throws MovieDbException {
LOG.info("getMovieCredits");
String[] appendToResponse = null;
for (TestID test : FILM_IDS) {
String result = instance.getMovieCredits(test.getTmdb(), appendToResponse);
MediaCreditList result = instance.getMovieCredits(test.getTmdb(), appendToResponse);
assertNotNull(result);
assertFalse(result.getCast().isEmpty());
boolean found = false;
for (MediaCreditCast p : result.getCast()) {
if (test.getOther().equals(p.getName())) {
found = true;
break;
}
}
assertTrue(test.getOther() + " not found in cast!", found);
assertFalse(result.getCrew().isEmpty());
break;
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getMovieCasts method, of class TmdbMovies.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testGetMovieCasts() throws MovieDbException {
LOG.info("getMovieCasts");
String[] appendToResponse = null;
for (TestID test : FILM_IDS) {
TmdbResultsList<Person> result = instance.getMovieCasts(test.getTmdb(), appendToResponse);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
@@ -178,7 +179,7 @@ public class TmdbMoviesTest extends AbstractTests {
public void testGetMovieImages() throws MovieDbException {
LOG.info("getMovieImages");
String language = "";
String language = LANGUAGE_DEFAULT;
String[] appendToResponse = null;
for (TestID test : FILM_IDS) {
@@ -193,7 +194,7 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetMovieKeywords() throws MovieDbException {
LOG.info("getMovieKeywords");
@@ -211,11 +212,11 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetMovieReleaseInfo() throws MovieDbException {
LOG.info("getMovieReleaseInfo");
String language = "";
String language = LANGUAGE_DEFAULT;
String[] appendToResponse = null;
for (TestID test : FILM_IDS) {
@@ -230,11 +231,11 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetMovieVideos() throws MovieDbException {
LOG.info("getMovieVideos");
String language = "";
String language = LANGUAGE_DEFAULT;
String[] appendToResponse = null;
for (TestID test : FILM_IDS) {
@@ -249,7 +250,7 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetMovieTranslations() throws MovieDbException {
LOG.info("getMovieTranslations");
@@ -267,12 +268,12 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetSimilarMovies() throws MovieDbException {
LOG.info("getSimilarMovies");
Integer page = null;
String language = "";
String language = LANGUAGE_DEFAULT;
String[] appendToResponse = null;
for (TestID test : FILM_IDS) {
@@ -287,12 +288,12 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetMovieReviews() throws MovieDbException {
LOG.info("getMovieReviews");
Integer page = null;
String language = "";
String language = LANGUAGE_DEFAULT;
String[] appendToResponse = null;
for (TestID test : FILM_IDS) {
@@ -307,12 +308,12 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetMovieLists() throws MovieDbException {
LOG.info("getMovieLists");
Integer page = null;
String language = "";
String language = LANGUAGE_DEFAULT;
String[] appendToResponse = null;
for (TestID test : FILM_IDS) {
@@ -327,7 +328,7 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetMovieChanges() throws MovieDbException {
LOG.info("getMovieChanges");
@@ -346,14 +347,13 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testPostMovieRating() throws MovieDbException {
LOG.info("postMovieRating");
String sessionId = "";
Integer rating = null;
Integer rating = new Random().nextInt(10) + 1;
for (TestID test : FILM_IDS) {
boolean result = instance.postMovieRating(sessionId, test.getTmdb(), rating);
boolean result = instance.postMovieRating(getSessionId(), test.getTmdb(), rating);
}
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
@@ -364,7 +364,7 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetLatestMovie() throws MovieDbException {
LOG.info("getLatestMovie");
@@ -380,11 +380,11 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetUpcoming() throws MovieDbException {
LOG.info("getUpcoming");
Integer page = null;
String language = "";
String language = LANGUAGE_DEFAULT;
for (TestID test : FILM_IDS) {
TmdbResultsList<MovieDb> result = instance.getUpcoming(page, language);
@@ -398,11 +398,11 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetNowPlayingMovies() throws MovieDbException {
LOG.info("getNowPlayingMovies");
Integer page = null;
String language = "";
String language = LANGUAGE_DEFAULT;
for (TestID test : FILM_IDS) {
TmdbResultsList<MovieDb> result = instance.getNowPlayingMovies(page, language);
@@ -416,11 +416,11 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetPopularMovieList() throws MovieDbException {
LOG.info("getPopularMovieList");
Integer page = null;
String language = "";
String language = LANGUAGE_DEFAULT;
for (TestID test : FILM_IDS) {
TmdbResultsList<MovieDb> result = instance.getPopularMovieList(page, language);
@@ -434,11 +434,11 @@ public class TmdbMoviesTest extends AbstractTests {
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
// @Test
public void testGetTopRatedMovies() throws MovieDbException {
LOG.info("getTopRatedMovies");
Integer page = null;
String language = "";
String language = LANGUAGE_DEFAULT;
for (TestID test : FILM_IDS) {
TmdbResultsList<MovieDb> result = instance.getTopRatedMovies(page, language);
@@ -27,9 +27,6 @@ import com.omertron.themoviedbapi.model2.artwork.Artwork;
import com.omertron.themoviedbapi.model2.artwork.ArtworkMedia;
import com.omertron.themoviedbapi.model2.change.ChangeKeyItem;
import com.omertron.themoviedbapi.model2.change.ChangeListItem;
import com.omertron.themoviedbapi.model2.person.CreditBasic;
import com.omertron.themoviedbapi.model2.person.CreditMovieBasic;
import com.omertron.themoviedbapi.model2.person.CreditTVBasic;
import com.omertron.themoviedbapi.model2.person.ExternalID;
import com.omertron.themoviedbapi.model2.person.Person;
import com.omertron.themoviedbapi.model2.person.PersonCredits;
@@ -121,7 +118,7 @@ public class TmdbPeopleTest extends AbstractTests {
String[] appendToResponse = null;
for (TestID test : testIDs) {
PersonCredits<CreditMovieBasic> result = instance.getPersonMovieCredits(test.getTmdb(), language, appendToResponse);
PersonCredits result = instance.getPersonMovieCredits(test.getTmdb(), language, appendToResponse);
LOG.info("ID: {}, # Cast: {}, # Crew: {}", result.getId(), result.getCast().size(), result.getCrew().size());
assertEquals("Incorrect ID", test.getTmdb(), result.getId());
assertFalse("No cast", result.getCast().isEmpty());
@@ -141,7 +138,7 @@ public class TmdbPeopleTest extends AbstractTests {
String[] appendToResponse = null;
for (TestID test : testIDs) {
PersonCredits<CreditTVBasic> result = instance.getPersonTVCredits(test.getTmdb(), language, appendToResponse);
PersonCredits result = instance.getPersonTVCredits(test.getTmdb(), language, appendToResponse);
LOG.info("ID: {}, # Cast: {}, # Crew: {}", result.getId(), result.getCast().size(), result.getCrew().size());
assertEquals("Incorrect ID", test.getTmdb(), result.getId());
assertFalse("No cast", result.getCast().isEmpty());
@@ -161,7 +158,7 @@ public class TmdbPeopleTest extends AbstractTests {
String[] appendToResponse = null;
for (TestID test : testIDs) {
PersonCredits<? extends CreditBasic> result = instance.getPersonCombinedCredits(test.getTmdb(), language, appendToResponse);
PersonCredits result = instance.getPersonCombinedCredits(test.getTmdb(), language, appendToResponse);
LOG.info("ID: {}, # Cast: {}, # Crew: {}", result.getId(), result.getCast().size(), result.getCrew().size());
assertEquals("Incorrect ID", test.getTmdb(), result.getId());
assertFalse("No cast", result.getCast().isEmpty());
@@ -23,7 +23,7 @@ import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.enumeration.SearchType;
import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.model2.MediaBasic;
import com.omertron.themoviedbapi.model2.media.MediaBasic;
import com.omertron.themoviedbapi.model2.keyword.Keyword;
import com.omertron.themoviedbapi.model2.collection.Collection;
import com.omertron.themoviedbapi.model2.company.Company;