-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
209 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
src/test/java/info/movito/themoviedbapi/TmdbGenresTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Genre> 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<Genre> genres = tmdbGenre.getTvList("en"); | ||
assertNotNull(genres); | ||
assertFalse(genres.isEmpty()); | ||
|
||
Genre genre = genres.get(0); | ||
assertNotNull(genre); | ||
testForNullFieldsAndNewItems(genre); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
] | ||
} |