From 46cd35f908e9d5fb3885811c0c4594fcd7eaf011 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Wed, 19 Dec 2012 15:56:45 +0000 Subject: [PATCH] Added getMovieChanges method --- .../omertron/themoviedbapi/TheMovieDbApi.java | 61 ++++++++- .../omertron/themoviedbapi/model/Artwork.java | 12 ++ .../themoviedbapi/model/ChangeItem.java | 121 +++++++++++++++++ .../themoviedbapi/model/ChangeValue.java | 127 ++++++++++++++++++ .../themoviedbapi/model/MovieChanges.java | 81 +++++++++++ .../themoviedbapi/wrapper/WrapperChanges.java | 69 ++++++++++ .../themoviedbapi/TheMovieDbApiTest.java | 104 ++++++++------ 7 files changed, 528 insertions(+), 47 deletions(-) create mode 100644 src/main/java/com/omertron/themoviedbapi/model/ChangeItem.java create mode 100644 src/main/java/com/omertron/themoviedbapi/model/ChangeValue.java create mode 100644 src/main/java/com/omertron/themoviedbapi/model/MovieChanges.java create mode 100644 src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index d8da1c629..9037db925 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -19,8 +19,6 @@ */ package com.omertron.themoviedbapi; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.omertron.themoviedbapi.MovieDbException.MovieDbExceptionType; import com.omertron.themoviedbapi.model.AlternativeTitle; @@ -30,6 +28,7 @@ import com.omertron.themoviedbapi.model.CollectionInfo; import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.Keyword; +import com.omertron.themoviedbapi.model.MovieChanges; import com.omertron.themoviedbapi.model.MovieDb; import com.omertron.themoviedbapi.model.MovieList; import com.omertron.themoviedbapi.model.Person; @@ -48,6 +47,7 @@ import static com.omertron.themoviedbapi.tools.ApiUrl.*; import com.omertron.themoviedbapi.tools.FilteringLayout; import com.omertron.themoviedbapi.tools.WebBrowser; import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles; +import com.omertron.themoviedbapi.wrapper.WrapperChanges; import com.omertron.themoviedbapi.wrapper.WrapperCompany; import com.omertron.themoviedbapi.wrapper.WrapperCompanyMovies; import com.omertron.themoviedbapi.wrapper.WrapperConfig; @@ -67,7 +67,6 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.List; -import java.util.logging.Level; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -700,7 +699,15 @@ public class TheMovieDbApi { } } - //lists + /** + * Get the lists that the movie belongs to + * + * @param movieId + * @param language + * @param page + * @return + * @throws MovieDbException + */ public List getMovieLists(int movieId, String language, int page) throws MovieDbException { ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/lists"); apiUrl.addArgument(PARAM_ID, movieId); @@ -725,8 +732,50 @@ public class TheMovieDbApi { } } - //changes - public void getMovieChanges() throws MovieDbException { + /** + * Get the changes for a specific movie id. + * + * Changes are grouped by key, and ordered by date in descending order. + * + * 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 language is present on fields that are translatable. + * + * TODO: DOES NOT WORK AT THE MOMENT. This is due to the "value" item + * changing type in the ChangeItem + * + * @param movieId + * @param startDate the start date of the changes, optional + * @param endDate the end date of the changes, optional + * @throws MovieDbException + */ + @Deprecated + public List getMovieChanges(int movieId, String startDate, String endDate) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/changes"); + apiUrl.addArgument(PARAM_ID, movieId); + + if (StringUtils.isNotBlank(startDate)) { + apiUrl.addArgument("start_date", startDate); + } + + if (StringUtils.isNotBlank(endDate)) { + apiUrl.addArgument("end_date", endDate); + } + + URL url = apiUrl.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + WrapperChanges wrapper = mapper.readValue(webpage, WrapperChanges.class); + return wrapper.getChanges(); + } catch (IOException ex) { + logger.warn("Failed to get movie changes: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } /** diff --git a/src/main/java/com/omertron/themoviedbapi/model/Artwork.java b/src/main/java/com/omertron/themoviedbapi/model/Artwork.java index ceb82e93c..dd9b30a13 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Artwork.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Artwork.java @@ -54,6 +54,8 @@ public class Artwork implements Serializable { private float voteAverage; @JsonProperty("vote_count") private int voteCount; + @JsonProperty("flag") + private String flag; private ArtworkType artworkType = ArtworkType.POSTER; // @@ -88,6 +90,11 @@ public class Artwork implements Serializable { public int getVoteCount() { return voteCount; } + + public String getFlag() { + return flag; + } + // // @@ -122,6 +129,11 @@ public class Artwork implements Serializable { public void setVoteCount(int voteCount) { this.voteCount = voteCount; } + + public void setFlag(String flag) { + this.flag = flag; + } + // /** diff --git a/src/main/java/com/omertron/themoviedbapi/model/ChangeItem.java b/src/main/java/com/omertron/themoviedbapi/model/ChangeItem.java new file mode 100644 index 000000000..09cc9fd17 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/ChangeItem.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2004-2012 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 . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.log4j.Logger; + +public class ChangeItem { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(MovieChanges.class); + /* + * Properties + */ + @JsonProperty("id") + private String id; + @JsonProperty("action") + private String action; + @JsonProperty("time") + private String time; + @JsonProperty("value") + private ChangeValue value; + @JsonProperty("original_value") + private ChangeValue originalValue; + @JsonProperty("iso_639_1") + private String language; + + // + public String getId() { + return id; + } + + public String getAction() { + return action; + } + + public String getTime() { + return time; + } + + public ChangeValue getValue() { + return value; + } + + public ChangeValue getOriginalValue() { + return originalValue; + } + + public String getLanguage() { + return language; + } + // + + // + public void setId(String id) { + this.id = id; + } + + public void setAction(String action) { + this.action = action; + } + + public void setTime(String time) { + this.time = time; + } + + public void setValue(ChangeValue value) { + this.value = value; + } + + public void setOriginalValue(ChangeValue originalValue) { + this.originalValue = originalValue; + } + + public void setLanguage(String language) { + this.language = language; + } + + // + + @Override + public String toString() { + return "ChangeItem{" + "id=" + id + ", action=" + action + ", time=" + time + ", value=" + value + '}'; + } + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.trace(sb.toString()); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/ChangeValue.java b/src/main/java/com/omertron/themoviedbapi/model/ChangeValue.java new file mode 100644 index 000000000..a1120d773 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/ChangeValue.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2004-2012 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 . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.log4j.Logger; + +public class ChangeValue { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(MovieChanges.class); + /* + * Properties + */ + @JsonProperty("poster") + private Artwork poster; + @JsonProperty("backdrop") + private Artwork backdrop; + @JsonProperty("title") + private String title; + @JsonProperty("iso_3166_1") + private String language; + @JsonProperty("site") + private String site; + @JsonProperty("name") + private String name; + @JsonProperty("id") + private int id; + + // + public Artwork getPoster() { + return poster; + } + + public Artwork getBackdrop() { + return backdrop; + } + + public String getTitle() { + return title; + } + + public String getLanguage() { + return language; + } + + public String getSite() { + return site; + } + + public String getName() { + return name; + } + + public int getId() { + return id; + } + // + + // + public void setPoster(Artwork poster) { + this.poster = poster; + } + + public void setBackdrop(Artwork backdrop) { + this.backdrop = backdrop; + backdrop.setArtworkType(ArtworkType.BACKDROP); + } + + public void setTitle(String title) { + this.title = title; + } + + public void setLanguage(String language) { + this.language = language; + } + + public void setSite(String site) { + this.site = site; + } + + public void setName(String name) { + this.name = name; + } + + public void setId(int id) { + this.id = id; + } + + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.trace(sb.toString()); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieChanges.java b/src/main/java/com/omertron/themoviedbapi/model/MovieChanges.java new file mode 100644 index 000000000..93f21588d --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieChanges.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2004-2012 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 . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import org.apache.log4j.Logger; + +/** + * + * @author Stuart + */ +public class MovieChanges implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(MovieChanges.class); + /* + * Properties + */ + @JsonProperty("key") + private String key; + @JsonProperty("items") + private List items; + + // + public String getKey() { + return key; + } + + public List getItems() { + return items; + } + // + + // + public void setKey(String key) { + this.key = key; + } + + public void setItems(List items) { + this.items = items; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.trace(sb.toString()); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java new file mode 100644 index 000000000..69a217463 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2004-2012 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 . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.MovieChanges; +import java.util.List; +import org.apache.log4j.Logger; + +/** + * + * @author stuart.boston + */ +public class WrapperChanges { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(WrapperChanges.class); + /* + * Properties + */ + @JsonProperty("changes") + private List changes; + + // + public List getChanges() { + return changes; + } + // + + // + public void setChanges(List changes) { + this.changes = changes; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.trace(sb.toString()); + } +} diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index 79f55cd87..7e9f30123 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -25,6 +25,7 @@ import com.omertron.themoviedbapi.model.CollectionInfo; import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.Keyword; +import com.omertron.themoviedbapi.model.MovieChanges; import com.omertron.themoviedbapi.model.MovieDb; import com.omertron.themoviedbapi.model.MovieList; import com.omertron.themoviedbapi.model.Person; @@ -37,6 +38,7 @@ import com.omertron.themoviedbapi.model.Trailer; import com.omertron.themoviedbapi.model.Translation; import com.omertron.themoviedbapi.tools.FilteringLayout; import java.io.IOException; +import java.util.Collections; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Level; @@ -91,7 +93,7 @@ public class TheMovieDbApiTest { /** * Test of getConfiguration method, of class TheMovieDbApi. */ - //@Test + @Test public void testConfiguration() throws IOException { logger.info("Test Configuration"); @@ -107,7 +109,7 @@ public class TheMovieDbApiTest { /** * Test of searchMovie method, of class TheMovieDbApi. */ - //@Test + @Test public void testSearchMovie() throws MovieDbException { logger.info("searchMovie"); @@ -128,7 +130,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieInfo method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieInfo() throws MovieDbException { logger.info("getMovieInfo"); String language = "en"; @@ -139,7 +141,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieAlternativeTitles method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieAlternativeTitles() throws MovieDbException { logger.info("getMovieAlternativeTitles"); String country = ""; @@ -155,7 +157,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieCasts method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieCasts() throws MovieDbException { logger.info("getMovieCasts"); List people = tmdb.getMovieCasts(ID_MOVIE_BLADE_RUNNER); @@ -182,7 +184,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieImages method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieImages() throws MovieDbException { logger.info("getMovieImages"); String language = ""; @@ -193,7 +195,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieKeywords method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieKeywords() throws MovieDbException { logger.info("getMovieKeywords"); List result = tmdb.getMovieKeywords(ID_MOVIE_BLADE_RUNNER); @@ -203,7 +205,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieReleaseInfo method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieReleaseInfo() throws MovieDbException { logger.info("getMovieReleaseInfo"); List result = tmdb.getMovieReleaseInfo(ID_MOVIE_BLADE_RUNNER, ""); @@ -213,7 +215,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieTrailers method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieTrailers() throws MovieDbException { logger.info("getMovieTrailers"); List result = tmdb.getMovieTrailers(ID_MOVIE_BLADE_RUNNER, ""); @@ -223,7 +225,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieTranslations method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieTranslations() throws MovieDbException { logger.info("getMovieTranslations"); List result = tmdb.getMovieTranslations(ID_MOVIE_BLADE_RUNNER); @@ -233,7 +235,7 @@ public class TheMovieDbApiTest { /** * Test of getCollectionInfo method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetCollectionInfo() throws MovieDbException { logger.info("getCollectionInfo"); String language = ""; @@ -246,7 +248,7 @@ public class TheMovieDbApiTest { * * @throws MovieDbException */ - //@Test + @Test public void testCreateImageUrl() throws MovieDbException { logger.info("createImageUrl"); MovieDb movie = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, ""); @@ -257,7 +259,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieInfoImdb method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieInfoImdb() throws MovieDbException { logger.info("getMovieInfoImdb"); MovieDb result = tmdb.getMovieInfoImdb("tt0076759", "en-US"); @@ -267,7 +269,7 @@ public class TheMovieDbApiTest { /** * Test of getApiKey method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetApiKey() { // Not required } @@ -275,7 +277,7 @@ public class TheMovieDbApiTest { /** * Test of getApiBase method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetApiBase() { // Not required } @@ -283,7 +285,7 @@ public class TheMovieDbApiTest { /** * Test of getConfiguration method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetConfiguration() { // Not required } @@ -291,7 +293,7 @@ public class TheMovieDbApiTest { /** * Test of searchPeople method, of class TheMovieDbApi. */ - //@Test + @Test public void testSearchPeople() throws MovieDbException { logger.info("searchPeople"); String personName = "Bruce Willis"; @@ -303,7 +305,7 @@ public class TheMovieDbApiTest { /** * Test of getPersonInfo method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetPersonInfo() throws MovieDbException { logger.info("getPersonInfo"); Person result = tmdb.getPersonInfo(ID_PERSON_BRUCE_WILLIS); @@ -313,7 +315,7 @@ public class TheMovieDbApiTest { /** * Test of getPersonCredits method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetPersonCredits() throws MovieDbException { logger.info("getPersonCredits"); @@ -324,7 +326,7 @@ public class TheMovieDbApiTest { /** * Test of getPersonImages method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetPersonImages() throws MovieDbException { logger.info("getPersonImages"); @@ -335,7 +337,7 @@ public class TheMovieDbApiTest { /** * Test of getLatestMovie method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetLatestMovie() throws MovieDbException { logger.info("getLatestMovie"); MovieDb result = tmdb.getLatestMovie(); @@ -346,7 +348,7 @@ public class TheMovieDbApiTest { /** * Test of compareMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testCompareMovies() { // Not required } @@ -354,7 +356,7 @@ public class TheMovieDbApiTest { /** * Test of setProxy method, of class TheMovieDbApi. */ - //@Test + @Test public void testSetProxy() { // Not required } @@ -362,7 +364,7 @@ public class TheMovieDbApiTest { /** * Test of setTimeout method, of class TheMovieDbApi. */ - //@Test + @Test public void testSetTimeout() { // Not required } @@ -370,37 +372,37 @@ public class TheMovieDbApiTest { /** * Test of getNowPlayingMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetNowPlayingMovies() throws MovieDbException { logger.info("getNowPlayingMovies"); - List results = tmdb.getNowPlayingMovies("", true); + List results = tmdb.getNowPlayingMovies("", 0); assertTrue("No now playing movies found", !results.isEmpty()); } /** * Test of getPopularMovieList method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetPopularMovieList() throws MovieDbException { logger.info("getPopularMovieList"); - List results = tmdb.getPopularMovieList("", true); + List results = tmdb.getPopularMovieList("", 0); assertTrue("No popular movies found", !results.isEmpty()); } /** * Test of getTopRatedMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetTopRatedMovies() throws MovieDbException { logger.info("getTopRatedMovies"); - List results = tmdb.getTopRatedMovies("", true); + List results = tmdb.getTopRatedMovies("", 0); assertTrue("No top rated movies found", !results.isEmpty()); } /** * Test of getCompanyInfo method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetCompanyInfo() throws MovieDbException { logger.info("getCompanyInfo"); Company company = tmdb.getCompanyInfo(ID_COMPANY_LUCASFILM); @@ -410,7 +412,7 @@ public class TheMovieDbApiTest { /** * Test of getCompanyMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetCompanyMovies() throws MovieDbException { logger.info("getCompanyMovies"); List results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, "", true); @@ -420,7 +422,7 @@ public class TheMovieDbApiTest { /** * Test of searchCompanies method, of class TheMovieDbApi. */ - //@Test + @Test public void testSearchCompanies() throws MovieDbException { logger.info("searchCompanies"); List results = tmdb.searchCompanies(COMPANY_NAME, "", true); @@ -430,7 +432,7 @@ public class TheMovieDbApiTest { /** * Test of getSimilarMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetSimilarMovies() throws MovieDbException { logger.info("getSimilarMovies"); List results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, "", true); @@ -440,7 +442,7 @@ public class TheMovieDbApiTest { /** * Test of getGenreList method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetGenreList() throws MovieDbException { logger.info("getGenreList"); List results = tmdb.getGenreList(""); @@ -450,7 +452,7 @@ public class TheMovieDbApiTest { /** * Test of getGenreMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetGenreMovies() throws MovieDbException { logger.info("getGenreMovies"); List results = tmdb.getGenreMovies(ID_GENRE_ACTION, "", true); @@ -460,7 +462,7 @@ public class TheMovieDbApiTest { /** * Test of getUpcoming method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetUpcoming() throws Exception { logger.info("getUpcoming"); List results = tmdb.getUpcoming(""); @@ -470,7 +472,7 @@ public class TheMovieDbApiTest { /** * Test of getCollectionImages method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetCollectionImages() throws Exception { logger.info("getCollectionImages"); String language = ""; @@ -481,7 +483,7 @@ public class TheMovieDbApiTest { /** * Test of getAuthorisationToken method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetAuthorisationToken() throws Exception { logger.info("getAuthorisationToken"); TokenAuthorisation result = tmdb.getAuthorisationToken(); @@ -493,7 +495,7 @@ public class TheMovieDbApiTest { /** * Test of getSessionToken method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetSessionToken() throws Exception { logger.info("getSessionToken"); TokenAuthorisation token = tmdb.getAuthorisationToken(); @@ -510,7 +512,7 @@ public class TheMovieDbApiTest { /** * Test of getGuestSessionToken method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetGuestSessionToken() throws Exception { logger.info("getGuestSessionToken"); TokenSession result = tmdb.getGuestSessionToken(); @@ -526,4 +528,24 @@ public class TheMovieDbApiTest { assertNotNull("No results found", results); assertTrue("No results found", results.size() > 0); } + +// Do not test this until it is fixed +// @Test + public void testGetMovieChanges() throws Exception { + logger.info("getMovieChanges"); + + String language = ""; + String startDate = ""; + String endDate = null; + List results = Collections.EMPTY_LIST; + + List movieList = tmdb.getPopularMovieList(language, 0); + for (MovieDb movie : movieList) { + results = tmdb.getMovieChanges(movie.getId(), startDate, endDate); + logger.info(movie.getTitle() + " has " + results.size() + " changes."); + } + + assertNotNull("No results found", results); + assertTrue("No results found", results.size() > 0); + } }