diff --git a/src/main/java/info/movito/themoviedbapi/TmdbConfiguration.java b/src/main/java/info/movito/themoviedbapi/TmdbConfiguration.java index 41418d7..10928bb 100644 --- a/src/main/java/info/movito/themoviedbapi/TmdbConfiguration.java +++ b/src/main/java/info/movito/themoviedbapi/TmdbConfiguration.java @@ -32,7 +32,7 @@ public class TmdbConfiguration extends AbstractTmdbApi { * @return The configuration details * @throws TmdbException If there was an error making the request or mapping the response. */ - public Configuration getConfig() throws TmdbException { + public Configuration getDetails() throws TmdbException { ApiUrl apiUrl = new ApiUrl(TMDB_METHOD_CONFIGURATION); return mapJsonResult(apiUrl, Configuration.class); } diff --git a/src/main/java/info/movito/themoviedbapi/TmdbMovies.java b/src/main/java/info/movito/themoviedbapi/TmdbMovies.java index 8984e10..3dca9d4 100644 --- a/src/main/java/info/movito/themoviedbapi/TmdbMovies.java +++ b/src/main/java/info/movito/themoviedbapi/TmdbMovies.java @@ -307,7 +307,7 @@ public ProviderResults getWatchProviders(int movieId) throws TmdbException { * @param movieId The TMDb id of the movie. * @param guestSessionId optional - The guest session id of the user. * @param sessionId optional - The session id of the user. - * @param rating The rating of the movie. Must be: 0 < rating <= 10. + * @param rating The rating of the movie. Must be: 0 < rating ≦ 10. * @return The response status. * @throws TmdbException If there was an error making the request or mapping the response. */ diff --git a/src/main/java/info/movito/themoviedbapi/model/ReleaseDate.java b/src/main/java/info/movito/themoviedbapi/model/ReleaseDate.java index 14d5f61..ccbc9b5 100644 --- a/src/main/java/info/movito/themoviedbapi/model/ReleaseDate.java +++ b/src/main/java/info/movito/themoviedbapi/model/ReleaseDate.java @@ -15,7 +15,7 @@ public class ReleaseDate extends AbstractJsonMapping { private String certification; @JsonProperty("descriptors") - private List descriptors; + private List descriptors; @JsonProperty("iso_639_1") private String language; diff --git a/src/main/java/info/movito/themoviedbapi/model/account/Avatar.java b/src/main/java/info/movito/themoviedbapi/model/account/Avatar.java index 0d66601..e2a2287 100644 --- a/src/main/java/info/movito/themoviedbapi/model/account/Avatar.java +++ b/src/main/java/info/movito/themoviedbapi/model/account/Avatar.java @@ -5,16 +5,16 @@ import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.HashMap; +import java.util.Map; @Data @EqualsAndHashCode(callSuper = false) public class Avatar extends AbstractJsonMapping { @JsonProperty("gravatar") - private HashMap gravatar; + private Map gravatar; @JsonProperty("tmdb") - private HashMap tmdb; + private Map tmdb; public String getGravatarHash() { return gravatar.get("hash"); diff --git a/src/main/java/info/movito/themoviedbapi/model/configuration/ImageConfig.java b/src/main/java/info/movito/themoviedbapi/model/configuration/ImageConfig.java index 60f828a..7856f7f 100644 --- a/src/main/java/info/movito/themoviedbapi/model/configuration/ImageConfig.java +++ b/src/main/java/info/movito/themoviedbapi/model/configuration/ImageConfig.java @@ -29,6 +29,9 @@ public class ImageConfig extends AbstractJsonMapping { @JsonProperty("logo_sizes") private List logoSizes; + @JsonProperty("still_sizes") + private List stillSizes; + /** * Check that the poster size is valid. */ diff --git a/src/main/java/info/movito/themoviedbapi/model/core/MovieResultsPage.java b/src/main/java/info/movito/themoviedbapi/model/core/MovieResultsPage.java index 48a2144..eb197bb 100644 --- a/src/main/java/info/movito/themoviedbapi/model/core/MovieResultsPage.java +++ b/src/main/java/info/movito/themoviedbapi/model/core/MovieResultsPage.java @@ -1,3 +1,5 @@ package info.movito.themoviedbapi.model.core; -public class MovieResultsPage extends ResultsPage { } +public class MovieResultsPage extends ResultsPage { + +} diff --git a/src/main/java/info/movito/themoviedbapi/model/movies/MovieDb.java b/src/main/java/info/movito/themoviedbapi/model/movies/MovieDb.java index f7d609e..9bf9aae 100644 --- a/src/main/java/info/movito/themoviedbapi/model/movies/MovieDb.java +++ b/src/main/java/info/movito/themoviedbapi/model/movies/MovieDb.java @@ -15,7 +15,6 @@ import lombok.EqualsAndHashCode; import java.util.List; -import java.util.Optional; @Data @EqualsAndHashCode(callSuper = true) @@ -94,111 +93,67 @@ public class MovieDb extends IdElement implements Multi { private Integer voteCount; /* append to responses */ + + /** Can be null if not appended to the request (append to response). */ @JsonProperty("account_states") private AccountStates accountStates; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("alternative_titles") private AlternativeTitles alternativeTitles; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("credits") private Credits credits; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("changes") private ChangeResults changes; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("external_ids") private ExternalIds externalIds; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("images") private Images images; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("keywords") private KeywordResults keywords; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("recommendations") private MovieResultsPage recommendations; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("release_dates") private ReleaseDateResults releaseDates; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("lists") private MovieListResultsPage lists; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("reviews") private ReviewResultsPage reviews; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("similar") private MovieResultsPage similar; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("translations") private Translations translations; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("videos") private VideoResults videos; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("watch/providers") private ProviderResults watchProviders; - public Optional getAccountStates() { - return Optional.ofNullable(accountStates); - } - - public Optional getAlternativeTitles() { - return Optional.ofNullable(alternativeTitles); - } - - public Optional getCredits() { - return Optional.ofNullable(credits); - } - - public Optional getChanges() { - return Optional.ofNullable(changes); - } - - public Optional getExternalIds() { - return Optional.ofNullable(externalIds); - } - - public Optional getImages() { - return Optional.ofNullable(images); - } - - public Optional getKeywords() { - return Optional.ofNullable(keywords); - } - - public Optional getRecommendations() { - return Optional.ofNullable(recommendations); - } - - public Optional getReleaseDates() { - return Optional.ofNullable(releaseDates); - } - - public Optional getLists() { - return Optional.ofNullable(lists); - } - - public Optional getReviews() { - return Optional.ofNullable(reviews); - } - - public Optional getSimilar() { - return Optional.ofNullable(similar); - } - - public Optional getTranslations() { - return Optional.ofNullable(translations); - } - - public Optional getVideos() { - return Optional.ofNullable(videos); - } - - public Optional getWatchProviders() { - return Optional.ofNullable(watchProviders); - } - @Override public MediaType getMediaType() { return MediaType.MOVIE; diff --git a/src/main/java/info/movito/themoviedbapi/model/people/PersonDb.java b/src/main/java/info/movito/themoviedbapi/model/people/PersonDb.java index a516af5..9f32391 100644 --- a/src/main/java/info/movito/themoviedbapi/model/people/PersonDb.java +++ b/src/main/java/info/movito/themoviedbapi/model/people/PersonDb.java @@ -12,7 +12,6 @@ import lombok.EqualsAndHashCode; import java.util.List; -import java.util.Optional; @Data @EqualsAndHashCode(callSuper = true) @@ -55,55 +54,35 @@ public class PersonDb extends NamedIdElement implements Multi { private String profilePath; /* append to responses */ + + /** Can be null if not appended to the request (append to response). */ @JsonProperty("combined_credits") private CombinedPersonCredits combinedCredits; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("changes") private ChangeResults changes; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("external_ids") private ExternalIds externalIds; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("images") private PersonImages images; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("movie_credits") private MovieCredits movieCredits; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("tv_credits") private TvCredits tvCredits; + /** Can be null if not appended to the request (append to response). */ @JsonProperty("translations") private Translations translations; - public Optional getCombinedCredits() { - return Optional.ofNullable(combinedCredits); - } - - public Optional getChanges() { - return Optional.ofNullable(changes); - } - - public Optional getExternalIds() { - return Optional.ofNullable(externalIds); - } - - public Optional getImages() { - return Optional.ofNullable(images); - } - - public Optional getMovieCredits() { - return Optional.ofNullable(movieCredits); - } - - public Optional getTvCredits() { - return Optional.ofNullable(tvCredits); - } - - public Optional getTranslations() { - return Optional.ofNullable(translations); - } - @Override public MediaType getMediaType() { return MediaType.PERSON; diff --git a/src/test/java/info/movito/themoviedbapi/TmdbAccountTest.java b/src/test/java/info/movito/themoviedbapi/TmdbAccountTest.java index 59279cc..f9fe023 100644 --- a/src/test/java/info/movito/themoviedbapi/TmdbAccountTest.java +++ b/src/test/java/info/movito/themoviedbapi/TmdbAccountTest.java @@ -1,18 +1,12 @@ package info.movito.themoviedbapi; -import info.movito.themoviedbapi.model.movies.MovieList; -import info.movito.themoviedbapi.model.movies.MovieListResultsPage; import info.movito.themoviedbapi.model.account.Account; -import info.movito.themoviedbapi.model.core.Movie; import info.movito.themoviedbapi.model.core.MovieResultsPage; -import info.movito.themoviedbapi.model.core.TvSeries; import info.movito.themoviedbapi.model.core.TvSeriesResultsPage; import info.movito.themoviedbapi.model.core.responses.ResponseStatus; -import info.movito.themoviedbapi.model.rated.RatedMovie; +import info.movito.themoviedbapi.model.movies.MovieListResultsPage; import info.movito.themoviedbapi.model.rated.RatedMovieResultsPage; -import info.movito.themoviedbapi.model.rated.RatedTvEpisode; import info.movito.themoviedbapi.model.rated.RatedTvEpisodeResultsPage; -import info.movito.themoviedbapi.model.rated.RatedTvSeries; import info.movito.themoviedbapi.model.rated.RatedTvSeriesResultsPage; import info.movito.themoviedbapi.tools.RequestType; import info.movito.themoviedbapi.tools.TmdbException; @@ -24,14 +18,12 @@ import java.io.IOException; import java.net.URL; import java.util.HashMap; -import java.util.List; import static info.movito.themoviedbapi.AbstractTmdbApi.getObjectMapper; import static info.movito.themoviedbapi.TmdbAccount.TMDB_METHOD_ACCOUNT; import static info.movito.themoviedbapi.tools.ApiUrl.TMDB_API_BASE_URL; -import static info.movito.themoviedbapi.util.TestUtils.testForNullFieldsAndNewItems; +import static info.movito.themoviedbapi.util.TestUtils.validateAbstractJsonMappingFields; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.when; @@ -51,7 +43,7 @@ public void testGetAccount() throws IOException, TmdbException { TmdbAccount tmdbAccount = getTmdbApi().getAccount(); Account account = tmdbAccount.getDetails(1234, "testSessionId"); assertNotNull(account); - testForNullFieldsAndNewItems(account); + validateAbstractJsonMappingFields(account); } /** @@ -77,7 +69,7 @@ public void testAddFavourite() throws TmdbException, IOException { TmdbAccount tmdbAccount = getTmdbApi().getAccount(); ResponseStatus responseStatus = tmdbAccount.addFavorite(accountId, sessionId, mediaId, mediaType); assertNotNull(responseStatus); - testForNullFieldsAndNewItems(responseStatus); + validateAbstractJsonMappingFields(responseStatus); assertEquals(1, responseStatus.getStatusCode()); assertEquals("Success.", responseStatus.getStatusMessage()); } @@ -105,7 +97,7 @@ public void testRemoveFavorite() throws TmdbException, IOException { TmdbAccount tmdbAccount = getTmdbApi().getAccount(); ResponseStatus responseStatus = tmdbAccount.removeFavorite(accountId, sessionId, mediaId, mediaType); assertNotNull(responseStatus); - testForNullFieldsAndNewItems(responseStatus); + validateAbstractJsonMappingFields(responseStatus); assertEquals(1, responseStatus.getStatusCode()); assertEquals("Success.", responseStatus.getStatusMessage()); } @@ -133,7 +125,7 @@ public void testAddToWatchList() throws IOException, TmdbException { TmdbAccount tmdbAccount = getTmdbApi().getAccount(); ResponseStatus responseStatus = tmdbAccount.addToWatchList(accountId, sessionId, mediaId, mediaType); assertNotNull(responseStatus); - testForNullFieldsAndNewItems(responseStatus); + validateAbstractJsonMappingFields(responseStatus); assertEquals(1, responseStatus.getStatusCode()); assertEquals("Success.", responseStatus.getStatusMessage()); } @@ -161,7 +153,7 @@ public void testRemoveFromWatchList() throws IOException, TmdbException { TmdbAccount tmdbAccount = getTmdbApi().getAccount(); ResponseStatus responseStatus = tmdbAccount.removeFromWatchList(accountId, sessionId, mediaId, mediaType); assertNotNull(responseStatus); - testForNullFieldsAndNewItems(responseStatus); + validateAbstractJsonMappingFields(responseStatus); assertEquals(1, responseStatus.getStatusCode()); assertEquals("Success.", responseStatus.getStatusMessage()); } @@ -185,14 +177,7 @@ public void testGetFavouriteMovies() throws TmdbException, IOException { TmdbAccount tmdbAccount = getTmdbApi().getAccount(); MovieResultsPage movieResultsPage = tmdbAccount.getFavoriteMovies(accountId, sessionId, language, page, sortBy); assertNotNull(movieResultsPage); - testForNullFieldsAndNewItems(movieResultsPage); - - List movieResults = movieResultsPage.getResults(); - assertFalse(movieResults.isEmpty()); - - Movie movie = movieResults.get(0); - assertNotNull(movie); - testForNullFieldsAndNewItems(movie); + validateAbstractJsonMappingFields(movieResultsPage); } /** @@ -214,14 +199,7 @@ public void testGetFavouriteTv() throws IOException, TmdbException { TmdbAccount tmdbAccount = getTmdbApi().getAccount(); TvSeriesResultsPage tvSeriesResultsPage = tmdbAccount.getFavoriteTv(accountId, sessionId, language, page, sortBy); assertNotNull(tvSeriesResultsPage); - testForNullFieldsAndNewItems(tvSeriesResultsPage); - - List tvResults = tvSeriesResultsPage.getResults(); - assertFalse(tvResults.isEmpty()); - - TvSeries tvSeries = tvResults.get(0); - assertNotNull(tvSeries); - testForNullFieldsAndNewItems(tvSeries); + validateAbstractJsonMappingFields(tvSeriesResultsPage); } /** @@ -240,14 +218,7 @@ public void testGetLists() throws TmdbException, IOException { TmdbAccount tmdbAccount = getTmdbApi().getAccount(); MovieListResultsPage movieListResultsPage = tmdbAccount.getLists(accountId, sessionId, page); assertNotNull(movieListResultsPage); - testForNullFieldsAndNewItems(movieListResultsPage); - - List movieLists = movieListResultsPage.getResults(); - assertFalse(movieLists.isEmpty()); - - MovieList movieList = movieLists.get(0); - assertNotNull(movieList); - testForNullFieldsAndNewItems(movieList); + validateAbstractJsonMappingFields(movieListResultsPage); } /** @@ -269,14 +240,7 @@ public void testGetRatedMovies() throws TmdbException, IOException { TmdbAccount tmdbAccount = getTmdbApi().getAccount(); RatedMovieResultsPage ratedMovieResultsPage = tmdbAccount.getRatedMovies(accountId, sessionId, language, page, sortBy); assertNotNull(ratedMovieResultsPage); - testForNullFieldsAndNewItems(ratedMovieResultsPage); - - List ratedMovies = ratedMovieResultsPage.getResults(); - assertFalse(ratedMovies.isEmpty()); - - RatedMovie ratedMovie = ratedMovies.get(0); - assertNotNull(ratedMovie); - testForNullFieldsAndNewItems(ratedMovie); + validateAbstractJsonMappingFields(ratedMovieResultsPage); } /** @@ -298,14 +262,7 @@ public void testGetRatedTvSeries() throws TmdbException, IOException { TmdbAccount tmdbAccount = getTmdbApi().getAccount(); RatedTvSeriesResultsPage ratedTvSeriesResultsPage = tmdbAccount.getRatedTvSeries(accountId, sessionId, language, page, sortBy); assertNotNull(ratedTvSeriesResultsPage); - testForNullFieldsAndNewItems(ratedTvSeriesResultsPage); - - List ratedTvSeriess = ratedTvSeriesResultsPage.getResults(); - assertFalse(ratedTvSeriess.isEmpty()); - - RatedTvSeries ratedTvSeries = ratedTvSeriess.get(0); - assertNotNull(ratedTvSeries); - testForNullFieldsAndNewItems(ratedTvSeries); + validateAbstractJsonMappingFields(ratedTvSeriesResultsPage); } /** @@ -328,14 +285,7 @@ public void testGetRatedTvEpisodes() throws TmdbException, IOException { RatedTvEpisodeResultsPage ratedTvEpisodesResultsPage = tmdbAccount.getRatedTvEpisodes(accountId, sessionId, language, page, sortBy); assertNotNull(ratedTvEpisodesResultsPage); - testForNullFieldsAndNewItems(ratedTvEpisodesResultsPage); - - List ratedTvEpisodes = ratedTvEpisodesResultsPage.getResults(); - assertFalse(ratedTvEpisodes.isEmpty()); - - RatedTvEpisode ratedTvEpisode = ratedTvEpisodes.get(0); - assertNotNull(ratedTvEpisode); - testForNullFieldsAndNewItems(ratedTvEpisode); + validateAbstractJsonMappingFields(ratedTvEpisodesResultsPage); } /** @@ -357,14 +307,7 @@ public void testGetWatchListMovies() throws TmdbException, IOException { TmdbAccount tmdbAccount = getTmdbApi().getAccount(); MovieResultsPage movieResultsPage = tmdbAccount.getWatchListMovies(accountId, sessionId, language, page, sortBy); assertNotNull(movieResultsPage); - testForNullFieldsAndNewItems(movieResultsPage); - - List movies = movieResultsPage.getResults(); - assertFalse(movies.isEmpty()); - - Movie movie = movies.get(0); - assertNotNull(movie); - testForNullFieldsAndNewItems(movie); + validateAbstractJsonMappingFields(movieResultsPage); } /** @@ -386,13 +329,6 @@ public void testGetWatchListTvSeries() throws TmdbException, IOException { TmdbAccount tmdbAccount = getTmdbApi().getAccount(); TvSeriesResultsPage tvSeriesResultsPage = tmdbAccount.getWatchListTvSeries(accountId, sessionId, language, page, sortBy); assertNotNull(tvSeriesResultsPage); - testForNullFieldsAndNewItems(tvSeriesResultsPage); - - List tvSeriess = tvSeriesResultsPage.getResults(); - assertFalse(tvSeriess.isEmpty()); - - TvSeries tvSeries = tvSeriess.get(0); - assertNotNull(tvSeries); - testForNullFieldsAndNewItems(tvSeries); + validateAbstractJsonMappingFields(tvSeriesResultsPage); } } diff --git a/src/test/java/info/movito/themoviedbapi/TmdbAuthenticationTest.java b/src/test/java/info/movito/themoviedbapi/TmdbAuthenticationTest.java index fde3fc0..5a4ab86 100644 --- a/src/test/java/info/movito/themoviedbapi/TmdbAuthenticationTest.java +++ b/src/test/java/info/movito/themoviedbapi/TmdbAuthenticationTest.java @@ -20,7 +20,7 @@ import static info.movito.themoviedbapi.TmdbAuthentication.TMDB_METHOD_AUTH; import static info.movito.themoviedbapi.tools.ApiUrl.TMDB_API_BASE_URL; import static info.movito.themoviedbapi.tools.TmdbResponseCode.INVALID_API_KEY; -import static info.movito.themoviedbapi.util.TestUtils.testForNullFieldsAndNewItems; +import static info.movito.themoviedbapi.util.TestUtils.validateAbstractJsonMappingFields; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -44,7 +44,7 @@ public void testCreateGuestSession() throws TmdbException, IOException { TmdbAuthentication tmdbAuthentication = getTmdbApi().getAuthentication(); GuestSession guestSession = tmdbAuthentication.createGuestSession(); assertNotNull(guestSession); - testForNullFieldsAndNewItems(guestSession); + validateAbstractJsonMappingFields(guestSession); } /** @@ -59,7 +59,7 @@ public void testCreateRequestToken() throws TmdbException, IOException { TmdbAuthentication tmdbAuthentication = getTmdbApi().getAuthentication(); RequestToken requestToken = tmdbAuthentication.createRequestToken(); assertNotNull(requestToken); - testForNullFieldsAndNewItems(requestToken); + validateAbstractJsonMappingFields(requestToken); } /** @@ -116,7 +116,7 @@ public void testCreateSession() throws TmdbException, IOException { requestToken.setRequestToken(requestTokenStr); Session session = tmdbAuthentication.createSession(requestToken); assertNotNull(session); - testForNullFieldsAndNewItems(session); + validateAbstractJsonMappingFields(session); } /** @@ -152,7 +152,7 @@ public void testCreateAuthenticatedRequestToken() throws TmdbException, IOExcept RequestToken authenticatedRequestToken = tmdbAuthentication.createAuthenticatedRequestToken(requestToken, "username", "password"); assertNotNull(authenticatedRequestToken); - testForNullFieldsAndNewItems(authenticatedRequestToken); + validateAbstractJsonMappingFields(authenticatedRequestToken); } /** @@ -186,7 +186,7 @@ public void testDeleteSession() throws TmdbException, IOException { TmdbAuthentication tmdbAuthentication = getTmdbApi().getAuthentication(); ResponseStatusDelete responseStatusDelete = tmdbAuthentication.deleteSession("sessionId"); assertNotNull(responseStatusDelete); - testForNullFieldsAndNewItems(responseStatusDelete); + validateAbstractJsonMappingFields(responseStatusDelete); assertTrue(responseStatusDelete.getSuccess()); } @@ -212,7 +212,7 @@ public void testValidateKey() throws TmdbException, IOException { TmdbAuthentication tmdbAuthentication = getTmdbApi().getAuthentication(); ResponseStatusAuthentication responseStatusAuthentication = tmdbAuthentication.validateKey(); assertNotNull(responseStatusAuthentication); - testForNullFieldsAndNewItems(responseStatusAuthentication); + validateAbstractJsonMappingFields(responseStatusAuthentication); assertTrue(responseStatusAuthentication.getSuccess()); } diff --git a/src/test/java/info/movito/themoviedbapi/TmdbCertificationsTest.java b/src/test/java/info/movito/themoviedbapi/TmdbCertificationsTest.java index ec58151..2db722b 100644 --- a/src/test/java/info/movito/themoviedbapi/TmdbCertificationsTest.java +++ b/src/test/java/info/movito/themoviedbapi/TmdbCertificationsTest.java @@ -1,6 +1,5 @@ package info.movito.themoviedbapi; -import info.movito.themoviedbapi.model.certifications.Certification; import info.movito.themoviedbapi.model.certifications.CertificationResults; import info.movito.themoviedbapi.tools.RequestType; import info.movito.themoviedbapi.tools.TmdbException; @@ -9,15 +8,12 @@ import java.io.IOException; import java.net.URL; -import java.util.List; -import java.util.Map; import static info.movito.themoviedbapi.TmdbCertifications.TMDB_METHOD_CERTIFICATIONS; import static info.movito.themoviedbapi.TmdbCertifications.TMDB_METHOD_MOVIE_CERTIFICATIONS; import static info.movito.themoviedbapi.TmdbCertifications.TMDB_METHOD_TV_CERTIFICATIONS; 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 info.movito.themoviedbapi.util.TestUtils.validateAbstractJsonMappingFields; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.when; @@ -37,17 +33,7 @@ public void testGetMovieCertifications() throws IOException, TmdbException { TmdbCertifications tmdbCertifications = getTmdbApi().getCertifications(); CertificationResults movieCertifications = tmdbCertifications.getMovieCertifications(); assertNotNull(movieCertifications); - testForNullFieldsAndNewItems(movieCertifications); - - Map> certifications = movieCertifications.getCertifications(); - assertFalse(certifications.isEmpty()); - - List auCertifications = certifications.get("AU"); - assertFalse(auCertifications.isEmpty()); - - Certification auCertification = auCertifications.get(0); - assertNotNull(auCertification); - testForNullFieldsAndNewItems(auCertification); + validateAbstractJsonMappingFields(movieCertifications); } /** @@ -62,16 +48,6 @@ public void testGetTvCertifications() throws IOException, TmdbException { TmdbCertifications tmdbCertifications = getTmdbApi().getCertifications(); CertificationResults tvCertifications = tmdbCertifications.getTvCertifications(); assertNotNull(tvCertifications); - testForNullFieldsAndNewItems(tvCertifications); - - Map> certifications = tvCertifications.getCertifications(); - assertFalse(certifications.isEmpty()); - - List auCertifications = certifications.get("AU"); - assertFalse(auCertifications.isEmpty()); - - Certification auCertification = auCertifications.get(0); - assertNotNull(auCertification); - testForNullFieldsAndNewItems(auCertification); + validateAbstractJsonMappingFields(tvCertifications); } } diff --git a/src/test/java/info/movito/themoviedbapi/TmdbChangesTest.java b/src/test/java/info/movito/themoviedbapi/TmdbChangesTest.java index 26960bb..30fe18e 100644 --- a/src/test/java/info/movito/themoviedbapi/TmdbChangesTest.java +++ b/src/test/java/info/movito/themoviedbapi/TmdbChangesTest.java @@ -1,6 +1,5 @@ package info.movito.themoviedbapi; -import info.movito.themoviedbapi.model.changes.Change; import info.movito.themoviedbapi.model.changes.ChangesResultsPage; import info.movito.themoviedbapi.tools.RequestType; import info.movito.themoviedbapi.tools.TmdbException; @@ -15,7 +14,7 @@ import static info.movito.themoviedbapi.TmdbChanges.TMDB_METHOD_PERSON; import static info.movito.themoviedbapi.TmdbChanges.TMDB_METHOD_TV; import static info.movito.themoviedbapi.tools.ApiUrl.TMDB_API_BASE_URL; -import static info.movito.themoviedbapi.util.TestUtils.testForNullFieldsAndNewItems; +import static info.movito.themoviedbapi.util.TestUtils.validateAbstractJsonMappingFields; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.when; @@ -38,16 +37,9 @@ public void testGetMovieChangesList() throws TmdbException, IOException { when(getTmdbUrlReader().readUrl(url, null, RequestType.GET)).thenReturn(body); TmdbChanges tmdbChanges = getTmdbApi().getChanges(); - long start = System.currentTimeMillis(); ChangesResultsPage changesResultsPage = tmdbChanges.getMovieChangesList(startDate, endDate, page); - long end = System.currentTimeMillis(); - System.out.println("Time: " + (end - start)); assertNotNull(changesResultsPage); - testForNullFieldsAndNewItems(changesResultsPage); - - Change change = changesResultsPage.getResults().get(0); - assertNotNull(change); - testForNullFieldsAndNewItems(change); + validateAbstractJsonMappingFields(changesResultsPage); } /** @@ -67,11 +59,7 @@ public void testGetPeopleChangesList() throws TmdbException, IOException { TmdbChanges tmdbChanges = getTmdbApi().getChanges(); ChangesResultsPage changesResultsPage = tmdbChanges.getPeopleChangesList(startDate, endDate, page); assertNotNull(changesResultsPage); - testForNullFieldsAndNewItems(changesResultsPage); - - Change change = changesResultsPage.getResults().get(0); - assertNotNull(change); - testForNullFieldsAndNewItems(change); + validateAbstractJsonMappingFields(changesResultsPage); } /** @@ -91,10 +79,6 @@ public void testGetTvChangesList() throws TmdbException, IOException { TmdbChanges tmdbChanges = getTmdbApi().getChanges(); ChangesResultsPage changesResultsPage = tmdbChanges.getTvChangesList(startDate, endDate, page); assertNotNull(changesResultsPage); - testForNullFieldsAndNewItems(changesResultsPage); - - Change change = changesResultsPage.getResults().get(0); - assertNotNull(change); - testForNullFieldsAndNewItems(change); + validateAbstractJsonMappingFields(changesResultsPage); } } diff --git a/src/test/java/info/movito/themoviedbapi/TmdbCollectionsTest.java b/src/test/java/info/movito/themoviedbapi/TmdbCollectionsTest.java index 91f7000..1ef4f10 100644 --- a/src/test/java/info/movito/themoviedbapi/TmdbCollectionsTest.java +++ b/src/test/java/info/movito/themoviedbapi/TmdbCollectionsTest.java @@ -1,11 +1,8 @@ package info.movito.themoviedbapi; -import info.movito.themoviedbapi.model.Artwork; import info.movito.themoviedbapi.model.CollectionInfo; -import info.movito.themoviedbapi.model.collections.Data; import info.movito.themoviedbapi.model.collections.Images; import info.movito.themoviedbapi.model.collections.Translation; -import info.movito.themoviedbapi.model.collections.Part; import info.movito.themoviedbapi.tools.RequestType; import info.movito.themoviedbapi.tools.TmdbException; import info.movito.themoviedbapi.util.TestUtils; @@ -17,7 +14,7 @@ import static info.movito.themoviedbapi.TmdbCollections.TMDB_METHOD_COLLECTION; import static info.movito.themoviedbapi.tools.ApiUrl.TMDB_API_BASE_URL; -import static info.movito.themoviedbapi.util.TestUtils.testForNullFieldsAndNewItems; +import static info.movito.themoviedbapi.util.TestUtils.validateAbstractJsonMappingFields; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.when; @@ -42,14 +39,7 @@ public void testGetDetails() throws IOException, TmdbException { TmdbCollections tmdbCollections = getTmdbApi().getCollections(); CollectionInfo collectionInfo = tmdbCollections.getDetails(collectionId, language); assertNotNull(collectionInfo); - testForNullFieldsAndNewItems(collectionInfo); - - List partList = collectionInfo.getParts(); - assertFalse(partList.isEmpty()); - - Part part = partList.get(0); - assertNotNull(part); - testForNullFieldsAndNewItems(part); + validateAbstractJsonMappingFields(collectionInfo); } /** @@ -69,15 +59,7 @@ public void testGetImages() throws IOException, TmdbException { TmdbCollections tmdbCollections = getTmdbApi().getCollections(); Images images = tmdbCollections.getImages(collectionId, language); assertNotNull(images); - testForNullFieldsAndNewItems(images); - - List posters = images.getPosters(); - assertFalse(posters.isEmpty()); - testForNullFieldsAndNewItems(posters.get(0)); - - List backdrops = images.getBackdrops(); - assertFalse(backdrops.isEmpty()); - testForNullFieldsAndNewItems(backdrops.get(0)); + validateAbstractJsonMappingFields(images); } /** @@ -97,15 +79,7 @@ public void testGetImagesMultipleLanguages() throws IOException, TmdbException { TmdbCollections tmdbCollections = getTmdbApi().getCollections(); Images images = tmdbCollections.getImages(collectionId, null, includeImageLanguage); assertNotNull(images); - testForNullFieldsAndNewItems(images); - - List posters = images.getPosters(); - assertFalse(posters.isEmpty()); - testForNullFieldsAndNewItems(posters.get(0)); - - List backdrops = images.getBackdrops(); - assertFalse(backdrops.isEmpty()); - testForNullFieldsAndNewItems(backdrops.get(0)); + validateAbstractJsonMappingFields(images); } /** @@ -122,13 +96,5 @@ public void testGetTranslations() throws IOException, TmdbException { TmdbCollections tmdbCollections = getTmdbApi().getCollections(); List translations = tmdbCollections.getTranslations(collectionId); assertFalse(translations.isEmpty()); - - Translation translation = translations.get(0); - assertNotNull(translation); - testForNullFieldsAndNewItems(translation); - - Data data = translation.getData(); - assertNotNull(data); - testForNullFieldsAndNewItems(data); } } diff --git a/src/test/java/info/movito/themoviedbapi/TmdbCompaniesTest.java b/src/test/java/info/movito/themoviedbapi/TmdbCompaniesTest.java index ae704e2..002015d 100644 --- a/src/test/java/info/movito/themoviedbapi/TmdbCompaniesTest.java +++ b/src/test/java/info/movito/themoviedbapi/TmdbCompaniesTest.java @@ -1,8 +1,6 @@ package info.movito.themoviedbapi; -import info.movito.themoviedbapi.model.AlternativeName; import info.movito.themoviedbapi.model.Company; -import info.movito.themoviedbapi.model.core.image.Image; import info.movito.themoviedbapi.model.core.image.ImageResults; import info.movito.themoviedbapi.tools.RequestType; import info.movito.themoviedbapi.tools.TmdbException; @@ -14,7 +12,7 @@ import static info.movito.themoviedbapi.TmdbCompanies.TMDB_METHOD_COMPANY; import static info.movito.themoviedbapi.tools.ApiUrl.TMDB_API_BASE_URL; -import static info.movito.themoviedbapi.util.TestUtils.testForNullFieldsAndNewItems; +import static info.movito.themoviedbapi.util.TestUtils.validateAbstractJsonMappingFields; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.when; @@ -36,7 +34,7 @@ public void testGetDetails() throws IOException, TmdbException { TmdbCompanies tmdbCompanies = getTmdbApi().getCompanies(); Company company = tmdbCompanies.getDetails(companyId); assertNotNull(company); - testForNullFieldsAndNewItems(company); + validateAbstractJsonMappingFields(company); } /** @@ -53,11 +51,7 @@ public void testGetAlternativeNames() throws IOException, TmdbException { TmdbCompanies tmdbCompanies = getTmdbApi().getCompanies(); TmdbCompanies.AlternativeNamesResultsPage alternativeNamesResultsPage = tmdbCompanies.getAlternativeNames(1); assertNotNull(alternativeNamesResultsPage); - testForNullFieldsAndNewItems(alternativeNamesResultsPage); - - AlternativeName alternativeName = alternativeNamesResultsPage.getResults().get(0); - assertNotNull(alternativeName); - testForNullFieldsAndNewItems(alternativeName); + validateAbstractJsonMappingFields(alternativeNamesResultsPage); } /** @@ -74,10 +68,6 @@ public void testGetImages() throws IOException, TmdbException { TmdbCompanies tmdbCompanies = getTmdbApi().getCompanies(); ImageResults logoImageResults = tmdbCompanies.getImages(1); assertNotNull(logoImageResults); - testForNullFieldsAndNewItems(logoImageResults); - - Image image = logoImageResults.getLogos().get(0); - assertNotNull(image); - testForNullFieldsAndNewItems(image); + validateAbstractJsonMappingFields(logoImageResults); } } diff --git a/src/test/java/info/movito/themoviedbapi/TmdbConfigurationTest.java b/src/test/java/info/movito/themoviedbapi/TmdbConfigurationTest.java index e6bdb90..098a764 100644 --- a/src/test/java/info/movito/themoviedbapi/TmdbConfigurationTest.java +++ b/src/test/java/info/movito/themoviedbapi/TmdbConfigurationTest.java @@ -16,7 +16,7 @@ import static info.movito.themoviedbapi.TmdbConfiguration.TMDB_METHOD_CONFIGURATION; import static info.movito.themoviedbapi.tools.ApiUrl.TMDB_API_BASE_URL; -import static info.movito.themoviedbapi.util.TestUtils.testForNullFieldsAndNewItems; +import static info.movito.themoviedbapi.util.TestUtils.validateAbstractJsonMappingFields; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.when; @@ -26,18 +26,18 @@ */ public class TmdbConfigurationTest extends AbstractTmdbApiTest { /** - * Test for {@link TmdbConfiguration#getConfig()} with an expected result. + * Test for {@link TmdbConfiguration#getDetails()} with an expected result. */ @Test - public void testGetConfig() throws IOException, TmdbException { + public void testGetDetails() throws IOException, TmdbException { String body = TestUtils.readTestFile("api_responses/configuration/details.json"); URL url = new URL(TMDB_API_BASE_URL + TMDB_METHOD_CONFIGURATION); when(getTmdbUrlReader().readUrl(url, null, RequestType.GET)).thenReturn(body); TmdbConfiguration tmdbConfiguration = getTmdbApi().getConfiguration(); - Configuration configuration = tmdbConfiguration.getConfig(); + Configuration configuration = tmdbConfiguration.getDetails(); assertNotNull(configuration); - testForNullFieldsAndNewItems(configuration); + validateAbstractJsonMappingFields(configuration); } /** @@ -56,7 +56,7 @@ public void testGetCountries() throws IOException, TmdbException { Country country = countries.get(0); assertNotNull(country); - testForNullFieldsAndNewItems(country); + validateAbstractJsonMappingFields(country); } /** @@ -75,7 +75,7 @@ public void testGetJobs() throws IOException, TmdbException { Job job = jobs.get(0); assertNotNull(job); - testForNullFieldsAndNewItems(job); + validateAbstractJsonMappingFields(job); } /** @@ -94,7 +94,7 @@ public void testGetLanguages() throws IOException, TmdbException { Language language = languages.get(0); assertNotNull(language); - testForNullFieldsAndNewItems(language); + validateAbstractJsonMappingFields(language); } /** @@ -131,6 +131,6 @@ public void testGetTimezones() throws IOException, TmdbException { Timezone timezone = timezones.get(0); assertNotNull(timezone); - testForNullFieldsAndNewItems(timezone); + validateAbstractJsonMappingFields(timezone); } } diff --git a/src/test/java/info/movito/themoviedbapi/TmdbDiscoverTest.java b/src/test/java/info/movito/themoviedbapi/TmdbDiscoverTest.java index a1ece98..7948bcb 100644 --- a/src/test/java/info/movito/themoviedbapi/TmdbDiscoverTest.java +++ b/src/test/java/info/movito/themoviedbapi/TmdbDiscoverTest.java @@ -1,8 +1,6 @@ package info.movito.themoviedbapi; -import info.movito.themoviedbapi.model.core.Movie; import info.movito.themoviedbapi.model.core.MovieResultsPage; -import info.movito.themoviedbapi.model.core.TvSeries; import info.movito.themoviedbapi.model.core.TvSeriesResultsPage; import info.movito.themoviedbapi.tools.RequestType; import info.movito.themoviedbapi.tools.TmdbException; @@ -18,7 +16,7 @@ import static info.movito.themoviedbapi.TmdbDiscover.TMDB_METHOD_MOVIE; import static info.movito.themoviedbapi.TmdbDiscover.TMDB_METHOD_TV; import static info.movito.themoviedbapi.tools.ApiUrl.TMDB_API_BASE_URL; -import static info.movito.themoviedbapi.util.TestUtils.testForNullFieldsAndNewItems; +import static info.movito.themoviedbapi.util.TestUtils.validateAbstractJsonMappingFields; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.when; @@ -41,11 +39,7 @@ public void testGetMovie() throws IOException, TmdbException { MovieResultsPage movieResultsPage = tmdbDiscover.getMovie(discoverMovieParamBuilder); assertNotNull(movieResultsPage); - testForNullFieldsAndNewItems(movieResultsPage); - - Movie movie = movieResultsPage.getResults().get(0); - assertNotNull(movie); - testForNullFieldsAndNewItems(movie); + validateAbstractJsonMappingFields(movieResultsPage); } /** @@ -60,11 +54,7 @@ public void testGetMovieNullBuilder() throws IOException, TmdbException { TmdbDiscover tmdbDiscover = getTmdbApi().getDiscover(); MovieResultsPage movieResultsPage = tmdbDiscover.getMovie(null); assertNotNull(movieResultsPage); - testForNullFieldsAndNewItems(movieResultsPage); - - Movie movie = movieResultsPage.getResults().get(0); - assertNotNull(movie); - testForNullFieldsAndNewItems(movie); + validateAbstractJsonMappingFields(movieResultsPage); } /** @@ -82,11 +72,7 @@ public void testGetTv() throws IOException, TmdbException { TvSeriesResultsPage tvSeriesResultsPage = tmdbDiscover.getTv(discoverTvParamBuilder); assertNotNull(tvSeriesResultsPage); - testForNullFieldsAndNewItems(tvSeriesResultsPage); - - TvSeries tvSeries = tvSeriesResultsPage.getResults().get(0); - assertNotNull(tvSeries); - testForNullFieldsAndNewItems(tvSeries); + validateAbstractJsonMappingFields(tvSeriesResultsPage); } /** @@ -101,10 +87,6 @@ public void testGetTvNullBuilder() throws IOException, TmdbException { TmdbDiscover tmdbDiscover = getTmdbApi().getDiscover(); TvSeriesResultsPage tvSeriesResultsPage = tmdbDiscover.getTv(null); assertNotNull(tvSeriesResultsPage); - testForNullFieldsAndNewItems(tvSeriesResultsPage); - - TvSeries tvSeries = tvSeriesResultsPage.getResults().get(0); - assertNotNull(tvSeries); - testForNullFieldsAndNewItems(tvSeries); + validateAbstractJsonMappingFields(tvSeriesResultsPage); } } diff --git a/src/test/java/info/movito/themoviedbapi/TmdbGenresTest.java b/src/test/java/info/movito/themoviedbapi/TmdbGenresTest.java index 191bc65..fbb5882 100644 --- a/src/test/java/info/movito/themoviedbapi/TmdbGenresTest.java +++ b/src/test/java/info/movito/themoviedbapi/TmdbGenresTest.java @@ -12,7 +12,7 @@ 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 info.movito.themoviedbapi.util.TestUtils.validateAbstractJsonMappingFields; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.when; @@ -37,7 +37,7 @@ public void testGetMovieList() throws IOException, TmdbException { Genre genre = genres.get(0); assertNotNull(genre); - testForNullFieldsAndNewItems(genre); + validateAbstractJsonMappingFields(genre); } /** @@ -56,6 +56,6 @@ public void testGetTvList() throws IOException, TmdbException { Genre genre = genres.get(0); assertNotNull(genre); - testForNullFieldsAndNewItems(genre); + validateAbstractJsonMappingFields(genre); } } diff --git a/src/test/java/info/movito/themoviedbapi/TmdbGuestSessionsTest.java b/src/test/java/info/movito/themoviedbapi/TmdbGuestSessionsTest.java index 88eb96f..3c24fbd 100644 --- a/src/test/java/info/movito/themoviedbapi/TmdbGuestSessionsTest.java +++ b/src/test/java/info/movito/themoviedbapi/TmdbGuestSessionsTest.java @@ -1,10 +1,7 @@ package info.movito.themoviedbapi; -import info.movito.themoviedbapi.model.rated.RatedMovie; import info.movito.themoviedbapi.model.rated.RatedMovieResultsPage; -import info.movito.themoviedbapi.model.rated.RatedTvEpisode; import info.movito.themoviedbapi.model.rated.RatedTvEpisodeResultsPage; -import info.movito.themoviedbapi.model.rated.RatedTvSeries; import info.movito.themoviedbapi.model.rated.RatedTvSeriesResultsPage; import info.movito.themoviedbapi.tools.RequestType; import info.movito.themoviedbapi.tools.TmdbException; @@ -14,12 +11,10 @@ import java.io.IOException; import java.net.URL; -import java.util.List; import static info.movito.themoviedbapi.TmdbGuestSessions.TMDB_METHOD_GUEST_SESSIONS; 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 info.movito.themoviedbapi.util.TestUtils.validateAbstractJsonMappingFields; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.when; @@ -39,14 +34,7 @@ public void testGetRatedMovies() throws IOException, TmdbException { TmdbGuestSessions guestSessions = new TmdbGuestSessions(getTmdbApi()); RatedMovieResultsPage ratedMovieResultsPage = guestSessions.getRatedMovies(1, "en", 1, AccountSortBy.CREATED_AT_DESC); assertNotNull(ratedMovieResultsPage); - testForNullFieldsAndNewItems(ratedMovieResultsPage); - - List ratedMovies = ratedMovieResultsPage.getResults(); - assertFalse(ratedMovies.isEmpty()); - - RatedMovie ratedMovie = ratedMovies.get(0); - assertNotNull(ratedMovie); - testForNullFieldsAndNewItems(ratedMovie); + validateAbstractJsonMappingFields(ratedMovieResultsPage); } /** @@ -61,14 +49,7 @@ public void testGetRatedTvSeries() throws IOException, TmdbException { TmdbGuestSessions guestSessions = new TmdbGuestSessions(getTmdbApi()); RatedTvSeriesResultsPage ratedTvSeriesResultsPage = guestSessions.getRatedTvSeries(1, "en", 1, AccountSortBy.CREATED_AT_DESC); assertNotNull(ratedTvSeriesResultsPage); - testForNullFieldsAndNewItems(ratedTvSeriesResultsPage); - - List ratedTvSeriess = ratedTvSeriesResultsPage.getResults(); - assertFalse(ratedTvSeriess.isEmpty()); - - RatedTvSeries ratedTvSeries = ratedTvSeriess.get(0); - assertNotNull(ratedTvSeries); - testForNullFieldsAndNewItems(ratedTvSeries); + validateAbstractJsonMappingFields(ratedTvSeriesResultsPage); } /** @@ -84,13 +65,6 @@ public void testGetRatedTvEpisodes() throws IOException, TmdbException { TmdbGuestSessions guestSessions = new TmdbGuestSessions(getTmdbApi()); RatedTvEpisodeResultsPage ratedTvEpisodesResultsPage = guestSessions.getRatedTvEpisodes(1, "en", 1, AccountSortBy.CREATED_AT_DESC); assertNotNull(ratedTvEpisodesResultsPage); - testForNullFieldsAndNewItems(ratedTvEpisodesResultsPage); - - List ratedTvEpisodes = ratedTvEpisodesResultsPage.getResults(); - assertFalse(ratedTvEpisodes.isEmpty()); - - RatedTvEpisode ratedTvEpisode = ratedTvEpisodes.get(0); - assertNotNull(ratedTvEpisode); - testForNullFieldsAndNewItems(ratedTvEpisode); + validateAbstractJsonMappingFields(ratedTvEpisodesResultsPage); } } diff --git a/src/test/java/info/movito/themoviedbapi/TmdbKeywordsTest.java b/src/test/java/info/movito/themoviedbapi/TmdbKeywordsTest.java index a859972..845c44a 100644 --- a/src/test/java/info/movito/themoviedbapi/TmdbKeywordsTest.java +++ b/src/test/java/info/movito/themoviedbapi/TmdbKeywordsTest.java @@ -11,7 +11,7 @@ import static info.movito.themoviedbapi.TmdbKeywords.TMDB_METHOD_KEYWORD; import static info.movito.themoviedbapi.tools.ApiUrl.TMDB_API_BASE_URL; -import static info.movito.themoviedbapi.util.TestUtils.testForNullFieldsAndNewItems; +import static info.movito.themoviedbapi.util.TestUtils.validateAbstractJsonMappingFields; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.when; @@ -31,6 +31,6 @@ public void testGetDetails() throws TmdbException, IOException { TmdbKeywords tmdbKeywords = getTmdbApi().getKeywords(); Keyword keyword = tmdbKeywords.getDetails(1); assertNotNull(keyword); - testForNullFieldsAndNewItems(keyword); + validateAbstractJsonMappingFields(keyword); } } diff --git a/src/test/java/info/movito/themoviedbapi/TmdbMovieListsTest.java b/src/test/java/info/movito/themoviedbapi/TmdbMovieListsTest.java index 63184bc..1d0f5b8 100644 --- a/src/test/java/info/movito/themoviedbapi/TmdbMovieListsTest.java +++ b/src/test/java/info/movito/themoviedbapi/TmdbMovieListsTest.java @@ -1,8 +1,6 @@ package info.movito.themoviedbapi; -import info.movito.themoviedbapi.model.core.Movie; import info.movito.themoviedbapi.model.core.MovieResultsPage; -import info.movito.themoviedbapi.model.movielists.Dates; import info.movito.themoviedbapi.model.movielists.MovieResultsPageWithDates; import info.movito.themoviedbapi.tools.RequestType; import info.movito.themoviedbapi.tools.TmdbException; @@ -11,12 +9,10 @@ import java.io.IOException; import java.net.URL; -import java.util.List; import static info.movito.themoviedbapi.TmdbMovieLists.TMDB_METHOD_MOVIE_LISTS; 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 info.movito.themoviedbapi.util.TestUtils.validateAbstractJsonMappingFields; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.when; @@ -36,24 +32,7 @@ public void testGetNowPlaying() throws IOException, TmdbException { TmdbMovieLists tmdbMovieLists = getTmdbApi().getMovieLists(); MovieResultsPageWithDates movieResultsPageWithDates = tmdbMovieLists.getNowPlaying("en-US", 1, null); assertNotNull(movieResultsPageWithDates); - testForNullFieldsAndNewItems(movieResultsPageWithDates); - - Dates dates = movieResultsPageWithDates.getDates(); - assertNotNull(dates); - testForNullFieldsAndNewItems(dates); - - List movies = movieResultsPageWithDates.getResults(); - assertNotNull(movies); - assertFalse(movies.isEmpty()); - - Movie movie = movies.get(0); - assertNotNull(movie); - testForNullFieldsAndNewItems(movie); - - List genreIds = movie.getGenreIds(); - assertNotNull(genreIds); - assertFalse(genreIds.isEmpty()); - assertNotNull(genreIds.get(0)); + validateAbstractJsonMappingFields(movieResultsPageWithDates); } /** @@ -68,20 +47,7 @@ public void testGetPopular() throws IOException, TmdbException { TmdbMovieLists tmdbMovieLists = getTmdbApi().getMovieLists(); MovieResultsPage movieResultsPage = tmdbMovieLists.getPopular("en-US", 1, null); assertNotNull(movieResultsPage); - testForNullFieldsAndNewItems(movieResultsPage); - - List movies = movieResultsPage.getResults(); - assertNotNull(movies); - assertFalse(movies.isEmpty()); - - Movie movie = movies.get(0); - assertNotNull(movie); - testForNullFieldsAndNewItems(movie); - - List genreIds = movie.getGenreIds(); - assertNotNull(genreIds); - assertFalse(genreIds.isEmpty()); - assertNotNull(genreIds.get(0)); + validateAbstractJsonMappingFields(movieResultsPage); } /** @@ -96,20 +62,7 @@ public void testGetTopRated() throws IOException, TmdbException { TmdbMovieLists tmdbMovieLists = getTmdbApi().getMovieLists(); MovieResultsPage movieResultsPage = tmdbMovieLists.getTopRated("en-US", 1, null); assertNotNull(movieResultsPage); - testForNullFieldsAndNewItems(movieResultsPage); - - List movies = movieResultsPage.getResults(); - assertNotNull(movies); - assertFalse(movies.isEmpty()); - - Movie movie = movies.get(0); - assertNotNull(movie); - testForNullFieldsAndNewItems(movie); - - List genreIds = movie.getGenreIds(); - assertNotNull(genreIds); - assertFalse(genreIds.isEmpty()); - assertNotNull(genreIds.get(0)); + validateAbstractJsonMappingFields(movieResultsPage); } /** @@ -124,23 +77,6 @@ public void testGetUpcoming() throws IOException, TmdbException { TmdbMovieLists tmdbMovieLists = getTmdbApi().getMovieLists(); MovieResultsPageWithDates movieResultsPageWithDates = tmdbMovieLists.getUpcoming("en-US", 1, null); assertNotNull(movieResultsPageWithDates); - testForNullFieldsAndNewItems(movieResultsPageWithDates); - - Dates dates = movieResultsPageWithDates.getDates(); - assertNotNull(dates); - testForNullFieldsAndNewItems(dates); - - List movies = movieResultsPageWithDates.getResults(); - assertNotNull(movies); - assertFalse(movies.isEmpty()); - - Movie movie = movies.get(0); - assertNotNull(movie); - testForNullFieldsAndNewItems(movie); - - List genreIds = movie.getGenreIds(); - assertNotNull(genreIds); - assertFalse(genreIds.isEmpty()); - assertNotNull(genreIds.get(0)); + validateAbstractJsonMappingFields(movieResultsPageWithDates); } } diff --git a/src/test/java/info/movito/themoviedbapi/TmdbMoviesTest.java b/src/test/java/info/movito/themoviedbapi/TmdbMoviesTest.java index 3892f0a..6b424d2 100644 --- a/src/test/java/info/movito/themoviedbapi/TmdbMoviesTest.java +++ b/src/test/java/info/movito/themoviedbapi/TmdbMoviesTest.java @@ -1,66 +1,42 @@ package info.movito.themoviedbapi; -import info.movito.themoviedbapi.model.AlternativeTitle; -import info.movito.themoviedbapi.model.Artwork; -import info.movito.themoviedbapi.model.Genre; -import info.movito.themoviedbapi.model.ProductionCompany; -import info.movito.themoviedbapi.model.ProductionCountry; -import info.movito.themoviedbapi.model.ReleaseDate; -import info.movito.themoviedbapi.model.ReleaseInfo; -import info.movito.themoviedbapi.model.Video; -import info.movito.themoviedbapi.model.core.Language; -import info.movito.themoviedbapi.model.core.Movie; import info.movito.themoviedbapi.model.core.MovieResultsPage; import info.movito.themoviedbapi.model.core.responses.ResponseStatus; -import info.movito.themoviedbapi.model.keywords.Keyword; import info.movito.themoviedbapi.model.movies.AccountStates; import info.movito.themoviedbapi.model.movies.AlternativeTitles; -import info.movito.themoviedbapi.model.movies.Cast; import info.movito.themoviedbapi.model.movies.Credits; -import info.movito.themoviedbapi.model.movies.Crew; -import info.movito.themoviedbapi.model.movies.Data; import info.movito.themoviedbapi.model.movies.ExternalIds; import info.movito.themoviedbapi.model.movies.Images; import info.movito.themoviedbapi.model.movies.KeywordResults; import info.movito.themoviedbapi.model.movies.MovieDb; -import info.movito.themoviedbapi.model.movies.MovieList; import info.movito.themoviedbapi.model.movies.MovieListResultsPage; import info.movito.themoviedbapi.model.movies.Rated; import info.movito.themoviedbapi.model.movies.ReleaseDateResults; -import info.movito.themoviedbapi.model.movies.Review; import info.movito.themoviedbapi.model.movies.ReviewResultsPage; -import info.movito.themoviedbapi.model.movies.Translation; import info.movito.themoviedbapi.model.movies.Translations; import info.movito.themoviedbapi.model.movies.VideoResults; -import info.movito.themoviedbapi.model.movies.changes.Change; -import info.movito.themoviedbapi.model.movies.changes.ChangeItem; import info.movito.themoviedbapi.model.movies.changes.ChangeResults; -import info.movito.themoviedbapi.model.providers.Provider; import info.movito.themoviedbapi.model.providers.ProviderResults; -import info.movito.themoviedbapi.model.providers.WatchProviders; -import info.movito.themoviedbapi.model.reviews.AuthorDetails; import info.movito.themoviedbapi.tools.RequestType; import info.movito.themoviedbapi.tools.TmdbException; import info.movito.themoviedbapi.tools.appendtoresponse.MovieAppendToResponse; +import info.movito.themoviedbapi.util.AbstractJsonMappingValidator; import info.movito.themoviedbapi.util.TestUtils; import info.movito.themoviedbapi.util.Utils; import org.junit.jupiter.api.Test; import java.io.IOException; import java.net.URL; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Optional; import static info.movito.themoviedbapi.AbstractTmdbApi.getObjectMapper; import static info.movito.themoviedbapi.TmdbMovies.TMDB_METHOD_MOVIE; import static info.movito.themoviedbapi.tools.ApiUrl.TMDB_API_BASE_URL; -import static info.movito.themoviedbapi.util.TestUtils.testForNewItems; -import static info.movito.themoviedbapi.util.TestUtils.testForNullFields; -import static info.movito.themoviedbapi.util.TestUtils.testForNullFieldsAndNewItems; +import static info.movito.themoviedbapi.util.TestUtils.validateAbstractJsonMappingFields; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.when; @@ -81,29 +57,31 @@ public void testGetDetails() throws IOException, TmdbException { TmdbMovies tmdbMovies = getTmdbApi().getMovies(); MovieDb movie = tmdbMovies.getDetails(123, "en-US"); assertNotNull(movie); - testForNullFields(movie, "accountStates", "alternativeTitles", "credits", "changes", "externalIds", "images", "keywords", - "recommendations", "releaseDates", "lists", "reviews", "similar", "translations", "videos", "watchProviders"); - testForNewItems(movie); - - List genres = movie.getGenres(); - assertNotNull(genres); - assertFalse(genres.isEmpty()); - testForNullFieldsAndNewItems(genres.get(0)); - - List productionCompanies = movie.getProductionCompanies(); - assertNotNull(productionCompanies); - assertFalse(productionCompanies.isEmpty()); - testForNullFieldsAndNewItems(productionCompanies.get(0)); - - List productionCountries = movie.getProductionCountries(); - assertNotNull(productionCountries); - assertFalse(productionCountries.isEmpty()); - testForNullFieldsAndNewItems(productionCountries.get(0)); - - List spokenLanguages = movie.getSpokenLanguages(); - assertNotNull(spokenLanguages); - assertFalse(spokenLanguages.isEmpty()); - testForNullFieldsAndNewItems(spokenLanguages.get(0)); + + AbstractJsonMappingValidator abstractJsonMappingValidator = new AbstractJsonMappingValidator(movie); + List filteredModel = new ArrayList<>(); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.accountStates"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.alternativeTitles"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.credits"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.changes"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.externalIds"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.images"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.keywords"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.recommendations"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.releaseDates"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.lists"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.reviews"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.similar"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.translations"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.videos"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.watchProviders"); + + abstractJsonMappingValidator.validateNullFields(filteredModel); + abstractJsonMappingValidator.validateEmptyCollections(); + abstractJsonMappingValidator.validateNullContainingCollection(); + abstractJsonMappingValidator.validateEmptyMaps(); + abstractJsonMappingValidator.validateNullContainingMaps(); + abstractJsonMappingValidator.validateNewItems(); } /** @@ -120,84 +98,7 @@ public void testGetDetailsWithAppendToResponse() throws IOException, TmdbExcepti TmdbMovies tmdbMovies = getTmdbApi().getMovies(); MovieDb movie = tmdbMovies.getDetails(123, "en-US", MovieAppendToResponse.values()); assertNotNull(movie); - testForNullFields(movie); - testForNewItems(movie); - - Optional accountStates = movie.getAccountStates(); - assertNotNull(accountStates); - assertTrue(accountStates.isPresent()); - testForNullFields(accountStates.get(), "rated"); // strange case, rated can either be boolean (false) or an object - testForNewItems(accountStates.get()); - - Optional alternativeTitles = movie.getAlternativeTitles(); - assertNotNull(alternativeTitles); - assertTrue(alternativeTitles.isPresent()); - testForNullFieldsAndNewItems(alternativeTitles.get()); - - Optional credits = movie.getCredits(); - assertNotNull(credits); - assertTrue(credits.isPresent()); - testForNullFieldsAndNewItems(credits.get()); - - Optional changes = movie.getChanges(); - assertNotNull(changes); - assertTrue(changes.isPresent()); - testForNullFieldsAndNewItems(changes.get()); - - Optional externalIds = movie.getExternalIds(); - assertNotNull(externalIds); - assertTrue(externalIds.isPresent()); - testForNullFieldsAndNewItems(externalIds.get()); - - Optional images = movie.getImages(); - assertNotNull(images); - assertTrue(images.isPresent()); - testForNullFieldsAndNewItems(images.get()); - - Optional keywords = movie.getKeywords(); - assertNotNull(keywords); - assertTrue(keywords.isPresent()); - testForNullFieldsAndNewItems(keywords.get()); - - Optional lists = movie.getLists(); - assertNotNull(lists); - assertTrue(lists.isPresent()); - testForNullFieldsAndNewItems(lists.get()); - - Optional reviews = movie.getReviews(); - assertNotNull(reviews); - assertTrue(reviews.isPresent()); - testForNullFieldsAndNewItems(reviews.get()); - - Optional recommendations = movie.getRecommendations(); - assertNotNull(recommendations); - assertTrue(recommendations.isPresent()); - testForNullFieldsAndNewItems(recommendations.get()); - - Optional releaseDates = movie.getReleaseDates(); - assertNotNull(releaseDates); - assertTrue(releaseDates.isPresent()); - testForNullFieldsAndNewItems(releaseDates.get()); - - Optional similar = movie.getSimilar(); - assertNotNull(similar); - assertTrue(similar.isPresent()); - testForNullFieldsAndNewItems(similar.get()); - - Optional translations = movie.getTranslations(); - assertNotNull(translations); - assertTrue(translations.isPresent()); - testForNullFieldsAndNewItems(translations.get()); - - Optional videos = movie.getVideos(); - assertNotNull(videos); - assertTrue(videos.isPresent()); - testForNullFieldsAndNewItems(videos.get()); - - Optional watchProviders = movie.getWatchProviders(); - assertNotNull(watchProviders); - assertTrue(watchProviders.isPresent()); - testForNullFieldsAndNewItems(watchProviders.get()); + validateAbstractJsonMappingFields(movie); } /** @@ -212,12 +113,12 @@ public void testGetAccountStates() throws IOException, TmdbException { TmdbMovies tmdbMovies = getTmdbApi().getMovies(); AccountStates accountStates = tmdbMovies.getAccountStates(123, "123", null); assertNotNull(accountStates); - testForNullFieldsAndNewItems(accountStates); + validateAbstractJsonMappingFields(accountStates); Optional rated = accountStates.getRated(); assertNotNull(rated); assertTrue(rated.isPresent()); - testForNullFieldsAndNewItems(rated.get()); + validateAbstractJsonMappingFields(rated.get()); } /** @@ -232,12 +133,7 @@ public void testGetAlternativeTitles() throws IOException, TmdbException { TmdbMovies tmdbMovies = getTmdbApi().getMovies(); AlternativeTitles alternativeTitles = tmdbMovies.getAlternativeTitles(123, "US"); assertNotNull(alternativeTitles); - testForNullFieldsAndNewItems(alternativeTitles); - - List titles = alternativeTitles.getTitles(); - assertNotNull(titles); - assertFalse(titles.isEmpty()); - testForNullFieldsAndNewItems(titles.get(0)); + validateAbstractJsonMappingFields(alternativeTitles); } /** @@ -252,20 +148,7 @@ public void testGetChanges() throws IOException, TmdbException { TmdbMovies tmdbMovies = getTmdbApi().getMovies(); ChangeResults changeResults = tmdbMovies.getChanges(123, null, null, null); assertNotNull(changeResults); - testForNullFieldsAndNewItems(changeResults); - - List changedItems = changeResults.getChangedItems(); - assertNotNull(changedItems); - assertFalse(changedItems.isEmpty()); - - Change change = changedItems.get(0); - assertNotNull(change); - testForNullFieldsAndNewItems(change); - - List changeItems = change.getChangeItems(); - assertNotNull(changeItems); - assertFalse(changeItems.isEmpty()); - testForNullFieldsAndNewItems(changeItems.get(0)); + validateAbstractJsonMappingFields(changeResults); } /** @@ -280,17 +163,7 @@ public void testGetCredits() throws IOException, TmdbException { TmdbMovies tmdbMovies = getTmdbApi().getMovies(); Credits credits = tmdbMovies.getCredits(123, "en-US"); assertNotNull(credits); - testForNullFieldsAndNewItems(credits); - - List cast = credits.getCast(); - assertNotNull(cast); - assertFalse(cast.isEmpty()); - testForNullFieldsAndNewItems(cast.get(0)); - - List crew = credits.getCrew(); - assertNotNull(crew); - assertFalse(crew.isEmpty()); - testForNullFieldsAndNewItems(crew.get(0)); + validateAbstractJsonMappingFields(credits); } /** @@ -305,7 +178,7 @@ public void testGetExternalIds() throws IOException, TmdbException { TmdbMovies tmdbMovies = getTmdbApi().getMovies(); ExternalIds externalIds = tmdbMovies.getExternalIds(123); assertNotNull(externalIds); - testForNullFieldsAndNewItems(externalIds); + validateAbstractJsonMappingFields(externalIds); } /** @@ -320,19 +193,7 @@ public void testGetImages() throws IOException, TmdbException { TmdbMovies tmdbMovies = getTmdbApi().getMovies(); Images images = tmdbMovies.getImages(123, "en-US"); assertNotNull(images); - testForNullFieldsAndNewItems(images); - - List posters = images.getPosters(); - assertFalse(posters.isEmpty()); - testForNullFieldsAndNewItems(posters.get(0)); - - List backdrops = images.getBackdrops(); - assertFalse(backdrops.isEmpty()); - testForNullFieldsAndNewItems(backdrops.get(0)); - - List logos = images.getLogos(); - assertFalse(logos.isEmpty()); - testForNullFieldsAndNewItems(logos.get(0)); + validateAbstractJsonMappingFields(images); } /** @@ -347,11 +208,7 @@ public void testGetKeywords() throws IOException, TmdbException { TmdbMovies tmdbMovies = getTmdbApi().getMovies(); KeywordResults keywords = tmdbMovies.getKeywords(123); assertNotNull(keywords); - testForNullFieldsAndNewItems(keywords); - - List keywordsList = keywords.getKeywords(); - assertFalse(keywordsList.isEmpty()); - testForNullFieldsAndNewItems(keywordsList.get(0)); + validateAbstractJsonMappingFields(keywords); } /** @@ -366,9 +223,31 @@ public void testGetLatest() throws IOException, TmdbException { TmdbMovies tmdbMovies = getTmdbApi().getMovies(); MovieDb movie = tmdbMovies.getLatest(); assertNotNull(movie); - testForNullFields(movie, "accountStates", "alternativeTitles", "credits", "changes", "externalIds", "images", "keywords", - "recommendations", "releaseDates", "lists", "reviews", "similar", "translations", "videos", "watchProviders"); - testForNewItems(movie); + + AbstractJsonMappingValidator abstractJsonMappingValidator = new AbstractJsonMappingValidator(movie); + List filteredModel = new ArrayList<>(); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.accountStates"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.alternativeTitles"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.credits"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.changes"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.externalIds"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.images"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.keywords"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.recommendations"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.releaseDates"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.lists"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.reviews"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.similar"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.translations"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.videos"); + filteredModel.add("info.movito.themoviedbapi.model.movies.MovieDb.watchProviders"); + + abstractJsonMappingValidator.validateNullFields(filteredModel); + abstractJsonMappingValidator.validateEmptyCollections(); + abstractJsonMappingValidator.validateNullContainingCollection(); + abstractJsonMappingValidator.validateEmptyMaps(); + abstractJsonMappingValidator.validateNullContainingMaps(); + abstractJsonMappingValidator.validateNewItems(); } /** @@ -383,11 +262,7 @@ public void testGetLists() throws IOException, TmdbException { TmdbMovies tmdbMovies = getTmdbApi().getMovies(); MovieListResultsPage lists = tmdbMovies.getLists(123, "en-US", null); assertNotNull(lists); - testForNullFieldsAndNewItems(lists); - - MovieList list = lists.getResults().get(0); - assertNotNull(list); - testForNullFieldsAndNewItems(list); + validateAbstractJsonMappingFields(lists); } /** @@ -402,11 +277,7 @@ public void testGetRecommendations() throws IOException, TmdbException { TmdbMovies tmdbMovies = getTmdbApi().getMovies(); MovieResultsPage recommendations = tmdbMovies.getRecommendations(123, "en-US", 1); assertNotNull(recommendations); - testForNullFieldsAndNewItems(recommendations); - - Movie movie = recommendations.getResults().get(0); - assertNotNull(movie); - testForNullFieldsAndNewItems(movie); + validateAbstractJsonMappingFields(recommendations); } /** @@ -421,24 +292,7 @@ public void testGetReleaseDates() throws IOException, TmdbException { TmdbMovies tmdbMovies = getTmdbApi().getMovies(); ReleaseDateResults releaseDates = tmdbMovies.getReleaseDates(123); assertNotNull(releaseDates); - testForNullFieldsAndNewItems(releaseDates); - - ReleaseInfo releaseInfo = releaseDates.getResults().get(0); - assertNotNull(releaseInfo); - testForNullFieldsAndNewItems(releaseInfo); - - List releaseDatesList = releaseInfo.getReleaseDates(); - assertNotNull(releaseDatesList); - assertFalse(releaseDatesList.isEmpty()); - - ReleaseDate releaseDate = releaseDatesList.get(0); - assertNotNull(releaseDate); - testForNullFieldsAndNewItems(releaseDate); - - List descriptors = releaseDate.getDescriptors(); - assertNotNull(descriptors); - assertFalse(descriptors.isEmpty()); - assertNotNull(descriptors.get(0)); + validateAbstractJsonMappingFields(releaseDates); } /** @@ -453,15 +307,7 @@ public void testGetReviews() throws IOException, TmdbException { TmdbMovies tmdbMovies = getTmdbApi().getMovies(); ReviewResultsPage reviews = tmdbMovies.getReviews(123, "en-US", null); assertNotNull(reviews); - testForNullFieldsAndNewItems(reviews); - - Review review = reviews.getResults().get(0); - assertNotNull(review); - testForNullFieldsAndNewItems(review); - - AuthorDetails authorDetails = review.getAuthorDetails(); - assertNotNull(authorDetails); - testForNullFieldsAndNewItems(authorDetails); + validateAbstractJsonMappingFields(reviews); } /** @@ -476,11 +322,7 @@ public void testGetSimilar() throws IOException, TmdbException { TmdbMovies tmdbMovies = getTmdbApi().getMovies(); MovieResultsPage similar = tmdbMovies.getSimilar(123, "en-US", null); assertNotNull(similar); - testForNullFieldsAndNewItems(similar); - - Movie movie = similar.getResults().get(0); - assertNotNull(movie); - testForNullFieldsAndNewItems(movie); + validateAbstractJsonMappingFields(similar); } /** @@ -495,19 +337,7 @@ public void testGetTranslations() throws IOException, TmdbException { TmdbMovies tmdbMovies = getTmdbApi().getMovies(); Translations translations = tmdbMovies.getTranslations(123); assertNotNull(translations); - testForNullFieldsAndNewItems(translations); - - List translationsList = translations.getTranslations(); - assertNotNull(translationsList); - assertFalse(translationsList.isEmpty()); - - Translation translation = translationsList.get(0); - assertNotNull(translation); - testForNullFieldsAndNewItems(translation); - - Data data = translation.getData(); - assertNotNull(data); - testForNullFieldsAndNewItems(data); + validateAbstractJsonMappingFields(translations); } /** @@ -522,12 +352,7 @@ public void testGetVideos() throws IOException, TmdbException { TmdbMovies tmdbMovies = getTmdbApi().getMovies(); VideoResults videos = tmdbMovies.getVideos(123, "en-US"); assertNotNull(videos); - testForNullFieldsAndNewItems(videos); - - List