Added new searches

master
Omertron 13 years ago
parent 1009e2598e
commit 44d63fbf76

@ -24,6 +24,7 @@ import com.omertron.themoviedbapi.MovieDbException.MovieDbExceptionType;
import com.omertron.themoviedbapi.model.AlternativeTitle; import com.omertron.themoviedbapi.model.AlternativeTitle;
import com.omertron.themoviedbapi.model.Artwork; import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model.ArtworkType; import com.omertron.themoviedbapi.model.ArtworkType;
import com.omertron.themoviedbapi.model.Collection;
import com.omertron.themoviedbapi.model.CollectionInfo; import com.omertron.themoviedbapi.model.CollectionInfo;
import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model.Company;
import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.Genre;
@ -48,6 +49,7 @@ import com.omertron.themoviedbapi.tools.FilteringLayout;
import com.omertron.themoviedbapi.tools.WebBrowser; import com.omertron.themoviedbapi.tools.WebBrowser;
import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles; import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles;
import com.omertron.themoviedbapi.wrapper.WrapperChanges; import com.omertron.themoviedbapi.wrapper.WrapperChanges;
import com.omertron.themoviedbapi.wrapper.WrapperCollection;
import com.omertron.themoviedbapi.wrapper.WrapperCompany; import com.omertron.themoviedbapi.wrapper.WrapperCompany;
import com.omertron.themoviedbapi.wrapper.WrapperCompanyMovies; import com.omertron.themoviedbapi.wrapper.WrapperCompanyMovies;
import com.omertron.themoviedbapi.wrapper.WrapperConfig; import com.omertron.themoviedbapi.wrapper.WrapperConfig;
@ -1332,33 +1334,37 @@ public class TheMovieDbApi {
} }
/** /**
* Search Companies. * Search for collections by name.
*
* You can use this method to search for production companies that are part of TMDb. The company IDs will map to
* those returned on movie calls.
*
* http://help.themoviedb.org/kb/api/search-companies
* *
* @param companyName * @param query
* @param language
* @param page * @param page
* @return * @return
* @throws MovieDbException * @throws MovieDbException
*/ */
public List<Company> searchCompanies(String companyName, int page) throws MovieDbException { public List<Collection> searchCollection(String query, String language, int page) throws MovieDbException {
ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "company"); ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "collections");
apiUrl.addArgument(PARAM_QUERY, companyName);
if (StringUtils.isNotBlank(query)) {
apiUrl.addArgument(PARAM_QUERY, query);
}
if (StringUtils.isNotBlank(language)) {
apiUrl.addArgument(PARAM_LANGUAGE, language);
}
if (page > 0) { if (page > 0) {
apiUrl.addArgument(PARAM_PAGE, page); apiUrl.addArgument(PARAM_PAGE, Integer.toString(page));
} }
URL url = apiUrl.buildUrl(); URL url = apiUrl.buildUrl();
String webpage = WebBrowser.request(url); String webpage = WebBrowser.request(url);
try { try {
WrapperCompany wrapper = mapper.readValue(webpage, WrapperCompany.class); WrapperCollection wrapper = mapper.readValue(webpage, WrapperCollection.class);
return wrapper.getResults(); return wrapper.getResults();
} catch (IOException ex) { } catch (IOException ex) {
logger.warn("Failed to find company: " + ex.getMessage()); logger.warn("Failed to find collection: " + ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
} }
} }
@ -1395,5 +1401,78 @@ public class TheMovieDbApi {
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
} }
} }
/**
* Search for lists by name and description.
*
* @param query
* @param language
* @param page
* @throws MovieDbException
*/
public List<MovieList> searchList(String query, String language, int page) throws MovieDbException {
ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "list");
if (StringUtils.isNotBlank(query)) {
apiUrl.addArgument(PARAM_QUERY, query);
}
if (StringUtils.isNotBlank(language)) {
apiUrl.addArgument(PARAM_LANGUAGE, language);
}
if (page > 0) {
apiUrl.addArgument(PARAM_PAGE, Integer.toString(page));
}
URL url = apiUrl.buildUrl();
String webpage = WebBrowser.request(url);
try {
WrapperMovieList wrapper = mapper.readValue(webpage, WrapperMovieList.class);
return wrapper.getMovieList();
} catch (IOException ex) {
logger.warn("Failed to find list: " + ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
}
}
/**
* Search Companies.
*
* You can use this method to search for production companies that are part of TMDb. The company IDs will map to
* those returned on movie calls.
*
* http://help.themoviedb.org/kb/api/search-companies
*
* @param companyName
* @param page
* @return
* @throws MovieDbException
*/
public List<Company> searchCompanies(String companyName, int page) throws MovieDbException {
ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "company");
apiUrl.addArgument(PARAM_QUERY, companyName);
if (page > 0) {
apiUrl.addArgument(PARAM_PAGE, page);
}
URL url = apiUrl.buildUrl();
String webpage = WebBrowser.request(url);
try {
WrapperCompany wrapper = mapper.readValue(webpage, WrapperCompany.class);
return wrapper.getResults();
} catch (IOException ex) {
logger.warn("Failed to find company: " + ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
}
}
public void searchKeyword() {
}
//</editor-fold> //</editor-fold>
//
// List Functions
// Keywords Functions
} }

