master
Stuart Boston 11 years ago
parent 69d2eba4db
commit 410df1f056

@ -46,7 +46,7 @@ import com.omertron.themoviedbapi.model.Certification;
import com.omertron.themoviedbapi.model.change.ChangedMedia;
import com.omertron.themoviedbapi.model2.collection.Collection;
import com.omertron.themoviedbapi.model2.collection.CollectionInfo;
import com.omertron.themoviedbapi.model.Company;
import com.omertron.themoviedbapi.model2.company.Company;
import com.omertron.themoviedbapi.model2.Configuration;
import com.omertron.themoviedbapi.model.discover.Discover;
import com.omertron.themoviedbapi.model.Genre;
@ -602,7 +602,7 @@ public class TheMovieDbApi {
* @return
* @throws MovieDbException
*/
public TmdbResultsList<MovieDb> getCompanyMovies(int companyId, String language, int page) throws MovieDbException {
public List<MovieFavorite> getCompanyMovies(int companyId, String language, int page) throws MovieDbException {
return tmdbCompany.getCompanyMovies(companyId, language, page);
}
//</editor-fold>

@ -20,18 +20,17 @@
package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model.Company;
import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import com.omertron.themoviedbapi.model2.company.Company;
import com.omertron.themoviedbapi.model2.movie.MovieFavorite;
import com.omertron.themoviedbapi.tools.ApiUrl;
import com.omertron.themoviedbapi.tools.HttpTools;
import com.omertron.themoviedbapi.tools.MethodBase;
import com.omertron.themoviedbapi.tools.MethodSub;
import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import com.omertron.themoviedbapi.wrapper.WrapperCompanyMovies;
import java.io.IOException;
import java.net.URL;
import java.util.List;
import org.yamj.api.common.exception.ApiExceptionType;
/**
@ -52,8 +51,7 @@ public class TmdbCompanies extends AbstractMethod {
}
/**
* This method is used to retrieve the basic information about a production
* company on TMDb.
* This method is used to retrieve the basic information about a production company on TMDb.
*
* @param companyId
* @return
@ -76,8 +74,7 @@ public class TmdbCompanies extends AbstractMethod {
/**
* This method is used to retrieve the movies associated with a company.
*
* These movies are returned in order of most recently released to oldest.
* The default response will return 20 movies per page.
* These movies are returned in order of most recently released to oldest. The default response will return 20 movies per page.
*
* TODO: Implement more than 20 movies
*
@ -87,7 +84,7 @@ public class TmdbCompanies extends AbstractMethod {
* @return
* @throws MovieDbException
*/
public TmdbResultsList<MovieDb> getCompanyMovies(int companyId, String language, int page) throws MovieDbException {
public List<MovieFavorite> getCompanyMovies(int companyId, String language, Integer page) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, companyId);
parameters.add(Param.LANGUAGE, language);
@ -95,15 +92,7 @@ public class TmdbCompanies extends AbstractMethod {
URL url = new ApiUrl(apiKey, MethodBase.COMPANY).setSubMethod(MethodSub.MOVIES).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
WrapperCompanyMovies wrapper = MAPPER.readValue(webpage, WrapperCompanyMovies.class);
TmdbResultsList<MovieDb> results = new TmdbResultsList<MovieDb>(wrapper.getResults());
results.copyWrapper(wrapper);
return results;
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get company movies", url, ex);
}
return processWrapperList(TR_MOVIE_FAV, url, webpage);
}
}

@ -21,7 +21,7 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model2.collection.Collection;
import com.omertron.themoviedbapi.model.Company;
import com.omertron.themoviedbapi.model2.company.Company;
import com.omertron.themoviedbapi.model.keyword.Keyword;
import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.model.MovieList;

@ -17,10 +17,11 @@
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
package com.omertron.themoviedbapi.model2.company;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
/**
* Company information

@ -20,7 +20,7 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Company;
import com.omertron.themoviedbapi.model2.company.Company;
import java.util.List;
/**

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

@ -24,7 +24,7 @@ import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model.change.ChangedMedia;
import com.omertron.themoviedbapi.model2.collection.Collection;
import com.omertron.themoviedbapi.model2.collection.CollectionInfo;
import com.omertron.themoviedbapi.model.Company;
import com.omertron.themoviedbapi.model2.company.Company;
import com.omertron.themoviedbapi.model.discover.Discover;
import com.omertron.themoviedbapi.model.Genre;
import com.omertron.themoviedbapi.model2.JobDepartment;

@ -21,11 +21,12 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model.Company;
import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import com.omertron.themoviedbapi.model2.company.Company;
import com.omertron.themoviedbapi.model2.movie.MovieFavorite;
import java.util.List;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
@ -83,7 +84,7 @@ public class TmdbCompaniesTest extends AbstractTests {
@Test
public void testGetCompanyMovies() throws MovieDbException {
LOG.info("getCompanyMovies");
TmdbResultsList<MovieDb> result = instance.getCompanyMovies(ID_COMPANY, LANGUAGE_DEFAULT, 0);
assertTrue("No company movies found", !result.isEmpty());
List<MovieFavorite> result = instance.getCompanyMovies(ID_COMPANY, LANGUAGE_DEFAULT, 0);
assertFalse("No company movies found", result.isEmpty());
}
}

@ -22,7 +22,7 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model2.collection.Collection;
import com.omertron.themoviedbapi.model.Company;
import com.omertron.themoviedbapi.model2.company.Company;
import com.omertron.themoviedbapi.model.keyword.Keyword;
import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.model.MovieList;

Loading…
Cancel
Save