rename movie and tv fav classes

master
Stuart Boston 11 years ago
parent 410df1f056
commit 5642d7c99e

@ -69,8 +69,8 @@ import com.omertron.themoviedbapi.model2.authentication.TokenAuthorisation;
import com.omertron.themoviedbapi.model2.authentication.TokenSession;
import com.omertron.themoviedbapi.model.Translation;
import com.omertron.themoviedbapi.model.Video;
import com.omertron.themoviedbapi.model2.movie.MovieFavorite;
import com.omertron.themoviedbapi.model2.tv.TVFavorite;
import com.omertron.themoviedbapi.model2.movie.MovieBasic;
import com.omertron.themoviedbapi.model2.tv.TVBasic;
import com.omertron.themoviedbapi.model2.list.UserList;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import com.omertron.themoviedbapi.results.TmdbResultsMap;
@ -295,7 +295,7 @@ public class TheMovieDbApi {
* @return
* @throws MovieDbException
*/
public List<MovieFavorite> getFavoriteMovies(String sessionId, int accountId) throws MovieDbException {
public List<MovieBasic> getFavoriteMovies(String sessionId, int accountId) throws MovieDbException {
return tmdbAccount.getFavoriteMovies(sessionId, accountId);
}
@ -325,7 +325,7 @@ public class TheMovieDbApi {
* @return
* @throws MovieDbException
*/
public List<MovieFavorite> getRatedMovies(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
public List<MovieBasic> getRatedMovies(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
return tmdbAccount.getRatedMovies(sessionId, accountId, page, sortBy, language);
}
@ -340,7 +340,7 @@ public class TheMovieDbApi {
* @return
* @throws MovieDbException
*/
public List<TVFavorite> getRatedTV(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
public List<TVBasic> getRatedTV(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
return tmdbAccount.getRatedTV(sessionId, accountId, page, sortBy, language);
}
@ -355,7 +355,7 @@ public class TheMovieDbApi {
* @return The watchlist of the user
* @throws MovieDbException
*/
public List<MovieFavorite> getWatchListMovie(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
public List<MovieBasic> getWatchListMovie(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
return tmdbAccount.getWatchListMovie(sessionId, accountId, page, sortBy, language);
}
@ -370,7 +370,7 @@ public class TheMovieDbApi {
* @return The watchlist of the user
* @throws MovieDbException
*/
public List<TVFavorite> getWatchListTV(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
public List<TVBasic> getWatchListTV(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
return tmdbAccount.getWatchListTV(sessionId, accountId, page, sortBy, language);
}
@ -602,7 +602,7 @@ public class TheMovieDbApi {
* @return
* @throws MovieDbException
*/
public List<MovieFavorite> getCompanyMovies(int companyId, String language, int page) throws MovieDbException {
public List<MovieBasic> getCompanyMovies(int companyId, String language, int page) throws MovieDbException {
return tmdbCompany.getCompanyMovies(companyId, language, page);
}
//</editor-fold>

@ -22,8 +22,8 @@ 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.model2.movie.MovieFavorite;
import com.omertron.themoviedbapi.model2.tv.TVFavorite;
import com.omertron.themoviedbapi.model2.movie.MovieBasic;
import com.omertron.themoviedbapi.model2.tv.TVBasic;
import com.omertron.themoviedbapi.model2.list.UserList;
import com.omertron.themoviedbapi.tools.HttpTools;
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
@ -49,9 +49,9 @@ public class AbstractMethod {
protected static final ObjectMapper MAPPER = new ObjectMapper();
// Logger
protected static final Logger LOG = LoggerFactory.getLogger(TmdbAccount.class);
protected static final TypeReference<WrapperGenericList<MovieFavorite>> TR_MOVIE_FAV = new TypeReference<WrapperGenericList<MovieFavorite>>() {
protected static final TypeReference<WrapperGenericList<MovieBasic>> TR_MOVIE_BASIC = new TypeReference<WrapperGenericList<MovieBasic>>() {
};
protected static final TypeReference<WrapperGenericList<TVFavorite>> TR_TV_FAV = new TypeReference<WrapperGenericList<TVFavorite>>() {
protected static final TypeReference<WrapperGenericList<TVBasic>> TR_TV_BASIC = new TypeReference<WrapperGenericList<TVBasic>>() {
};
protected static final TypeReference<WrapperGenericList<UserList>> TR_USER_LIST = new TypeReference<WrapperGenericList<UserList>>() {
};

@ -23,8 +23,8 @@ import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.enumeration.MediaType;
import com.omertron.themoviedbapi.model2.account.Account;
import com.omertron.themoviedbapi.model2.StatusCode;
import com.omertron.themoviedbapi.model2.movie.MovieFavorite;
import com.omertron.themoviedbapi.model2.tv.TVFavorite;
import com.omertron.themoviedbapi.model2.movie.MovieBasic;
import com.omertron.themoviedbapi.model2.tv.TVBasic;
import com.omertron.themoviedbapi.model2.list.UserList;
import com.omertron.themoviedbapi.tools.ApiUrl;
import com.omertron.themoviedbapi.tools.HttpTools;
@ -102,13 +102,13 @@ public class TmdbAccount extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public List<MovieFavorite> getFavoriteMovies(String sessionId, int accountId) throws MovieDbException {
public List<MovieBasic> getFavoriteMovies(String sessionId, int accountId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, accountId);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(MethodSub.FAVORITE_MOVIES).buildUrl(parameters);
return processWrapperList(TR_MOVIE_FAV, url, "favorite movies");
return processWrapperList(TR_MOVIE_BASIC, url, "favorite movies");
}
/**
@ -119,13 +119,13 @@ public class TmdbAccount extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public List<TVFavorite> getFavoriteTv(String sessionId, int accountId) throws MovieDbException {
public List<TVBasic> getFavoriteTv(String sessionId, int accountId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, accountId);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(MethodSub.FAVORITE_TV).buildUrl(parameters);
return processWrapperList(TR_TV_FAV, url, "favorite TV shows");
return processWrapperList(TR_TV_BASIC, url, "favorite TV shows");
}
/**
@ -171,7 +171,7 @@ public class TmdbAccount extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public List<MovieFavorite> getRatedMovies(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
public List<MovieBasic> getRatedMovies(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, accountId);
@ -180,7 +180,7 @@ public class TmdbAccount extends AbstractMethod {
parameters.add(Param.LANGUAGE, language);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(MethodSub.RATED_MOVIES).buildUrl(parameters);
return processWrapperList(TR_MOVIE_FAV, url, "rated movies");
return processWrapperList(TR_MOVIE_BASIC, url, "rated movies");
}
/**
@ -194,7 +194,7 @@ public class TmdbAccount extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public List<TVFavorite> getRatedTV(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
public List<TVBasic> getRatedTV(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, accountId);
@ -203,7 +203,7 @@ public class TmdbAccount extends AbstractMethod {
parameters.add(Param.LANGUAGE, language);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(MethodSub.RATED_TV).buildUrl(parameters);
return processWrapperList(TR_TV_FAV, url, "rated TV shows");
return processWrapperList(TR_TV_BASIC, url, "rated TV shows");
}
/**
@ -217,7 +217,7 @@ public class TmdbAccount extends AbstractMethod {
* @return The watch list of the user
* @throws MovieDbException
*/
public List<MovieFavorite> getWatchListMovie(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
public List<MovieBasic> getWatchListMovie(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, accountId);
@ -226,7 +226,7 @@ public class TmdbAccount extends AbstractMethod {
parameters.add(Param.LANGUAGE, language);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(MethodSub.WATCHLIST_MOVIES).buildUrl(parameters);
return processWrapperList(TR_MOVIE_FAV, url, "movie watch list");
return processWrapperList(TR_MOVIE_BASIC, url, "movie watch list");
}
/**
@ -240,7 +240,7 @@ public class TmdbAccount extends AbstractMethod {
* @return The watch list of the user
* @throws MovieDbException
*/
public List<TVFavorite> getWatchListTV(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
public List<TVBasic> getWatchListTV(String sessionId, int accountId, Integer page, String sortBy, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, accountId);
@ -249,7 +249,7 @@ public class TmdbAccount extends AbstractMethod {
parameters.add(Param.LANGUAGE, language);
URL url = new ApiUrl(apiKey, MethodBase.ACCOUNT).setSubMethod(MethodSub.WATCHLIST_TV).buildUrl(parameters);
return processWrapperList(TR_TV_FAV, url, "TV watch list");
return processWrapperList(TR_TV_BASIC, url, "TV watch list");
}
/**

@ -21,7 +21,7 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model2.company.Company;
import com.omertron.themoviedbapi.model2.movie.MovieFavorite;
import com.omertron.themoviedbapi.model2.movie.MovieBasic;
import com.omertron.themoviedbapi.tools.ApiUrl;
import com.omertron.themoviedbapi.tools.HttpTools;
import com.omertron.themoviedbapi.tools.MethodBase;
@ -84,7 +84,7 @@ public class TmdbCompanies extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public List<MovieFavorite> getCompanyMovies(int companyId, String language, Integer page) throws MovieDbException {
public List<MovieBasic> getCompanyMovies(int companyId, String language, Integer page) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, companyId);
parameters.add(Param.LANGUAGE, language);
@ -92,7 +92,7 @@ public class TmdbCompanies extends AbstractMethod {
URL url = new ApiUrl(apiKey, MethodBase.COMPANY).setSubMethod(MethodSub.MOVIES).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
return processWrapperList(TR_MOVIE_FAV, url, webpage);
return processWrapperList(TR_MOVIE_BASIC, url, webpage);
}
}

@ -28,7 +28,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
*
* @author stuart.boston
*/
public class MovieFavorite extends AbstractJsonMapping {
public class MovieBasic extends AbstractJsonMapping {
@JsonProperty("id")
private int id;

@ -29,7 +29,7 @@ import java.util.List;
*
* @author stuart.boston
*/
public class TVFavorite extends AbstractJsonMapping {
public class TVBasic extends AbstractJsonMapping {
@JsonProperty("id")
private int id;

@ -20,7 +20,7 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model2.movie.MovieFavorite;
import com.omertron.themoviedbapi.model2.movie.MovieBasic;
import java.util.List;
/**
@ -30,13 +30,13 @@ import java.util.List;
public class WrapperCompanyMovies extends AbstractWrapperAll {
@JsonProperty("results")
private List<MovieFavorite> results;
private List<MovieBasic> results;
public List<MovieFavorite> getResults() {
public List<MovieBasic> getResults() {
return results;
}
public void setResults(List<MovieFavorite> results) {
public void setResults(List<MovieBasic> results) {
this.results = results;
}
}

@ -42,7 +42,9 @@ import com.omertron.themoviedbapi.model2.authentication.TokenAuthorisation;
import com.omertron.themoviedbapi.model2.authentication.TokenSession;
import com.omertron.themoviedbapi.model.Translation;
import com.omertron.themoviedbapi.model.Video;
import com.omertron.themoviedbapi.model2.movie.MovieBasic;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -400,8 +402,8 @@ public class TheMovieDbApiTest extends AbstractTests {
@Test
public void testGetCompanyMovies() throws MovieDbException {
LOG.info("getCompanyMovies");
TmdbResultsList<MovieDb> result = tmdb.getCompanyMovies(ID_COMPANY, LANGUAGE_DEFAULT, 0);
assertTrue("No company movies found", !result.getResults().isEmpty());
List<MovieBasic> result = tmdb.getCompanyMovies(ID_COMPANY, LANGUAGE_DEFAULT, 0);
assertFalse("No company movies found", result.isEmpty());
}
/**

@ -24,8 +24,8 @@ import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.enumeration.MediaType;
import com.omertron.themoviedbapi.model2.account.Account;
import com.omertron.themoviedbapi.model2.StatusCode;
import com.omertron.themoviedbapi.model2.movie.MovieFavorite;
import com.omertron.themoviedbapi.model2.tv.TVFavorite;
import com.omertron.themoviedbapi.model2.movie.MovieBasic;
import com.omertron.themoviedbapi.model2.tv.TVBasic;
import com.omertron.themoviedbapi.model2.list.UserList;
import java.util.List;
import org.junit.After;
@ -108,10 +108,10 @@ public class TmdbAccountTest extends AbstractTests {
@Test
public void testGetFavoriteMovies() throws MovieDbException {
LOG.info("getFavoriteMovies");
List<MovieFavorite> results = instance.getFavoriteMovies(getSessionId(), getAccountId());
List<MovieBasic> results = instance.getFavoriteMovies(getSessionId(), getAccountId());
assertNotNull("No list found", results);
assertFalse("No entries found", results.isEmpty());
for (MovieFavorite r : results) {
for (MovieBasic r : results) {
LOG.info(" {}", r.toString());
}
}
@ -124,10 +124,10 @@ public class TmdbAccountTest extends AbstractTests {
@Test
public void testGetFavoriteTv() throws MovieDbException {
LOG.info("getFavoriteTv");
List<TVFavorite> results = instance.getFavoriteTv(getSessionId(), getAccountId());
List<TVBasic> results = instance.getFavoriteTv(getSessionId(), getAccountId());
assertNotNull("No list found", results);
assertFalse("No entries found", results.isEmpty());
for (TVFavorite r : results) {
for (TVBasic r : results) {
LOG.info(" {}", r.toString());
}
}
@ -170,7 +170,7 @@ public class TmdbAccountTest extends AbstractTests {
@Test
public void testGetRatedMovies() throws MovieDbException {
LOG.info("getRatedMovies");
List<MovieFavorite> results = instance.getRatedMovies(getSessionId(), getAccountId(), null, null, null);
List<MovieBasic> results = instance.getRatedMovies(getSessionId(), getAccountId(), null, null, null);
assertNotNull("No rated list found", results);
assertFalse("No entries found", results.isEmpty());
}
@ -183,10 +183,10 @@ public class TmdbAccountTest extends AbstractTests {
@Test
public void testGetRatedTV() throws MovieDbException {
LOG.info("getRatedTV");
List<TVFavorite> results = instance.getRatedTV(getSessionId(), getAccountId(), null, null, null);
List<TVBasic> results = instance.getRatedTV(getSessionId(), getAccountId(), null, null, null);
assertNotNull("No rated list found", results);
assertFalse("No entries found", results.isEmpty());
for (TVFavorite r : results) {
for (TVBasic r : results) {
LOG.info(" {}", r.toString());
}
}
@ -199,10 +199,10 @@ public class TmdbAccountTest extends AbstractTests {
@Test
public void testGetWatchListMovie() throws MovieDbException {
LOG.info("getWatchListMovie");
List<MovieFavorite> results = instance.getWatchListMovie(getSessionId(), getAccountId(), null, null, null);
List<MovieBasic> results = instance.getWatchListMovie(getSessionId(), getAccountId(), null, null, null);
assertNotNull("No rated list found", results);
assertFalse("No entries found", results.isEmpty());
for (MovieFavorite r : results) {
for (MovieBasic r : results) {
LOG.info(" {}", r.toString());
}
}
@ -215,10 +215,10 @@ public class TmdbAccountTest extends AbstractTests {
@Test
public void testGetWatchListTV() throws MovieDbException {
LOG.info("getWatchListTV");
List<TVFavorite> results = instance.getWatchListTV(getSessionId(), getAccountId(), null, null, null);
List<TVBasic> results = instance.getWatchListTV(getSessionId(), getAccountId(), null, null, null);
assertNotNull("No rated list found", results);
assertFalse("No entries found", results.isEmpty());
for (TVFavorite r : results) {
for (TVBasic r : results) {
LOG.info(" {}", r.toString());
}
}

@ -22,7 +22,7 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model2.company.Company;
import com.omertron.themoviedbapi.model2.movie.MovieFavorite;
import com.omertron.themoviedbapi.model2.movie.MovieBasic;
import java.util.List;
import org.junit.After;
import org.junit.AfterClass;
@ -84,7 +84,7 @@ public class TmdbCompaniesTest extends AbstractTests {
@Test
public void testGetCompanyMovies() throws MovieDbException {
LOG.info("getCompanyMovies");
List<MovieFavorite> result = instance.getCompanyMovies(ID_COMPANY, LANGUAGE_DEFAULT, 0);
List<MovieBasic> result = instance.getCompanyMovies(ID_COMPANY, LANGUAGE_DEFAULT, 0);
assertFalse("No company movies found", result.isEmpty());
}
}

@ -29,7 +29,7 @@ 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.MovieFavorite;
import com.omertron.themoviedbapi.model2.movie.MovieBasic;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import java.util.List;
import java.util.Random;
@ -313,12 +313,12 @@ public class TmdbMoviesTest extends AbstractTests {
// get all rated movies
TmdbAccount account = new TmdbAccount(getApiKey(), getHttpTools());
List<MovieFavorite> ratedMovies = account.getRatedMovies(getSessionId(), getAccountId(), null, null, null);
List<MovieBasic> ratedMovies = account.getRatedMovies(getSessionId(), getAccountId(), null, null, null);
assertTrue(ratedMovies.size() > 0);
// make sure that we find the movie and it is rated correctly
boolean foundMovie = false;
for (MovieFavorite movie : ratedMovies) {
for (MovieBasic movie : ratedMovies) {
if (movie.getId() == movieID) {
assertEquals("Incorrect rating", movie.getRating(), (float) rating, 0);
foundMovie = true;

Loading…
Cancel
Save