Updated TestSuite

master
Stuart Boston 11 years ago
parent 53aeac2b3e
commit 1aa6e5bbf8

@ -1,3 +1,4 @@
/*
* Copyright (c) 2004-2015 Stuart Boston
*

@ -24,7 +24,13 @@ import com.omertron.themoviedbapi.model.movie.MovieBasic;
import com.omertron.themoviedbapi.model.tv.TVBasic;
import com.omertron.themoviedbapi.results.ResultList;
import com.omertron.themoviedbapi.interfaces.IIdentification;
import com.omertron.themoviedbapi.model.person.Person;
import com.omertron.themoviedbapi.model.tv.TVEpisodeInfo;
import com.omertron.themoviedbapi.model.tv.TVInfo;
import com.omertron.themoviedbapi.model.tv.TVSeasonInfo;
import java.util.List;
import java.util.Random;
import org.apache.commons.lang3.StringUtils;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@ -36,9 +42,18 @@ public class TestSuite {
throw new UnsupportedOperationException("Utility class");
}
public static int randomRating() {
return new Random().nextInt(10) + 1;
}
public static void test(ResultList<?> result) {
assertNotNull("Null result list", result);
assertFalse("Empty result list", result.isEmpty());
test(result.getResults());
}
public static void test(List<?> result) {
assertNotNull("Null results", result);
assertNotNull("Null collection", result.getResults());
assertFalse("Empty results", result.isEmpty());
}
@ -59,6 +74,38 @@ public class TestSuite {
assertTrue("No first air date", isNotBlank(test.getFirstAirDate()));
}
public static void test(TVInfo test) {
assertTrue("No ID", test.getId() > 0);
assertFalse("No runtime", test.getEpisodeRunTime().isEmpty());
assertFalse("No genres", test.getGenres().isEmpty());
assertTrue("No season count", test.getNumberOfSeasons() > 0);
assertTrue("No episode count", test.getNumberOfEpisodes() > 0);
}
public static void test(TVEpisodeInfo test) {
assertTrue("No ID", test.getId() > 0);
assertTrue("No name", StringUtils.isNotBlank(test.getName()));
assertTrue("No crew", test.getCrew().size() > 0);
assertTrue("No guest stars", test.getGuestStars().size() > 0);
}
public static void test(Person test) {
assertTrue("Missing bio", StringUtils.isNotBlank(test.getBiography()));
assertTrue("Missing birthday", StringUtils.isNotBlank(test.getBirthday()));
assertTrue("Missing homepage", StringUtils.isNotBlank(test.getHomepage()));
assertTrue("Missing name", StringUtils.isNotBlank(test.getName()));
assertTrue("Missing birth place", StringUtils.isNotBlank(test.getPlaceOfBirth()));
assertTrue("Missing artwork", StringUtils.isNotBlank(test.getProfilePath()));
assertTrue("Missing bio", test.getPopularity() > 0F);
}
public static void test(TVSeasonInfo test) {
assertTrue("No ID", test.getId() > 0);
assertTrue("No name", StringUtils.isNotBlank(test.getName()));
assertTrue("No overview", StringUtils.isNotBlank(test.getOverview()));
assertTrue("No episodes", test.getEpisodes().size() > 0);
}
public static void testId(ResultList<? extends IIdentification> result, int id, String message) {
testId(result.getResults(), id, message);
}

@ -30,12 +30,10 @@ import com.omertron.themoviedbapi.model.list.UserList;
import com.omertron.themoviedbapi.model.movie.MovieBasic;
import com.omertron.themoviedbapi.model.tv.TVBasic;
import com.omertron.themoviedbapi.results.ResultList;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
@ -97,8 +95,8 @@ public class TmdbAccountTest extends AbstractTests {
public void testGetUserLists() throws MovieDbException {
LOG.info("getUserLists");
ResultList<UserList> results = instance.getUserLists(getSessionId(), getAccountId());
assertNotNull("No list found", results);
assertFalse("No entries found", results.isEmpty());
TestSuite.test(results);
for (UserList result : results.getResults()) {
TestSuite.test(result);
}
@ -113,7 +111,8 @@ public class TmdbAccountTest extends AbstractTests {
public void testGetFavoriteMovies() throws MovieDbException {
LOG.info("getFavoriteMovies");
ResultList<MovieBasic> results = instance.getFavoriteMovies(getSessionId(), getAccountId());
assertFalse("No entries found", results.isEmpty());
TestSuite.test(results);
for (MovieBasic result : results.getResults()) {
TestSuite.test(result);
}
@ -128,7 +127,8 @@ public class TmdbAccountTest extends AbstractTests {
public void testGetFavoriteTv() throws MovieDbException {
LOG.info("getFavoriteTv");
ResultList<TVBasic> results = instance.getFavoriteTv(getSessionId(), getAccountId());
assertFalse("No entries found", results.isEmpty());
TestSuite.test(results);
for (TVBasic result : results.getResults()) {
TestSuite.test(result);
}
@ -173,7 +173,7 @@ public class TmdbAccountTest extends AbstractTests {
public void testGetRatedMovies() throws MovieDbException {
LOG.info("getRatedMovies");
ResultList<MovieBasic> results = instance.getRatedMovies(getSessionId(), getAccountId(), null, null, null);
assertFalse("No entries found", results.isEmpty());
TestSuite.test(results);
}
/**
@ -185,7 +185,7 @@ public class TmdbAccountTest extends AbstractTests {
public void testGetRatedTV() throws MovieDbException {
LOG.info("getRatedTV");
ResultList<TVBasic> results = instance.getRatedTV(getSessionId(), getAccountId(), null, null, null);
assertFalse("No entries found", results.isEmpty());
TestSuite.test(results);
for (TVBasic result : results.getResults()) {
TestSuite.test(result);
}
@ -200,8 +200,7 @@ public class TmdbAccountTest extends AbstractTests {
public void testGetWatchListMovie() throws MovieDbException {
LOG.info("getWatchListMovie");
ResultList<MovieBasic> results = instance.getWatchListMovie(getSessionId(), getAccountId(), null, null, null);
assertNotNull("No rated list found", results);
assertFalse("No entries found", results.isEmpty());
TestSuite.test(results);
for (MovieBasic result : results.getResults()) {
TestSuite.test(result);
}
@ -216,8 +215,7 @@ public class TmdbAccountTest extends AbstractTests {
public void testGetWatchListTV() throws MovieDbException {
LOG.info("getWatchListTV");
ResultList<TVBasic> results = instance.getWatchListTV(getSessionId(), getAccountId(), null, null, null);
assertNotNull("No rated list found", results);
assertFalse("No entries found", results.isEmpty());
TestSuite.test(results);
for (TVBasic result : results.getResults()) {
TestSuite.test(result);
}
@ -286,12 +284,12 @@ public class TmdbAccountTest extends AbstractTests {
result = instance.getGuestRatedMovies(guestSession, language, page, sortBy);
}
assertFalse("No movies found!", result.isEmpty());
TestSuite.test(result);
}
private void postGuestRating(String guestSessionId, int movieId) throws MovieDbException {
TmdbMovies tmdbMovies = new TmdbMovies(getApiKey(), getHttpTools());
Integer rating = new Random().nextInt(10) + 1;
int rating = TestSuite.randomRating();
LOG.info("Posting rating of '{}' to ID {} for guest session '{}'", rating, movieId, guestSessionId);
StatusCode sc = tmdbMovies.postMovieRating(movieId, rating, null, guestSessionId);

@ -21,11 +21,11 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.TestSuite;
import com.omertron.themoviedbapi.model.change.ChangeListItem;
import com.omertron.themoviedbapi.results.ResultList;
import com.omertron.themoviedbapi.tools.MethodBase;
import org.junit.AfterClass;
import static org.junit.Assert.assertFalse;
import org.junit.BeforeClass;
import org.junit.Test;
@ -59,7 +59,7 @@ public class TmdbChangesTest extends AbstractTests {
public void testGetMovieChangesList() throws MovieDbException {
LOG.info("getMovieChangesList");
ResultList<ChangeListItem> result = instance.getChangeList(MethodBase.MOVIE, null, null, null);
assertFalse("No Movie changes.", result.isEmpty());
TestSuite.test(result);
}
/**
@ -71,7 +71,7 @@ public class TmdbChangesTest extends AbstractTests {
public void testGetPersonChangesList() throws MovieDbException {
LOG.info("getPersonChangesList");
ResultList<ChangeListItem> result = instance.getChangeList(MethodBase.PERSON, null, null, null);
assertFalse("No Person changes.", result.isEmpty());
TestSuite.test(result);
}
/**
@ -83,6 +83,6 @@ public class TmdbChangesTest extends AbstractTests {
public void testGetTVChangesList() throws MovieDbException {
LOG.info("getTVChangesList");
ResultList<ChangeListItem> result = instance.getChangeList(MethodBase.TV, null, null, null);
assertFalse("No TV changes.", result.isEmpty());
TestSuite.test(result);
}
}

@ -21,6 +21,7 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.TestSuite;
import com.omertron.themoviedbapi.model.artwork.Artwork;
import com.omertron.themoviedbapi.model.collection.CollectionInfo;
import com.omertron.themoviedbapi.results.ResultList;
@ -73,7 +74,7 @@ public class TmdbCollectionsTest extends AbstractTests {
public void testGetCollectionImages() throws MovieDbException {
LOG.info("getCollectionImages");
ResultList<Artwork> result = instance.getCollectionImages(ID_COLLECTION_STAR_WARS, LANGUAGE_DEFAULT);
assertFalse("No artwork found", result.getResults().isEmpty());
TestSuite.test(result);
}
}

@ -21,12 +21,12 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.TestSuite;
import com.omertron.themoviedbapi.model.company.Company;
import com.omertron.themoviedbapi.model.movie.MovieBasic;
import com.omertron.themoviedbapi.results.ResultList;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
@ -85,6 +85,6 @@ public class TmdbCompaniesTest extends AbstractTests {
public void testGetCompanyMovies() throws MovieDbException {
LOG.info("getCompanyMovies");
ResultList<MovieBasic> result = instance.getCompanyMovies(ID_COMPANY, LANGUAGE_DEFAULT, 0);
assertFalse("No company movies found", result.isEmpty());
TestSuite.test(result);
}
}

@ -21,6 +21,7 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.TestSuite;
import com.omertron.themoviedbapi.model.config.Configuration;
import com.omertron.themoviedbapi.model.config.JobDepartment;
import com.omertron.themoviedbapi.results.ResultList;
@ -106,9 +107,7 @@ public class TmdbConfigurationTest extends AbstractTests {
public void testGetJobs() throws MovieDbException {
LOG.info("getJobs");
ResultList<JobDepartment> result = instance.getJobs();
assertNotNull("Null results", result);
assertFalse("Empty results", result.getResults().isEmpty());
assertTrue("No results", result.getResults().size() > 0);
TestSuite.test(result);
}
/**

@ -21,13 +21,13 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.TestSuite;
import com.omertron.themoviedbapi.model.discover.Discover;
import com.omertron.themoviedbapi.model.movie.MovieBasic;
import com.omertron.themoviedbapi.model.tv.TVBasic;
import com.omertron.themoviedbapi.results.ResultList;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.assertFalse;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@ -73,7 +73,7 @@ public class TmdbDiscoverTest extends AbstractTests {
discover.year(2013).language(LANGUAGE_ENGLISH);
ResultList<MovieBasic> result = instance.getDiscoverMovies(discover);
assertFalse("No movies discovered", result.isEmpty());
TestSuite.test(result);
}
/**
@ -88,7 +88,7 @@ public class TmdbDiscoverTest extends AbstractTests {
discover.year(2013).language(LANGUAGE_ENGLISH);
ResultList<TVBasic> result = instance.getDiscoverTV(discover);
assertFalse("No TV shows discovered", result.isEmpty());
TestSuite.test(result);
}
}

@ -23,6 +23,7 @@ import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.ArtworkResults;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.TestID;
import com.omertron.themoviedbapi.TestSuite;
import com.omertron.themoviedbapi.enumeration.ArtworkType;
import com.omertron.themoviedbapi.model.StatusCode;
import com.omertron.themoviedbapi.model.artwork.Artwork;
@ -35,8 +36,6 @@ import com.omertron.themoviedbapi.model.tv.TVEpisodeInfo;
import com.omertron.themoviedbapi.results.ResultList;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.apache.commons.lang3.StringUtils;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.assertEquals;
@ -97,10 +96,7 @@ public class TmdbEpisodesTest extends AbstractTests {
for (TestID test : TV_IDS) {
TVEpisodeInfo result = instance.getEpisodeInfo(test.getTmdb(), seasonNumber, episodeNumber, language, appendToResponse);
assertTrue("No ID", result.getId() > 0);
assertTrue("No name", StringUtils.isNotBlank(result.getName()));
assertTrue("No crew", result.getCrew().size() > 0);
assertTrue("No guest stars", result.getGuestStars().size() > 0);
TestSuite.test(result);
}
}
@ -196,9 +192,8 @@ public class TmdbEpisodesTest extends AbstractTests {
int seasonNumber = 1;
int episodeNumber = 1;
ArtworkResults results = new ArtworkResults();
for (TestID test : TV_IDS) {
ArtworkResults results = new ArtworkResults();
ResultList<Artwork> result = instance.getEpisodeImages(test.getTmdb(), seasonNumber, episodeNumber);
assertFalse("No artwork", result.isEmpty());
for (Artwork artwork : result.getResults()) {
@ -225,7 +220,7 @@ public class TmdbEpisodesTest extends AbstractTests {
String guestSessionID = null;
for (TestID test : TV_IDS) {
Integer rating = new Random().nextInt(10) + 1;
int rating = TestSuite.randomRating();
StatusCode result = instance.postEpisodeRating(test.getTmdb(), seasonNumber, episodeNumber, rating, getSessionId(), guestSessionID);
assertEquals("failed to post rating", 12, result.getCode());
}
@ -246,7 +241,7 @@ public class TmdbEpisodesTest extends AbstractTests {
for (TestID test : TV_IDS) {
ResultList<Video> result = instance.getEpisodeVideos(test.getTmdb(), seasonNumber, episodeNumber, language);
LOG.info("Found {} videos", result.getResults().size());
TestSuite.test(result);
}
}

@ -22,18 +22,14 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.TestID;
import com.omertron.themoviedbapi.TestSuite;
import com.omertron.themoviedbapi.enumeration.ExternalSource;
import com.omertron.themoviedbapi.model.FindResults;
import com.omertron.themoviedbapi.model.movie.MovieBasic;
import com.omertron.themoviedbapi.model.person.PersonFind;
import com.omertron.themoviedbapi.model.tv.TVBasic;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@ -91,16 +87,10 @@ public class TmdbFindTest extends AbstractTests {
FindResults result;
for (TestID test : FILM_IDS) {
LOG.info("Testing {}", test);
result = instance.find(test.getImdb(), ExternalSource.IMDB_ID, LANGUAGE_DEFAULT);
assertFalse("No movie for ID " + test.getName(), result.getMovieResults().isEmpty());
boolean found = false;
for (MovieBasic m : result.getMovieResults()) {
if (m.getId() == test.getTmdb()) {
found = true;
break;
}
}
assertTrue("No movie found: " + test.getName(), found);
TestSuite.test(result.getMovieResults());
TestSuite.testId(result.getMovieResults(), test.getTmdb(), "Movie");
}
}
@ -116,19 +106,10 @@ public class TmdbFindTest extends AbstractTests {
FindResults result;
for (TestID test : PERSON_IDS) {
LOG.info("Testing {}", test);
result = instance.find(test.getImdb(), ExternalSource.IMDB_ID, LANGUAGE_DEFAULT);
assertFalse("No person for ID: " + test.getName(), result.getPersonResults().isEmpty());
boolean found = false;
for (PersonFind p : result.getPersonResults()) {
for (Object x : p.getKnownFor()) {
LOG.info(" {}", x.toString());
}
if (p.getId() == test.getTmdb()) {
found = true;
break;
}
}
assertTrue("No person found for ID: " + test.getName(), found);
TestSuite.test(result.getPersonResults());
TestSuite.testId(result.getPersonResults(), test.getTmdb(), "Person");
}
}
@ -143,16 +124,10 @@ public class TmdbFindTest extends AbstractTests {
FindResults result;
for (TestID test : TV_IDS) {
LOG.info("Testing {}", test);
result = instance.find(test.getImdb(), ExternalSource.IMDB_ID, LANGUAGE_DEFAULT);
assertFalse("No TV Show info for ID: " + test.getName(), result.getTvResults().isEmpty());
boolean found = false;
for (TVBasic tv : result.getTvResults()) {
if (tv.getId() == test.getTmdb()) {
found = true;
break;
}
}
assertTrue("No TV Show found for ID: " + test.getName(), found);
TestSuite.test(result.getTvResults());
TestSuite.testId(result.getTvResults(), test.getTmdb(), "TV");
}
}

@ -21,13 +21,13 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.TestSuite;
import com.omertron.themoviedbapi.model.keyword.Keyword;
import com.omertron.themoviedbapi.model.movie.MovieBasic;
import com.omertron.themoviedbapi.results.ResultList;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@ -36,7 +36,7 @@ import org.junit.Test;
*
* @author stuart.boston
*/
public class TmdbKeywordsTest extends AbstractTests{
public class TmdbKeywordsTest extends AbstractTests {
private static TmdbKeywords tmdb;
private static final String ID_KEYWORD = "1721";
@ -47,7 +47,7 @@ public class TmdbKeywordsTest extends AbstractTests{
@BeforeClass
public static void setUpClass() throws MovieDbException {
doConfiguration();
tmdb = new TmdbKeywords(getApiKey(),getHttpTools());
tmdb = new TmdbKeywords(getApiKey(), getHttpTools());
}
@AfterClass
@ -84,7 +84,7 @@ public class TmdbKeywordsTest extends AbstractTests{
LOG.info("getKeywordMovies");
int page = 0;
ResultList<MovieBasic> result = tmdb.getKeywordMovies(ID_KEYWORD, LANGUAGE_DEFAULT, page);
assertFalse("No keyword movies found", result.isEmpty());
TestSuite.test(result);
}
}

@ -23,6 +23,7 @@ import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.ArtworkResults;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.TestID;
import com.omertron.themoviedbapi.TestSuite;
import com.omertron.themoviedbapi.enumeration.ArtworkType;
import com.omertron.themoviedbapi.model.StatusCode;
import com.omertron.themoviedbapi.model.artwork.Artwork;
@ -45,7 +46,6 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import static org.junit.Assert.assertEquals;
@ -146,7 +146,7 @@ public class TmdbMoviesTest extends AbstractTests {
for (TestID test : FILM_IDS) {
ResultList<AlternativeTitle> result = instance.getMovieAlternativeTitles(test.getTmdb(), country, appendToResponse);
assertFalse("No alt titles", result.isEmpty());
TestSuite.test(result);
}
}
@ -165,6 +165,8 @@ public class TmdbMoviesTest extends AbstractTests {
MediaCreditList result = instance.getMovieCredits(test.getTmdb(), appendToResponse);
assertNotNull(result);
assertFalse(result.getCast().isEmpty());
TestSuite.test(result.getCast());
TestSuite.test(result.getCrew());
boolean found = false;
for (MediaCreditCast p : result.getCast()) {
@ -176,7 +178,6 @@ public class TmdbMoviesTest extends AbstractTests {
assertTrue(test.getOther() + " not found in cast!", found);
assertFalse(result.getCrew().isEmpty());
break;
}
}
@ -219,7 +220,7 @@ public class TmdbMoviesTest extends AbstractTests {
for (TestID test : FILM_IDS) {
ResultList<Keyword> result = instance.getMovieKeywords(test.getTmdb(), appendToResponse);
assertFalse("No keywords", result.isEmpty());
TestSuite.test(result);
}
}
@ -237,7 +238,7 @@ public class TmdbMoviesTest extends AbstractTests {
for (TestID test : FILM_IDS) {
ResultList<ReleaseInfo> result = instance.getMovieReleaseInfo(test.getTmdb(), language, appendToResponse);
assertFalse("No release info", result.isEmpty());
TestSuite.test(result);
}
}
@ -274,7 +275,7 @@ public class TmdbMoviesTest extends AbstractTests {
for (TestID test : FILM_IDS) {
ResultList<Translation> result = instance.getMovieTranslations(test.getTmdb(), appendToResponse);
assertFalse("No translations", result.isEmpty());
TestSuite.test(result);
}
}
@ -293,7 +294,7 @@ public class TmdbMoviesTest extends AbstractTests {
for (TestID test : FILM_IDS) {
ResultList<MovieInfo> result = instance.getSimilarMovies(test.getTmdb(), page, language, appendToResponse);
assertFalse("No similar movies", result.isEmpty());
TestSuite.test(result);
}
}
@ -316,7 +317,7 @@ public class TmdbMoviesTest extends AbstractTests {
continue;
}
ResultList<Review> result = instance.getMovieReviews(test.getTmdb(), page, language, appendToResponse);
assertFalse("No reviews", result.isEmpty());
TestSuite.test(result);
}
}
@ -335,8 +336,7 @@ public class TmdbMoviesTest extends AbstractTests {
for (TestID test : FILM_IDS) {
ResultList<UserList> result = instance.getMovieLists(test.getTmdb(), page, language, appendToResponse);
assertFalse("Empty list", result.isEmpty());
assertTrue(result.getTotalResults() > 0);
TestSuite.test(result);
}
}
@ -379,7 +379,7 @@ public class TmdbMoviesTest extends AbstractTests {
@Test
public void testPostMovieRating() throws MovieDbException {
LOG.info("postMovieRating");
Integer rating = new Random().nextInt(10) + 1;
int rating = TestSuite.randomRating();
for (TestID test : FILM_IDS) {
StatusCode result = instance.postMovieRating(test.getTmdb(), rating, getSessionId(), null);
@ -429,7 +429,7 @@ public class TmdbMoviesTest extends AbstractTests {
String language = LANGUAGE_DEFAULT;
ResultList<MovieInfo> result = instance.getNowPlayingMovies(page, language);
assertFalse("No results found", result.isEmpty());
TestSuite.test(result);
}
/**
@ -444,7 +444,7 @@ public class TmdbMoviesTest extends AbstractTests {
String language = LANGUAGE_DEFAULT;
ResultList<MovieInfo> result = instance.getPopularMovieList(page, language);
assertFalse("No results found", result.isEmpty());
TestSuite.test(result);
}
/**
@ -459,7 +459,7 @@ public class TmdbMoviesTest extends AbstractTests {
String language = LANGUAGE_DEFAULT;
ResultList<MovieInfo> result = instance.getTopRatedMovies(page, language);
assertFalse("No results found", result.isEmpty());
TestSuite.test(result);
}
}

@ -22,6 +22,7 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.TestID;
import com.omertron.themoviedbapi.TestSuite;
import com.omertron.themoviedbapi.enumeration.ArtworkType;
import com.omertron.themoviedbapi.enumeration.MediaType;
import com.omertron.themoviedbapi.model.artwork.Artwork;
@ -70,7 +71,7 @@ public class TmdbPeopleTest extends AbstractTests {
doConfiguration();
instance = new TmdbPeople(getApiKey(), getHttpTools());
testIDs.add(new TestID("Bruce Willis", "nm0000246", 62));
// testIDs.add(new TestID("Will Smith", "nm0000226", 2888));
testIDs.add(new TestID("Will Smith", "nm0000226", 2888));
}
@AfterClass
@ -98,14 +99,8 @@ public class TmdbPeopleTest extends AbstractTests {
for (TestID test : testIDs) {
result = instance.getPersonInfo(test.getTmdb());
assertEquals("Wrong actor returned", test.getTmdb(), result.getId());
assertTrue("Missing bio", StringUtils.isNotBlank(result.getBiography()));
assertTrue("Missing birthday", StringUtils.isNotBlank(result.getBirthday()));
assertTrue("Missing homepage", StringUtils.isNotBlank(result.getHomepage()));
assertEquals("Missing IMDB", test.getImdb(), result.getImdbId());
assertTrue("Missing name", StringUtils.isNotBlank(result.getName()));
assertTrue("Missing birth place", StringUtils.isNotBlank(result.getPlaceOfBirth()));
assertTrue("Missing artwork", StringUtils.isNotBlank(result.getProfilePath()));
assertTrue("Missing bio", result.getPopularity() > 0F);
TestSuite.test(result);
}
}
@ -124,8 +119,8 @@ public class TmdbPeopleTest extends AbstractTests {
PersonCredits<CreditMovieBasic> result = instance.getPersonMovieCredits(test.getTmdb(), language, appendToResponse);
LOG.info("ID: {}, # Cast: {}, # Crew: {}", result.getId(), result.getCast().size(), result.getCrew().size());
assertEquals("Incorrect ID", test.getTmdb(), result.getId());
assertFalse("No cast", result.getCast().isEmpty());
assertFalse("No crew", result.getCrew().isEmpty());
TestSuite.test(result.getCast());
TestSuite.test(result.getCrew());
// Check that we have the movie specific fields
assertTrue("No title", StringUtils.isNotBlank(result.getCast().get(0).getTitle()));
@ -148,8 +143,8 @@ public class TmdbPeopleTest extends AbstractTests {
PersonCredits<CreditTVBasic> result = instance.getPersonTVCredits(test.getTmdb(), language, appendToResponse);
LOG.info("ID: {}, # Cast: {}, # Crew: {}", result.getId(), result.getCast().size(), result.getCrew().size());
assertEquals("Incorrect ID", test.getTmdb(), result.getId());
assertFalse("No cast", result.getCast().isEmpty());
assertFalse("No crew", result.getCrew().isEmpty());
TestSuite.test(result.getCast());
TestSuite.test(result.getCrew());
// Check that we have the TV specific fields
assertTrue("No title", StringUtils.isNotBlank(result.getCast().get(0).getName()));
@ -172,8 +167,8 @@ public class TmdbPeopleTest extends AbstractTests {
PersonCredits<CreditBasic> result = instance.getPersonCombinedCredits(test.getTmdb(), language, appendToResponse);
LOG.info("ID: {}, # Cast: {}, # Crew: {}", result.getId(), result.getCast().size(), result.getCrew().size());
assertEquals("Incorrect ID", test.getTmdb(), result.getId());
assertFalse("No cast", result.getCast().isEmpty());
assertFalse("No crew", result.getCrew().isEmpty());
TestSuite.test(result.getCast());
TestSuite.test(result.getCrew());
boolean checkedMovie = false;
boolean checkedTV = false;
@ -225,7 +220,7 @@ public class TmdbPeopleTest extends AbstractTests {
for (TestID test : testIDs) {
ResultList<Artwork> result = instance.getPersonImages(test.getTmdb());
assertFalse("No artwork", result.isEmpty());
TestSuite.test(result);
assertEquals("Wrong artwork type", ArtworkType.PROFILE, result.getResults().get(0).getArtworkType());
}
}
@ -243,7 +238,7 @@ public class TmdbPeopleTest extends AbstractTests {
for (TestID test : testIDs) {
ResultList<ArtworkMedia> result = instance.getPersonTaggedImages(test.getTmdb(), page, language);
assertFalse("No images", result.isEmpty());
TestSuite.test(result);
for (ArtworkMedia am : result.getResults()) {
assertTrue("No ID", StringUtils.isNotBlank(am.getId()));
assertTrue("No file path", StringUtils.isNotBlank(am.getFilePath()));
@ -292,8 +287,7 @@ public class TmdbPeopleTest extends AbstractTests {
LOG.info("getPersonPopular");
Integer page = null;
ResultList<PersonFind> result = instance.getPersonPopular(page);
assertFalse("No results", result.isEmpty());
assertTrue("No results", result.getResults().size() > 0);
TestSuite.test(result);
for (PersonFind p : result.getResults()) {
assertFalse("No known for entries", p.getKnownFor().isEmpty());
LOG.info("{} ({}) = {}", p.getName(), p.getId(), p.getKnownFor().size());
@ -308,10 +302,8 @@ public class TmdbPeopleTest extends AbstractTests {
@Test
public void testGetPersonLatest() throws MovieDbException {
LOG.info("getPersonLatest");
Person result = instance.getPersonLatest();
assertTrue("No ID", result.getId() > 0);
assertTrue("No name!", StringUtils.isNotBlank(result.getName()));
TestSuite.test(result);
}
}

@ -79,16 +79,7 @@ public class TmdbSearchTest extends AbstractTests {
int page = 0;
ResultList<Collection> result = instance.searchCollection(query, page, LANGUAGE_DEFAULT);
TestSuite.test(result);
// Make sure we find at least the "Dark Knight" collection, ID: 263
boolean found = false;
for (Collection c : result.getResults()) {
if (c.getId() == 263) {
found = true;
break;
}
}
assertTrue("Collection not found", found);
TestSuite.testId(result, 263, "Collection");
}
/**

@ -23,6 +23,7 @@ import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.ArtworkResults;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.TestID;
import com.omertron.themoviedbapi.TestSuite;
import com.omertron.themoviedbapi.enumeration.ArtworkType;
import com.omertron.themoviedbapi.model.artwork.Artwork;
import com.omertron.themoviedbapi.model.media.MediaCreditCast;
@ -34,11 +35,9 @@ import com.omertron.themoviedbapi.model.tv.TVSeasonInfo;
import com.omertron.themoviedbapi.results.ResultList;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
@ -94,10 +93,7 @@ public class TmdbSeasonsTest extends AbstractTests {
for (TestID test : TV_IDS) {
TVSeasonInfo result = instance.getSeasonInfo(test.getTmdb(), seasonNumber, language, appendToResponse);
assertTrue("No ID", result.getId() > 0);
assertTrue("No name", StringUtils.isNotBlank(result.getName()));
assertTrue("No overview", StringUtils.isNotBlank(result.getOverview()));
assertTrue("No episodes", result.getEpisodes().size() > 0);
TestSuite.test(result);
}
}
@ -142,7 +138,9 @@ public class TmdbSeasonsTest extends AbstractTests {
for (TestID test : TV_IDS) {
MediaCreditList result = instance.getSeasonCredits(test.getTmdb(), seasonNumber);
assertNotNull(result);
assertFalse(result.getCast().isEmpty());
TestSuite.test(result.getCast());
TestSuite.test(result.getCrew());
TestSuite.test(result.getGuestStars());
boolean found = false;
for (MediaCreditCast p : result.getCast()) {
@ -152,9 +150,6 @@ public class TmdbSeasonsTest extends AbstractTests {
}
}
assertTrue(test.getOther() + " not found in cast!", found);
assertFalse(result.getCrew().isEmpty());
break;
}
}
@ -193,7 +188,7 @@ public class TmdbSeasonsTest extends AbstractTests {
for (TestID test : TV_IDS) {
ResultList<Artwork> result = instance.getSeasonImages(test.getTmdb(), seasonNumber, language, includeImageLanguage);
assertFalse("No artwork", result.isEmpty());
TestSuite.test(result);
for (Artwork artwork : result.getResults()) {
results.found(artwork.getArtworkType());
}

@ -23,6 +23,7 @@ import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.ArtworkResults;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.TestID;
import com.omertron.themoviedbapi.TestSuite;
import com.omertron.themoviedbapi.enumeration.ArtworkType;
import com.omertron.themoviedbapi.model.StatusCode;
import com.omertron.themoviedbapi.model.artwork.Artwork;
@ -45,7 +46,6 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import static org.junit.Assert.assertEquals;
@ -92,11 +92,7 @@ public class TmdbTVTest extends AbstractTests {
for (TestID test : TV_IDS) {
TVInfo result = instance.getTVInfo(test.getTmdb(), language, appendToResponse);
assertTrue("No ID", result.getId() > 0);
assertFalse("No runtime", result.getEpisodeRunTime().isEmpty());
assertFalse("No genres", result.getGenres().isEmpty());
assertTrue("No season count", result.getNumberOfSeasons() > 0);
assertTrue("No episode count", result.getNumberOfEpisodes() > 0);
TestSuite.test(result);
}
}
@ -127,7 +123,7 @@ public class TmdbTVTest extends AbstractTests {
for (TestID test : TV_IDS) {
ResultList<AlternativeTitle> result = instance.getTVAlternativeTitles(test.getTmdb());
assertFalse("No alt titles", result.isEmpty());
TestSuite.test(result);
}
}
@ -173,7 +169,7 @@ public class TmdbTVTest extends AbstractTests {
for (TestID test : TV_IDS) {
ResultList<ContentRating> result = instance.getTVContentRatings(test.getTmdb());
assertFalse("No ratings", result.isEmpty());
TestSuite.test(result);
assertTrue("No language", StringUtils.isNotBlank(result.getResults().get(0).getLanguage()));
assertTrue("No rating", StringUtils.isNotBlank(result.getResults().get(0).getRating()));
}
@ -240,7 +236,7 @@ public class TmdbTVTest extends AbstractTests {
for (TestID test : TV_IDS) {
ResultList<Artwork> result = instance.getTVImages(test.getTmdb(), language, includeImageLanguage);
assertFalse("No artwork", result.isEmpty());
TestSuite.test(result);
for (Artwork artwork : result.getResults()) {
results.found(artwork.getArtworkType());
}
@ -264,7 +260,7 @@ public class TmdbTVTest extends AbstractTests {
for (TestID test : TV_IDS) {
ResultList<Keyword> result = instance.getTVKeywords(test.getTmdb(), appendToResponse);
assertFalse("No keywords", result.isEmpty());
TestSuite.test(result);
}
}
@ -278,7 +274,7 @@ public class TmdbTVTest extends AbstractTests {
LOG.info("postTVRating");
for (TestID test : TV_IDS) {
Integer rating = new Random().nextInt(10) + 1;
int rating = TestSuite.randomRating();
StatusCode result = instance.postTVRating(test.getTmdb(), rating, getSessionId(), null);
assertEquals("failed to post rating", 12, result.getCode());
}
@ -299,7 +295,7 @@ public class TmdbTVTest extends AbstractTests {
for (TestID test : TV_IDS) {
ResultList<TVInfo> result = instance.getTVSimilar(test.getTmdb(), page, language, appendToResponse);
assertFalse("No similar TV shows", result.isEmpty());
TestSuite.test(result);
}
}
@ -314,7 +310,7 @@ public class TmdbTVTest extends AbstractTests {
for (TestID test : TV_IDS) {
ResultList<Translation> result = instance.getTVTranslations(test.getTmdb());
assertFalse("No translations", result.isEmpty());
TestSuite.test(result);
}
}
@ -347,9 +343,7 @@ public class TmdbTVTest extends AbstractTests {
LOG.info("getTVLatest");
TVInfo result = instance.getLatestTV();
assertNotNull("Null TV returned", result);
assertTrue("No ID", result.getId() > 0);
assertTrue("No title", StringUtils.isNotBlank(result.getName()));
TestSuite.test(result);
}
/**
@ -364,7 +358,7 @@ public class TmdbTVTest extends AbstractTests {
String language = LANGUAGE_DEFAULT;
ResultList<TVBasic> result = instance.getTVOnTheAir(page, language);
assertFalse("No results", result.isEmpty());
TestSuite.test(result);
}
/**
@ -380,7 +374,7 @@ public class TmdbTVTest extends AbstractTests {
String timezone = "";
ResultList<TVBasic> result = instance.getTVAiringToday(page, language, timezone);
assertFalse("No results", result.isEmpty());
TestSuite.test(result);
}
/**
@ -395,7 +389,7 @@ public class TmdbTVTest extends AbstractTests {
String language = LANGUAGE_DEFAULT;
ResultList<TVBasic> result = instance.getTVTopRated(page, language);
assertFalse("No results", result.isEmpty());
TestSuite.test(result);
}
/**
@ -410,7 +404,7 @@ public class TmdbTVTest extends AbstractTests {
String language = LANGUAGE_DEFAULT;
ResultList<TVBasic> result = instance.getTVPopular(page, language);
assertFalse("No results", result.isEmpty());
TestSuite.test(result);
}
}

Loading…
Cancel
Save