@ -53,6 +53,8 @@ public class MovieList implements Serializable {
private String name; private String name;
@JsonProperty("poster_path") @JsonProperty("poster_path")
private String posterPath; private String posterPath;
@JsonProperty("list_type")
private String listType;
// <editor-fold defaultstate="collapsed" desc="Getter methods"> // <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getDescription() { public String getDescription() {
@ -83,6 +85,9 @@ public class MovieList implements Serializable {
return posterPath; return posterPath;
} }
public String getListType() {
return listType;
}
// </editor-fold> // </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods"> // <editor-fold defaultstate="collapsed" desc="Setter methods">
@ -114,6 +119,9 @@ public class MovieList implements Serializable {
this.posterPath = posterPath; this.posterPath = posterPath;
} }
public void setListType(String listType) {
this.listType = listType;
}
// </editor-fold> // </editor-fold>
/** /**

@ -0,0 +1,100 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Collection;
import com.omertron.themoviedbapi.model.MovieChanges;
import java.util.List;
import org.apache.log4j.Logger;
/**
*
* @author stuart.boston
*/
public class WrapperCollection {
/*
* Logger
*/
private static final Logger logger = Logger.getLogger(WrapperCollection.class);
/*
* Properties
*/
@JsonProperty("page")
private int page;
@JsonProperty("results")
private List<Collection> results;
@JsonProperty("total_pages")
private int totalPages;
@JsonProperty("total_results")
private int totalResults;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getPage() {
return page;
}
public List<Collection> getResults() {
return results;
}
public int getTotalPages() {
return totalPages;
}
public int getTotalResults() {
return totalResults;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setPage(int page) {
this.page = page;
}
public void setResults(List<Collection> results) {
this.results = results;
}
public void setTotalPages(int totalPages) {
this.totalPages = totalPages;
}
public void setTotalResults(int totalResults) {
this.totalResults = totalResults;
}
//</editor-fold>
/**
* 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());
}
}

@ -21,6 +21,7 @@ package com.omertron.themoviedbapi;
import com.omertron.themoviedbapi.model.AlternativeTitle; import com.omertron.themoviedbapi.model.AlternativeTitle;
import com.omertron.themoviedbapi.model.Artwork; import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model.Collection;
import com.omertron.themoviedbapi.model.CollectionInfo; import com.omertron.themoviedbapi.model.CollectionInfo;
import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model.Company;
import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.Genre;
@ -93,7 +94,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getConfiguration method, of class TheMovieDbApi. * Test of getConfiguration method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testConfiguration() throws IOException { public void testConfiguration() throws IOException {
logger.info("Test Configuration"); logger.info("Test Configuration");
@ -109,7 +110,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of searchMovie method, of class TheMovieDbApi. * Test of searchMovie method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testSearchMovie() throws MovieDbException { public void testSearchMovie() throws MovieDbException {
logger.info("searchMovie"); logger.info("searchMovie");
@ -130,7 +131,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieInfo method, of class TheMovieDbApi. * Test of getMovieInfo method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetMovieInfo() throws MovieDbException { public void testGetMovieInfo() throws MovieDbException {
logger.info("getMovieInfo"); logger.info("getMovieInfo");
String language = "en"; String language = "en";
@ -141,7 +142,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieAlternativeTitles method, of class TheMovieDbApi. * Test of getMovieAlternativeTitles method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetMovieAlternativeTitles() throws MovieDbException { public void testGetMovieAlternativeTitles() throws MovieDbException {
logger.info("getMovieAlternativeTitles"); logger.info("getMovieAlternativeTitles");
String country = ""; String country = "";
@ -157,7 +158,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieCasts method, of class TheMovieDbApi. * Test of getMovieCasts method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetMovieCasts() throws MovieDbException { public void testGetMovieCasts() throws MovieDbException {
logger.info("getMovieCasts"); logger.info("getMovieCasts");
List<Person> people = tmdb.getMovieCasts(ID_MOVIE_BLADE_RUNNER); List<Person> people = tmdb.getMovieCasts(ID_MOVIE_BLADE_RUNNER);
@ -184,7 +185,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieImages method, of class TheMovieDbApi. * Test of getMovieImages method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetMovieImages() throws MovieDbException { public void testGetMovieImages() throws MovieDbException {
logger.info("getMovieImages"); logger.info("getMovieImages");
String language = ""; String language = "";
@ -195,7 +196,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieKeywords method, of class TheMovieDbApi. * Test of getMovieKeywords method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetMovieKeywords() throws MovieDbException { public void testGetMovieKeywords() throws MovieDbException {
logger.info("getMovieKeywords"); logger.info("getMovieKeywords");
List<Keyword> result = tmdb.getMovieKeywords(ID_MOVIE_BLADE_RUNNER); List<Keyword> result = tmdb.getMovieKeywords(ID_MOVIE_BLADE_RUNNER);
@ -205,7 +206,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieReleaseInfo method, of class TheMovieDbApi. * Test of getMovieReleaseInfo method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetMovieReleaseInfo() throws MovieDbException { public void testGetMovieReleaseInfo() throws MovieDbException {
logger.info("getMovieReleaseInfo"); logger.info("getMovieReleaseInfo");
List<ReleaseInfo> result = tmdb.getMovieReleaseInfo(ID_MOVIE_BLADE_RUNNER, ""); List<ReleaseInfo> result = tmdb.getMovieReleaseInfo(ID_MOVIE_BLADE_RUNNER, "");
@ -215,7 +216,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieTrailers method, of class TheMovieDbApi. * Test of getMovieTrailers method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetMovieTrailers() throws MovieDbException { public void testGetMovieTrailers() throws MovieDbException {
logger.info("getMovieTrailers"); logger.info("getMovieTrailers");
List<Trailer> result = tmdb.getMovieTrailers(ID_MOVIE_BLADE_RUNNER, ""); List<Trailer> result = tmdb.getMovieTrailers(ID_MOVIE_BLADE_RUNNER, "");
@ -225,7 +226,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieTranslations method, of class TheMovieDbApi. * Test of getMovieTranslations method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetMovieTranslations() throws MovieDbException { public void testGetMovieTranslations() throws MovieDbException {
logger.info("getMovieTranslations"); logger.info("getMovieTranslations");
List<Translation> result = tmdb.getMovieTranslations(ID_MOVIE_BLADE_RUNNER); List<Translation> result = tmdb.getMovieTranslations(ID_MOVIE_BLADE_RUNNER);
@ -235,7 +236,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getCollectionInfo method, of class TheMovieDbApi. * Test of getCollectionInfo method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetCollectionInfo() throws MovieDbException { public void testGetCollectionInfo() throws MovieDbException {
logger.info("getCollectionInfo"); logger.info("getCollectionInfo");
String language = ""; String language = "";
@ -248,7 +249,7 @@ public class TheMovieDbApiTest {
* *
* @throws MovieDbException * @throws MovieDbException
*/ */
@Test //@Test
public void testCreateImageUrl() throws MovieDbException { public void testCreateImageUrl() throws MovieDbException {
logger.info("createImageUrl"); logger.info("createImageUrl");
MovieDb movie = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, ""); MovieDb movie = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, "");
@ -259,7 +260,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieInfoImdb method, of class TheMovieDbApi. * Test of getMovieInfoImdb method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetMovieInfoImdb() throws MovieDbException { public void testGetMovieInfoImdb() throws MovieDbException {
logger.info("getMovieInfoImdb"); logger.info("getMovieInfoImdb");
MovieDb result = tmdb.getMovieInfoImdb("tt0076759", "en-US"); MovieDb result = tmdb.getMovieInfoImdb("tt0076759", "en-US");
@ -269,7 +270,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getApiKey method, of class TheMovieDbApi. * Test of getApiKey method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetApiKey() { public void testGetApiKey() {
// Not required // Not required
} }
@ -277,7 +278,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getApiBase method, of class TheMovieDbApi. * Test of getApiBase method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetApiBase() { public void testGetApiBase() {
// Not required // Not required
} }
@ -285,7 +286,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getConfiguration method, of class TheMovieDbApi. * Test of getConfiguration method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetConfiguration() { public void testGetConfiguration() {
// Not required // Not required
} }
@ -293,7 +294,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of searchPeople method, of class TheMovieDbApi. * Test of searchPeople method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testSearchPeople() throws MovieDbException { public void testSearchPeople() throws MovieDbException {
logger.info("searchPeople"); logger.info("searchPeople");
String personName = "Bruce Willis"; String personName = "Bruce Willis";
@ -305,7 +306,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getPersonInfo method, of class TheMovieDbApi. * Test of getPersonInfo method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetPersonInfo() throws MovieDbException { public void testGetPersonInfo() throws MovieDbException {
logger.info("getPersonInfo"); logger.info("getPersonInfo");
Person result = tmdb.getPersonInfo(ID_PERSON_BRUCE_WILLIS); Person result = tmdb.getPersonInfo(ID_PERSON_BRUCE_WILLIS);
@ -315,7 +316,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getPersonCredits method, of class TheMovieDbApi. * Test of getPersonCredits method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetPersonCredits() throws MovieDbException { public void testGetPersonCredits() throws MovieDbException {
logger.info("getPersonCredits"); logger.info("getPersonCredits");
@ -326,7 +327,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getPersonImages method, of class TheMovieDbApi. * Test of getPersonImages method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetPersonImages() throws MovieDbException { public void testGetPersonImages() throws MovieDbException {
logger.info("getPersonImages"); logger.info("getPersonImages");
@ -337,7 +338,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getLatestMovie method, of class TheMovieDbApi. * Test of getLatestMovie method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetLatestMovie() throws MovieDbException { public void testGetLatestMovie() throws MovieDbException {
logger.info("getLatestMovie"); logger.info("getLatestMovie");
MovieDb result = tmdb.getLatestMovie(); MovieDb result = tmdb.getLatestMovie();
@ -348,7 +349,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of compareMovies method, of class TheMovieDbApi. * Test of compareMovies method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testCompareMovies() { public void testCompareMovies() {
// Not required // Not required
} }
@ -356,7 +357,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of setProxy method, of class TheMovieDbApi. * Test of setProxy method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testSetProxy() { public void testSetProxy() {
// Not required // Not required
} }
@ -364,7 +365,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of setTimeout method, of class TheMovieDbApi. * Test of setTimeout method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testSetTimeout() { public void testSetTimeout() {
// Not required // Not required
} }
@ -372,7 +373,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getNowPlayingMovies method, of class TheMovieDbApi. * Test of getNowPlayingMovies method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetNowPlayingMovies() throws MovieDbException { public void testGetNowPlayingMovies() throws MovieDbException {
logger.info("getNowPlayingMovies"); logger.info("getNowPlayingMovies");
List<MovieDb> results = tmdb.getNowPlayingMovies("", 0); List<MovieDb> results = tmdb.getNowPlayingMovies("", 0);
@ -382,7 +383,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getPopularMovieList method, of class TheMovieDbApi. * Test of getPopularMovieList method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetPopularMovieList() throws MovieDbException { public void testGetPopularMovieList() throws MovieDbException {
logger.info("getPopularMovieList"); logger.info("getPopularMovieList");
List<MovieDb> results = tmdb.getPopularMovieList("", 0); List<MovieDb> results = tmdb.getPopularMovieList("", 0);
@ -392,7 +393,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getTopRatedMovies method, of class TheMovieDbApi. * Test of getTopRatedMovies method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetTopRatedMovies() throws MovieDbException { public void testGetTopRatedMovies() throws MovieDbException {
logger.info("getTopRatedMovies"); logger.info("getTopRatedMovies");
List<MovieDb> results = tmdb.getTopRatedMovies("", 0); List<MovieDb> results = tmdb.getTopRatedMovies("", 0);
@ -402,7 +403,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getCompanyInfo method, of class TheMovieDbApi. * Test of getCompanyInfo method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetCompanyInfo() throws MovieDbException { public void testGetCompanyInfo() throws MovieDbException {
logger.info("getCompanyInfo"); logger.info("getCompanyInfo");
Company company = tmdb.getCompanyInfo(ID_COMPANY_LUCASFILM); Company company = tmdb.getCompanyInfo(ID_COMPANY_LUCASFILM);
@ -412,7 +413,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getCompanyMovies method, of class TheMovieDbApi. * Test of getCompanyMovies method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetCompanyMovies() throws MovieDbException { public void testGetCompanyMovies() throws MovieDbException {
logger.info("getCompanyMovies"); logger.info("getCompanyMovies");
List<MovieDb> results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, "", 0); List<MovieDb> results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, "", 0);
@ -422,7 +423,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of searchCompanies method, of class TheMovieDbApi. * Test of searchCompanies method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testSearchCompanies() throws MovieDbException { public void testSearchCompanies() throws MovieDbException {
logger.info("searchCompanies"); logger.info("searchCompanies");
List<Company> results = tmdb.searchCompanies(COMPANY_NAME, 0); List<Company> results = tmdb.searchCompanies(COMPANY_NAME, 0);
@ -432,7 +433,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getSimilarMovies method, of class TheMovieDbApi. * Test of getSimilarMovies method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetSimilarMovies() throws MovieDbException { public void testGetSimilarMovies() throws MovieDbException {
logger.info("getSimilarMovies"); logger.info("getSimilarMovies");
List<MovieDb> results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, "", 0); List<MovieDb> results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, "", 0);
@ -442,7 +443,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getGenreList method, of class TheMovieDbApi. * Test of getGenreList method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetGenreList() throws MovieDbException { public void testGetGenreList() throws MovieDbException {
logger.info("getGenreList"); logger.info("getGenreList");
List<Genre> results = tmdb.getGenreList(""); List<Genre> results = tmdb.getGenreList("");
@ -452,7 +453,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getGenreMovies method, of class TheMovieDbApi. * Test of getGenreMovies method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetGenreMovies() throws MovieDbException { public void testGetGenreMovies() throws MovieDbException {
logger.info("getGenreMovies"); logger.info("getGenreMovies");
List<MovieDb> results = tmdb.getGenreMovies(ID_GENRE_ACTION, "", 0); List<MovieDb> results = tmdb.getGenreMovies(ID_GENRE_ACTION, "", 0);
@ -462,7 +463,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getUpcoming method, of class TheMovieDbApi. * Test of getUpcoming method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetUpcoming() throws Exception { public void testGetUpcoming() throws Exception {
logger.info("getUpcoming"); logger.info("getUpcoming");
List<MovieDb> results = tmdb.getUpcoming("", 0); List<MovieDb> results = tmdb.getUpcoming("", 0);
@ -472,7 +473,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getCollectionImages method, of class TheMovieDbApi. * Test of getCollectionImages method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetCollectionImages() throws Exception { public void testGetCollectionImages() throws Exception {
logger.info("getCollectionImages"); logger.info("getCollectionImages");
String language = ""; String language = "";
@ -483,7 +484,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getAuthorisationToken method, of class TheMovieDbApi. * Test of getAuthorisationToken method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetAuthorisationToken() throws Exception { public void testGetAuthorisationToken() throws Exception {
logger.info("getAuthorisationToken"); logger.info("getAuthorisationToken");
TokenAuthorisation result = tmdb.getAuthorisationToken(); TokenAuthorisation result = tmdb.getAuthorisationToken();
@ -496,7 +497,7 @@ public class TheMovieDbApiTest {
* Test of getSessionToken method, of class TheMovieDbApi. * Test of getSessionToken method, of class TheMovieDbApi.
*/ */
// Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication // Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication
// @Test // //@Test
public void testGetSessionToken() throws Exception { public void testGetSessionToken() throws Exception {
logger.info("getSessionToken"); logger.info("getSessionToken");
TokenAuthorisation token = tmdb.getAuthorisationToken(); TokenAuthorisation token = tmdb.getAuthorisationToken();
@ -513,7 +514,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getGuestSessionToken method, of class TheMovieDbApi. * Test of getGuestSessionToken method, of class TheMovieDbApi.
*/ */
@Test //@Test
public void testGetGuestSessionToken() throws Exception { public void testGetGuestSessionToken() throws Exception {
logger.info("getGuestSessionToken"); logger.info("getGuestSessionToken");
TokenSession result = tmdb.getGuestSessionToken(); TokenSession result = tmdb.getGuestSessionToken();
@ -521,7 +522,7 @@ public class TheMovieDbApiTest {
assertTrue("Failed to get guest session", result.getSuccess()); assertTrue("Failed to get guest session", result.getSuccess());
} }
@Test //@Test
public void testGetMovieLists() throws Exception { public void testGetMovieLists() throws Exception {
logger.info("getMovieLists"); logger.info("getMovieLists");
String language = "en"; String language = "en";
@ -531,7 +532,6 @@ public class TheMovieDbApiTest {
} }
// Do not test this until it is fixed // Do not test this until it is fixed
// @Test
public void testGetMovieChanges() throws Exception { public void testGetMovieChanges() throws Exception {
logger.info("getMovieChanges"); logger.info("getMovieChanges");
@ -550,7 +550,7 @@ public class TheMovieDbApiTest {
assertTrue("No results found", results.size() > 0); assertTrue("No results found", results.size() > 0);
} }
@Test //@Test
public void testGetPersonLatest() throws Exception { public void testGetPersonLatest() throws Exception {
logger.info("getPersonLatest"); logger.info("getPersonLatest");
@ -559,4 +559,44 @@ public class TheMovieDbApiTest {
assertNotNull("No results found", result); assertNotNull("No results found", result);
assertTrue("No results found", StringUtils.isNotBlank(result.getName())); assertTrue("No results found", StringUtils.isNotBlank(result.getName()));
} }
/**
* Test of searchCollection method, of class TheMovieDbApi.
*/
//@Test
public void testSearchCollection() throws Exception {
logger.info("searchCollection");
String query = "batman";
String language = "";
int page = 0;
List<Collection> result = tmdb.searchCollection(query, language, page);
assertFalse("No collections found", result == null);
assertTrue("No collections found", result.size() > 0);
}
/**
* Test of searchList method, of class TheMovieDbApi.
*/
//@Test
public void testSearchList() throws Exception {
System.out.println("searchList");
String query = "watch";
String language = "";
int page = 0;
List result = tmdb.searchList(query, language, page);
assertFalse("No lists found", result == null);
assertTrue("No lists found", result.size() > 0);
}
/**
* Test of searchKeyword method, of class TheMovieDbApi.
*/
@Test
public void testSearchKeyword() {
System.out.println("searchKeyword");
TheMovieDbApi instance = null;
instance.searchKeyword();
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
} }

Loading…
Cancel
Save