getMovieList(String language) throws TmdbException {
+ ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_GENRE, "movie/list");
apiUrl.addLanguage(language);
-
return mapJsonResult(apiUrl, Genres.class).genres;
}
/**
- * You can use this method to retrieve the list of of official genres for
- * TV shows used on TMDb.
+ * Get the list of official genres for TV shows.
+ * See the documentation for more info.
*
- * These IDs will correspond to those found in TV shows calls.
+ * @param language optional - The language, e.g. "en".
+ * @return The list of official genres for movies.
+ * @throws TmdbException If there was an error making the request or mapping the response.
*/
- public List getTvGenreList(String language) throws TmdbException {
- ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_GENRE, "tv", "list");
-
+ public List getTvList(String language) throws TmdbException {
+ ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_GENRE, "tv/list");
apiUrl.addLanguage(language);
-
return mapJsonResult(apiUrl, Genres.class).genres;
}
- /**
- * Get a list of movies per genre.
- *
- * It is important to understand that only movies with more than 10 votes get listed.
- *
- * This prevents movies from 1 10/10 rating from being listed first and for the first 5 pages.
- */
- public MovieDbResultsPage getGenreMovies(int genreId, String language, Integer page, boolean includeAllMovies)
- throws TmdbException {
- ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_GENRE, genreId, "movies");
-
- apiUrl.addLanguage(language);
-
- apiUrl.addPage(page);
-
- apiUrl.addPathParam(PARAM_INCLUDE_ALL_MOVIES, includeAllMovies);
-
- return mapJsonResult(apiUrl, MovieDbResultsPage.class);
- }
-
private static class Genres extends AbstractJsonMapping {
@JsonProperty("genres")
private List genres;
diff --git a/src/test/java/info/movito/themoviedbapi/TmdbGenresTest.java b/src/test/java/info/movito/themoviedbapi/TmdbGenresTest.java
new file mode 100644
index 0000000..191bc65
--- /dev/null
+++ b/src/test/java/info/movito/themoviedbapi/TmdbGenresTest.java
@@ -0,0 +1,61 @@
+package info.movito.themoviedbapi;
+
+import info.movito.themoviedbapi.model.Genre;
+import info.movito.themoviedbapi.tools.RequestType;
+import info.movito.themoviedbapi.tools.TmdbException;
+import info.movito.themoviedbapi.util.TestUtils;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+
+import static info.movito.themoviedbapi.TmdbGenre.TMDB_METHOD_GENRE;
+import static info.movito.themoviedbapi.tools.ApiUrl.TMDB_API_BASE_URL;
+import static info.movito.themoviedbapi.util.TestUtils.testForNullFieldsAndNewItems;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.mockito.Mockito.when;
+
+/**
+ * Tests for {@link TmdbGenre}.
+ */
+public class TmdbGenresTest extends AbstractTmdbApiTest {
+ /**
+ * Tests {@link TmdbGenre#getMovieList(String)} with an expected result.
+ */
+ @Test
+ public void testGetMovieList() throws IOException, TmdbException {
+ String body = TestUtils.readTestFile("api_responses/genres/movie_list.json");
+ URL url = new URL(TMDB_API_BASE_URL + TMDB_METHOD_GENRE + "/movie/list?language=en");
+ when(getTmdbUrlReader().readUrl(url, null, RequestType.GET)).thenReturn(body);
+
+ TmdbGenre tmdbGenre = new TmdbGenre(getTmdbApi());
+ List genres = tmdbGenre.getMovieList("en");
+ assertNotNull(genres);
+ assertFalse(genres.isEmpty());
+
+ Genre genre = genres.get(0);
+ assertNotNull(genre);
+ testForNullFieldsAndNewItems(genre);
+ }
+
+ /**
+ * Tests {@link TmdbGenre#getTvList(String)} with an expected result.
+ */
+ @Test
+ public void testGetTvList() throws IOException, TmdbException {
+ String body = TestUtils.readTestFile("api_responses/genres/tv_list.json");
+ URL url = new URL(TMDB_API_BASE_URL + TMDB_METHOD_GENRE + "/tv/list?language=en");
+ when(getTmdbUrlReader().readUrl(url, null, RequestType.GET)).thenReturn(body);
+
+ TmdbGenre tmdbGenre = new TmdbGenre(getTmdbApi());
+ List genres = tmdbGenre.getTvList("en");
+ assertNotNull(genres);
+ assertFalse(genres.isEmpty());
+
+ Genre genre = genres.get(0);
+ assertNotNull(genre);
+ testForNullFieldsAndNewItems(genre);
+ }
+}
diff --git a/src/test/resources/api_responses/genres/movie_list.json b/src/test/resources/api_responses/genres/movie_list.json
new file mode 100644
index 0000000..1c110c1
--- /dev/null
+++ b/src/test/resources/api_responses/genres/movie_list.json
@@ -0,0 +1,80 @@
+{
+ "genres": [
+ {
+ "id": 28,
+ "name": "Action"
+ },
+ {
+ "id": 12,
+ "name": "Abenteuer"
+ },
+ {
+ "id": 16,
+ "name": "Animation"
+ },
+ {
+ "id": 35,
+ "name": "Komödie"
+ },
+ {
+ "id": 80,
+ "name": "Krimi"
+ },
+ {
+ "id": 99,
+ "name": "Dokumentarfilm"
+ },
+ {
+ "id": 18,
+ "name": "Drama"
+ },
+ {
+ "id": 10751,
+ "name": "Familie"
+ },
+ {
+ "id": 14,
+ "name": "Fantasy"
+ },
+ {
+ "id": 36,
+ "name": "Historie"
+ },
+ {
+ "id": 27,
+ "name": "Horror"
+ },
+ {
+ "id": 10402,
+ "name": "Musik"
+ },
+ {
+ "id": 9648,
+ "name": "Mystery"
+ },
+ {
+ "id": 10749,
+ "name": "Liebesfilm"
+ },
+ {
+ "id": 878,
+ "name": "Science Fiction"
+ },
+ {
+ "id": 10770,
+ "name": "TV-Film"
+ },
+ {
+ "id": 53,
+ "name": "Thriller"
+ },
+ {
+ "id": 10752,
+ "name": "Kriegsfilm"
+ },
+ {
+ "id": 37,
+ "name": "Western"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/src/test/resources/api_responses/genres/tv_list.json b/src/test/resources/api_responses/genres/tv_list.json
new file mode 100644
index 0000000..5d3a4ca
--- /dev/null
+++ b/src/test/resources/api_responses/genres/tv_list.json
@@ -0,0 +1,68 @@
+{
+ "genres": [
+ {
+ "id": 10759,
+ "name": "Action & Adventure"
+ },
+ {
+ "id": 16,
+ "name": "Animation"
+ },
+ {
+ "id": 35,
+ "name": "Komödie"
+ },
+ {
+ "id": 80,
+ "name": "Krimi"
+ },
+ {
+ "id": 99,
+ "name": "Dokumentarfilm"
+ },
+ {
+ "id": 18,
+ "name": "Drama"
+ },
+ {
+ "id": 10751,
+ "name": "Familie"
+ },
+ {
+ "id": 10762,
+ "name": "Kids"
+ },
+ {
+ "id": 9648,
+ "name": "Mystery"
+ },
+ {
+ "id": 10763,
+ "name": "News"
+ },
+ {
+ "id": 10764,
+ "name": "Reality"
+ },
+ {
+ "id": 10765,
+ "name": "Sci-Fi & Fantasy"
+ },
+ {
+ "id": 10766,
+ "name": "Soap"
+ },
+ {
+ "id": 10767,
+ "name": "Talk"
+ },
+ {
+ "id": 10768,
+ "name": "War & Politics"
+ },
+ {
+ "id": 37,
+ "name": "Western"
+ }
+ ]
+}
\ No newline at end of file