Updated MovieInfo with defaults
This commit is contained in:
@@ -25,6 +25,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.interfaces.IIdentification;
|
||||
import com.omertron.themoviedbapi.model.AbstractJsonMapping;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -35,13 +36,13 @@ public class MediaCreditList extends AbstractJsonMapping implements Serializable
|
||||
private static final long serialVersionUID = 4L;
|
||||
|
||||
@JsonProperty("id")
|
||||
private int id;
|
||||
private int id = 0;
|
||||
@JsonProperty("cast")
|
||||
private List<MediaCreditCast> cast;
|
||||
private List<MediaCreditCast> cast = Collections.emptyList();
|
||||
@JsonProperty("guest_stars")
|
||||
private List<MediaCreditCast> guestStars;
|
||||
private List<MediaCreditCast> guestStars = Collections.emptyList();
|
||||
@JsonProperty("crew")
|
||||
private List<MediaCreditCrew> crew;
|
||||
private List<MediaCreditCrew> crew = Collections.emptyList();
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.omertron.themoviedbapi.results.WrapperReleaseInfo;
|
||||
import com.omertron.themoviedbapi.results.WrapperTranslations;
|
||||
import com.omertron.themoviedbapi.results.WrapperVideos;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
@@ -86,9 +87,9 @@ public class MovieInfo extends AbstractJsonMapping implements Serializable, IIde
|
||||
@JsonProperty("overview")
|
||||
private String overview;
|
||||
@JsonProperty("production_companies")
|
||||
private List<ProductionCompany> productionCompanies;
|
||||
private List<ProductionCompany> productionCompanies = Collections.emptyList();
|
||||
@JsonProperty("production_countries")
|
||||
private List<ProductionCountry> productionCountries;
|
||||
private List<ProductionCountry> productionCountries = Collections.emptyList();
|
||||
@JsonProperty("revenue")
|
||||
private long revenue;
|
||||
@JsonProperty("runtime")
|
||||
@@ -96,7 +97,7 @@ public class MovieInfo extends AbstractJsonMapping implements Serializable, IIde
|
||||
@JsonProperty("original_language")
|
||||
private String originalLanguage;
|
||||
@JsonProperty("spoken_languages")
|
||||
private List<Language> spokenLanguages;
|
||||
private List<Language> spokenLanguages = Collections.emptyList();
|
||||
@JsonProperty("tagline")
|
||||
private String tagline;
|
||||
@JsonProperty("rating")
|
||||
@@ -107,26 +108,20 @@ public class MovieInfo extends AbstractJsonMapping implements Serializable, IIde
|
||||
private int voteCount;
|
||||
@JsonProperty("status")
|
||||
private String status;
|
||||
// AppendToResponse Properties
|
||||
@JsonProperty("alternative_titles")
|
||||
private WrapperAlternativeTitles alternativeTitles;
|
||||
@JsonProperty("casts")
|
||||
private MediaCreditList casts;
|
||||
@JsonProperty("images")
|
||||
private WrapperImages images;
|
||||
@JsonProperty("keywords")
|
||||
private WrapperMovieKeywords keywords;
|
||||
@JsonProperty("releases")
|
||||
private WrapperReleaseInfo releases;
|
||||
@JsonProperty("trailers")
|
||||
private WrapperVideos trailers;
|
||||
@JsonProperty("translations")
|
||||
private WrapperTranslations translations;
|
||||
private List<MovieInfo> similarMovies;
|
||||
private List<Review> reviews;
|
||||
private List<UserList> lists;
|
||||
@JsonProperty("video")
|
||||
private Boolean video = null;
|
||||
// AppendToResponse Properties
|
||||
private List<AlternativeTitle> alternativeTitles = Collections.emptyList();
|
||||
@JsonProperty("casts")
|
||||
private MediaCreditList credits;
|
||||
private List<Artwork> images = Collections.emptyList();
|
||||
private List<Keyword> keywords = Collections.emptyList();
|
||||
private List<ReleaseInfo> releases = Collections.emptyList();
|
||||
private List<Video> trailers = Collections.emptyList();
|
||||
private List<Translation> translations = Collections.emptyList();
|
||||
private List<MovieInfo> similarMovies = Collections.emptyList();
|
||||
private List<Review> reviews = Collections.emptyList();
|
||||
private List<UserList> lists = Collections.emptyList();
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="Getter methods">
|
||||
public String getBackdropPath() {
|
||||
@@ -344,35 +339,35 @@ public class MovieInfo extends AbstractJsonMapping implements Serializable, IIde
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="AppendToResponse Getters">
|
||||
public List<AlternativeTitle> getAlternativeTitles() {
|
||||
return alternativeTitles.getTitles();
|
||||
return alternativeTitles;
|
||||
}
|
||||
|
||||
public List<MediaCreditCast> getCast() {
|
||||
return casts.getCast();
|
||||
return credits.getCast();
|
||||
}
|
||||
|
||||
public List<MediaCreditCrew> getCrew() {
|
||||
return casts.getCrew();
|
||||
return credits.getCrew();
|
||||
}
|
||||
|
||||
public List<Artwork> getImages() {
|
||||
return images.getAll();
|
||||
return images;
|
||||
}
|
||||
|
||||
public List<Keyword> getKeywords() {
|
||||
return keywords.getKeywords();
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public List<ReleaseInfo> getReleases() {
|
||||
return releases.getCountries();
|
||||
return releases;
|
||||
}
|
||||
|
||||
public List<Video> getVideos() {
|
||||
return trailers.getVideos();
|
||||
return trailers;
|
||||
}
|
||||
|
||||
public List<Translation> getTranslations() {
|
||||
return translations.getTranslations();
|
||||
return translations;
|
||||
}
|
||||
|
||||
public List<MovieInfo> getSimilarMovies() {
|
||||
@@ -389,32 +384,38 @@ public class MovieInfo extends AbstractJsonMapping implements Serializable, IIde
|
||||
// </editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="AppendToResponse Setters">
|
||||
@JsonSetter("alternative_titles")
|
||||
public void setAlternativeTitles(WrapperAlternativeTitles alternativeTitles) {
|
||||
this.alternativeTitles = alternativeTitles;
|
||||
this.alternativeTitles = alternativeTitles.getTitles();
|
||||
}
|
||||
|
||||
public void setCasts(MediaCreditList credits) {
|
||||
this.casts = credits;
|
||||
public void setCredits(MediaCreditList credits) {
|
||||
this.credits = credits;
|
||||
}
|
||||
|
||||
@JsonSetter("images")
|
||||
public void setImages(WrapperImages images) {
|
||||
this.images = images;
|
||||
this.images = images.getAll();
|
||||
}
|
||||
|
||||
@JsonSetter("keywords")
|
||||
public void setKeywords(WrapperMovieKeywords keywords) {
|
||||
this.keywords = keywords;
|
||||
this.keywords = keywords.getKeywords();
|
||||
}
|
||||
|
||||
@JsonSetter("releases")
|
||||
public void setReleases(WrapperReleaseInfo releases) {
|
||||
this.releases = releases;
|
||||
this.releases = releases.getCountries();
|
||||
}
|
||||
|
||||
@JsonSetter("trailers")
|
||||
public void setTrailers(WrapperVideos trailers) {
|
||||
this.trailers = trailers;
|
||||
this.trailers = trailers.getVideos();
|
||||
}
|
||||
|
||||
@JsonSetter("translations")
|
||||
public void setTranslations(WrapperTranslations translations) {
|
||||
this.translations = translations;
|
||||
this.translations = translations.getTranslations();
|
||||
}
|
||||
|
||||
@JsonSetter("similar_movies")
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.omertron.themoviedbapi.model.movie.MovieBasic;
|
||||
import com.omertron.themoviedbapi.model.tv.TVBasic;
|
||||
import com.omertron.themoviedbapi.results.ResultList;
|
||||
import com.omertron.themoviedbapi.interfaces.IIdentification;
|
||||
import com.omertron.themoviedbapi.model.movie.MovieInfo;
|
||||
import com.omertron.themoviedbapi.model.person.Person;
|
||||
import com.omertron.themoviedbapi.model.tv.TVEpisodeInfo;
|
||||
import com.omertron.themoviedbapi.model.tv.TVInfo;
|
||||
@@ -64,6 +65,21 @@ public class TestSuite {
|
||||
assertTrue(message + ": Missing release date", isNotBlank(test.getReleaseDate()));
|
||||
}
|
||||
|
||||
public static void test(MovieInfo test) {
|
||||
String message = test.getClass().getSimpleName();
|
||||
assertTrue(message + ": Missing title", isNotBlank(test.getTitle()));
|
||||
assertTrue(message + ": Missing original title", isNotBlank(test.getOriginalTitle()));
|
||||
assertTrue(message + ": Missing poster", isNotBlank(test.getPosterPath()));
|
||||
assertTrue(message + ": Missing release date", isNotBlank(test.getReleaseDate()));
|
||||
assertTrue(message + ": Missing backdrop", isNotBlank(test.getBackdropPath()));
|
||||
assertTrue(message + ": Missing poster path", isNotBlank(test.getPosterPath()));
|
||||
assertTrue(message + ": Missing overview", isNotBlank(test.getOverview()));
|
||||
assertTrue(message + ": Missing Language", isNotBlank(test.getOriginalLanguage()));
|
||||
test(test.getGenres(), "Genres");
|
||||
test(test.getProductionCompanies(), "ProductionCompany");
|
||||
test(test.getProductionCountries(), "ProductionCountries");
|
||||
}
|
||||
|
||||
public static void test(UserList test) {
|
||||
String message = test.getClass().getSimpleName();
|
||||
assertTrue(message + ": Missing ID", isNotBlank(test.getId()));
|
||||
|
||||
@@ -94,7 +94,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
MovieInfo result = instance.getMovieInfo(test.getTmdb(), language, appendToResponse);
|
||||
assertEquals("Wrong IMDB ID", test.getImdb(), result.getImdbID());
|
||||
assertEquals("Wrong title", test.getName(), result.getTitle());
|
||||
|
||||
TestSuite.test(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +113,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
MovieInfo result = instance.getMovieInfoImdb(test.getImdb(), language, appendToResponse);
|
||||
assertEquals("Wrong TMDB ID", test.getTmdb(), result.getId());
|
||||
assertEquals("Wrong title", test.getName(), result.getTitle());
|
||||
TestSuite.test(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user