From ba64e339b1c595579fdf8adcd5d4fa77781d6615 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Tue, 17 Feb 2015 21:03:57 +0000 Subject: [PATCH] Updated methods --- .../omertron/themoviedbapi/AbstractTests.java | 106 +++++ .../methods/TmdbAccountTest.java | 185 ++++++++ .../methods/TmdbAuthenticationTest.java | 99 +++++ .../methods/TmdbCertificationsTest.java | 79 ++++ .../methods/TmdbChangesTest.java | 86 ++++ .../methods/TmdbCollectionsTest.java | 81 ++++ .../methods/TmdbCompaniesTest.java | 98 ++++ .../methods/TmdbConfigurationTest.java | 105 +++++ .../methods/TmdbCreditsTest.java | 86 ++++ .../methods/TmdbDiscoverTest.java | 102 +++++ .../themoviedbapi/methods/TmdbFindTest.java | 97 ++++ .../themoviedbapi/methods/TmdbGenresTest.java | 97 ++++ .../themoviedbapi/methods/TmdbJobsTest.java | 82 ++++ .../methods/TmdbKeywordsTest.java | 99 +++++ .../themoviedbapi/methods/TmdbListsTest.java | 170 +++++++ .../themoviedbapi/methods/TmdbMoviesTest.java | 420 ++++++++++++++++++ .../methods/TmdbNetworksTest.java | 65 +++ .../themoviedbapi/methods/TmdbPeopleTest.java | 215 +++++++++ .../methods/TmdbReviewsTest.java | 85 ++++ .../themoviedbapi/methods/TmdbSearchTest.java | 168 +++++++ .../themoviedbapi/methods/TmdbTVTest.java | 225 ++++++++++ 21 files changed, 2750 insertions(+) create mode 100644 src/test/java/com/omertron/themoviedbapi/AbstractTests.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbAccountTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbAuthenticationTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbCertificationsTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbChangesTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbCollectionsTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbCompaniesTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbConfigurationTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbCreditsTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbDiscoverTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbFindTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbGenresTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbJobsTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbKeywordsTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbListsTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbNetworksTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbPeopleTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbReviewsTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbSearchTest.java create mode 100644 src/test/java/com/omertron/themoviedbapi/methods/TmdbTVTest.java diff --git a/src/test/java/com/omertron/themoviedbapi/AbstractTests.java b/src/test/java/com/omertron/themoviedbapi/AbstractTests.java new file mode 100644 index 000000000..0b19a628f --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/AbstractTests.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi; + +import com.omertron.themoviedbapi.tools.HttpTools; +import java.io.File; +import java.util.Properties; +import org.apache.http.impl.client.HttpClient; +import org.junit.After; +import org.junit.AfterClass; +import static org.junit.Assert.fail; +import org.junit.Before; +import org.junit.BeforeClass; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.yamj.api.common.http.SimpleHttpClientBuilder; + +public class AbstractTests { + + protected static final Logger LOG = LoggerFactory.getLogger(AbstractTests.class); + private static final String PROP_FIlENAME = "testing.properties"; + private static final Properties props = new Properties(); + private static HttpClient httpClient; + private static HttpTools httpTools; + // Constants + protected static final String LANGUAGE_DEFAULT = ""; + protected static final String LANGUAGE_ENGLISH = "en"; + protected static final String LANGUAGE_RUSSIAN = "ru"; + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + httpClient = new SimpleHttpClientBuilder().build(); + httpTools = new HttpTools(httpClient); + + if (props.isEmpty()) { + File f = new File(PROP_FIlENAME); + if (f.exists()) { + LOG.info("Loading properties from '{}'", PROP_FIlENAME); + TestLogger.loadProperties(props, f); + } else { + LOG.info("Property file '{}' not found, creating dummy file.", PROP_FIlENAME); + + props.setProperty("API_Key", "INSERT_YOUR_KEY_HERE"); + props.setProperty("Username", "INSERT_YOUR_USERNAME_HERE"); + props.setProperty("Password", "INSERT_YOUR_PASSWORD_HERE"); + + TestLogger.saveProperties(props, f, "Properties file for tests"); + fail("Failed to get key information from properties file '" + PROP_FIlENAME + "'"); + } + } + } + + @AfterClass + public static void tearDownClass() throws MovieDbException { + } + + @Before + public void setUp() throws MovieDbException { + } + + @After + public void tearDown() throws MovieDbException { + } + + public static HttpClient getHttpClient() { + return httpClient; + } + + public static HttpTools getHttpTools() { + return httpTools; + } + + public static String getApiKey() { + return props.getProperty("API_Key"); + } + + public static String getUsername() { + return props.getProperty("Username"); + } + + public static String getPassword() { + return props.getProperty("Password"); + } + + public static String getProperty(String property) { + return props.getProperty(property); + } +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbAccountTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbAccountTest.java new file mode 100644 index 000000000..f393e6f6a --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbAccountTest.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import com.omertron.themoviedbapi.model.Account; +import com.omertron.themoviedbapi.model.MovieDb; +import com.omertron.themoviedbapi.model.MovieDbList; +import com.omertron.themoviedbapi.model.StatusCode; +import java.util.List; +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.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +/** + * + * @author stuart.boston + */ +public class TmdbAccountTest extends AbstractTests { + + // API + private static TmdbAccount instance; + // Constants + private static final int ID_MOVIE_FIGHT_CLUB = 550; + + public TmdbAccountTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + instance = new TmdbAccount(getApiKey(), getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + /** + * Test of getAccount method, of class TmdbAccount. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testGetAccount() throws MovieDbException { + LOG.info("getAccount"); + Account result = instance.getAccount(SESSION_ID_APITESTS); + assertEquals("Wrong account returned", ACCOUNT_ID_APITESTS, result.getId()); + } + + /** + * Test of getUserLists method, of class TmdbAccount. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testGetUserLists() throws MovieDbException { + LOG.info("getUserLists"); + List result = instance.getUserLists(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS); + assertNotNull("Null list returned", result); + } + + /** + * Test of getFavoriteMovies method, of class TmdbAccount. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testGetFavoriteMovies() throws MovieDbException { + LOG.info("getFavoriteMovies"); + + LOG.info("Check favorite list is empty"); + // make sure it's empty (because it's just a test account + List favList = instance.getFavoriteMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS); + assertTrue("Favorite list was not empty!", favList.isEmpty()); + + LOG.info("Add movie to list"); + // add a movie + StatusCode status = instance.changeFavoriteStatus(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, ID_MOVIE_FIGHT_CLUB, true); + LOG.info("Add Status: {}", status); + + LOG.info("Get favorite list"); + favList = instance.getFavoriteMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS); + assertNotNull("Empty favorite list returned", favList); + assertFalse("Favorite list empty", favList.isEmpty()); + + // clean up again + LOG.info("Remove movie(s) from list"); + for (MovieDb movie : favList) { + LOG.info("Removing movie {}-'{}'", movie.getId(), movie.getTitle()); + status = instance.changeFavoriteStatus(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, movie.getId(), false); + LOG.info("Remove status: {}", status); + } + assertTrue("Favorite list was not empty", instance.getFavoriteMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty()); + } + + /** + * Test of changeFavoriteStatus method, of class TmdbAccount. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Ignore("Tested as part of getFavoriteMovies") + public void testChangeFavoriteStatus() throws MovieDbException { + } + + /** + * Test of getRatedMovies method, of class TmdbAccount. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testGetRatedMovies() throws MovieDbException { + LOG.info("getRatedMovies"); + List result = instance.getRatedMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS); + assertFalse("No rated movies", result.isEmpty()); + } + + /** + * Test of getWatchList method, of class TmdbAccount. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testGetWatchList() throws MovieDbException { + LOG.info("getWatchList"); + + LOG.info("Check list is empty"); + // make sure it's empty (because it's just a test account + List watchList = instance.getWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS); + assertTrue("Watch list was not empty!", watchList.isEmpty()); + + LOG.info("Add movie to list"); + // add a movie + StatusCode status = instance.modifyWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, ID_MOVIE_FIGHT_CLUB, true); + LOG.info("Add Status: {}", status); + + LOG.info("Get watch list"); + watchList = instance.getWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS); + assertNotNull("Empty watch list returned", watchList); + assertFalse("Watchlist list empty", watchList.isEmpty()); + + LOG.info("Removing movie(s) from list"); + // clean up again + for (MovieDb movie : watchList) { + LOG.info("Removing movie {}-'{}'", movie.getId(), movie.getTitle()); + status = instance.modifyWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, movie.getId(), false); + LOG.info("Remove status: {}", status); + } + + assertTrue(instance.getWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty()); + } + + /** + * Test of modifyWatchList method, of class TmdbAccount. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Ignore("Tested as part of testGetWatchList") + public void testModifyWatchList() throws MovieDbException { + } +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbAuthenticationTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbAuthenticationTest.java new file mode 100644 index 000000000..69bf8e20c --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbAuthenticationTest.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import com.omertron.themoviedbapi.model.TokenAuthorisation; +import com.omertron.themoviedbapi.model.TokenSession; +import org.junit.AfterClass; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +/** + * + * @author stuart.boston + */ +public class TmdbAuthenticationTest extends AbstractTests{ + + // API + private static TmdbAuthentication instance; + + public TmdbAuthenticationTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + instance = new TmdbAuthentication(getApiKey(),getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + /** + * Test of getAuthorisationToken method, of class TmdbAuthentication. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testGetAuthorisationToken() throws MovieDbException { + LOG.info("getAuthorisationToken"); + TokenAuthorisation token = instance.getAuthorisationToken(); + assertFalse("Token is null", token == null); + assertTrue("Token is not valid", token.getSuccess()); + } + + /** + * Test of getSessionToken method, of class TmdbAuthentication. + * + * TODO: Cannot be tested without a HTTP authorisation:
+ * http://help.themoviedb.org/kb/api/user-authentication + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Ignore("Session needs to be authorised") + public void testGetSessionToken() throws MovieDbException { + LOG.info("getSessionToken"); + TokenAuthorisation token = instance.getAuthorisationToken(); + // Need to authorise the token here. + TokenSession result = instance.getSessionToken(token); + assertFalse("Session token is null", result == null); + assertTrue("Session token is not valid", result.getSuccess()); + } + + /** + * Test of getGuestSessionToken method, of class TmdbAuthentication. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testGetGuestSessionToken() throws MovieDbException { + LOG.info("getGuestSessionToken"); + TokenSession result = instance.getGuestSessionToken(); + assertTrue("Failed to get guest session", result.getSuccess()); + } + +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCertificationsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCertificationsTest.java new file mode 100644 index 000000000..20bbf8625 --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCertificationsTest.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import com.omertron.themoviedbapi.model.Certification; +import com.omertron.themoviedbapi.results.TmdbResultsMap; +import java.util.List; +import org.junit.AfterClass; +import static org.junit.Assert.assertFalse; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * + * @author stuart.boston + * @author Luca Tagliani + */ +public class TmdbCertificationsTest extends AbstractTests { + + // API + private static TmdbCertifications instance; + + public TmdbCertificationsTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + instance = new TmdbCertifications(getApiKey(), getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + /** + * Test of getMoviesCertification method, of class TmdbCertifications. + * + * @throws MovieDbException + */ + @Test + public void testGetMovieCertifications() throws MovieDbException { + LOG.info("getMovieCertifications"); + TmdbResultsMap> result = instance.getMoviesCertification(); + assertFalse("No movie certifications.", result.getResults().isEmpty()); + } + + /** + * Test of getTvCertification method, of class TmdbCertifications. + * + * @throws MovieDbException + */ + @Test + public void testGetTvCertifications() throws MovieDbException { + LOG.info("getTvCertifications"); + TmdbResultsMap> result = instance.getTvCertification(); + assertFalse("No tv certifications.", result.getResults().isEmpty()); + } +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbChangesTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbChangesTest.java new file mode 100644 index 000000000..fd84ba761 --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbChangesTest.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import com.omertron.themoviedbapi.model.ChangedMovie; +import com.omertron.themoviedbapi.results.TmdbResultsList; +import org.junit.AfterClass; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +/** + * + * @author stuart.boston + */ +public class TmdbChangesTest extends AbstractTests { + + // API + private static TmdbChanges instance; + + public TmdbChangesTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + instance = new TmdbChanges(getApiKey(), getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + /** + * Test of getMovieChangesList method, of class TmdbChanges. + * + * @throws MovieDbException + */ + @Test + public void testGetMovieChangesList() throws MovieDbException { + LOG.info("getMovieChangesList"); + int page = 0; + String startDate = ""; + String endDate = ""; + TmdbResultsList result = instance.getMovieChangesList(page, startDate, endDate); + assertFalse("No movie changes.", result.getResults().isEmpty()); + } + + /** + * Test of getPersonMovieOldChangesList method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Ignore("Not ready yet") + public void testGetPersonChangesList() throws MovieDbException { + LOG.info("getPersonChangesList"); + int page = 0; + String startDate = ""; + String endDate = ""; + instance.getPersonChangesList(page, startDate, endDate); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCollectionsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCollectionsTest.java new file mode 100644 index 000000000..50649b3ea --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCollectionsTest.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import com.omertron.themoviedbapi.model.Artwork; +import com.omertron.themoviedbapi.model.CollectionInfo; +import com.omertron.themoviedbapi.results.TmdbResultsList; +import org.junit.AfterClass; +import static org.junit.Assert.assertFalse; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * + * @author stuart.boston + */ +public class TmdbCollectionsTest extends AbstractTests { + + // API + private static TmdbCollections instance; + private static final int ID_COLLECTION_STAR_WARS = 10; + + public TmdbCollectionsTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + instance = new TmdbCollections(getApiKey(), getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + /** + * Test of getCollectionInfo method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetCollectionInfo() throws MovieDbException { + LOG.info("getCollectionInfo"); + String language = ""; + CollectionInfo result = instance.getCollectionInfo(ID_COLLECTION_STAR_WARS, language); + assertFalse("No collection information", result.getParts().isEmpty()); + } + + /** + * Test of getCollectionImages method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetCollectionImages() throws MovieDbException { + LOG.info("getCollectionImages"); + TmdbResultsList result = instance.getCollectionImages(ID_COLLECTION_STAR_WARS, LANGUAGE_DEFAULT); + assertFalse("No artwork found", result.getResults().isEmpty()); + } + +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCompaniesTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCompaniesTest.java new file mode 100644 index 000000000..50344ba87 --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCompaniesTest.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import static com.omertron.themoviedbapi.TheMovieDbApiTest.getApiKey(); +import static com.omertron.themoviedbapi.TheMovieDbApiTest.LANGUAGE_DEFAULT; +import com.omertron.themoviedbapi.model.Company; +import com.omertron.themoviedbapi.model.movie.MovieDb; +import com.omertron.themoviedbapi.results.TmdbResultsList; +import org.junit.After; +import org.junit.AfterClass; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.yamj.api.common.http.DefaultPoolingHttpClient; + +/** + * + * @author stuart.boston + */ +public class TmdbCompaniesTest extends AbstractTests{ + + // Logger + private static final Logger LOG = LoggerFactory.getLogger(TmdbCompaniesTest.class); + // API + private static TmdbCompanies instance; + private static final int ID_COMPANY = 2; + + public TmdbCompaniesTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + instance = new TmdbCompanies(getApiKey(),getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getCompanyInfo method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetCompanyInfo() throws MovieDbException { + LOG.info("getCompanyInfo"); + Company company = instance.getCompanyInfo(ID_COMPANY); + assertTrue("No company information found", company.getCompanyId() > 0); + assertNotNull("No parent company found", company.getParentCompany()); + } + + /** + * Test of getCompanyMovies method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetCompanyMovies() throws MovieDbException { + LOG.info("getCompanyMovies"); + TmdbResultsList result = instance.getCompanyMovies(ID_COMPANY, LANGUAGE_DEFAULT, 0); + assertTrue("No company movies found", !result.getResults().isEmpty()); + } +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbConfigurationTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbConfigurationTest.java new file mode 100644 index 000000000..73b80c431 --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbConfigurationTest.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import static com.omertron.themoviedbapi.TheMovieDbApiTest.getApiKey(); +import com.omertron.themoviedbapi.model.Configuration; +import com.omertron.themoviedbapi.model.type.ArtworkType; +import org.apache.commons.lang3.StringUtils; +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; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.yamj.api.common.http.DefaultPoolingHttpClient; + +/** + * + * @author stuart.boston + */ +public class TmdbConfigurationTest extends AbstractTests { + + // Logger + private static final Logger LOG = LoggerFactory.getLogger(TmdbConfigurationTest.class); + + // API + private static TmdbConfiguration instance; + + public TmdbConfigurationTest() { + } + + @BeforeClass + public static void setUpClass() { + TestLogger.Configure(); + instance = new TmdbConfiguration(getApiKey(),getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getConfig method, of class TmdbConfiguration. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testGetConfig() throws MovieDbException { + LOG.info("getConfig"); + Configuration result = instance.getConfig(); + LOG.info(result.toString()); + assertFalse("No backdrop sizes", result.getBackdropSizes().isEmpty()); + assertFalse("No logo sizes", result.getLogoSizes().isEmpty()); + assertFalse("No poster sizes", result.getPosterSizes().isEmpty()); + assertFalse("No profile sizes", result.getProfileSizes().isEmpty()); + assertTrue("No base url", StringUtils.isNotBlank(result.getBaseUrl())); + assertTrue("No secure base url", StringUtils.isNotBlank(result.getSecureBaseUrl())); + } + + /** + * Test of createImageUrl method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testCreateImageUrl() throws MovieDbException { + LOG.info("createImageUrl"); + Configuration config = instance.getConfig(); + + String result = config.createImageUrl("http://mediaplayersite.com/image.jpg", ArtworkType.POSTER, "original").toString(); + assertTrue("Error compiling image URL", !result.isEmpty()); + } + +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCreditsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCreditsTest.java new file mode 100644 index 000000000..e2186a91c --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCreditsTest.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import static com.omertron.themoviedbapi.TheMovieDbApiTest.getApiKey(); +import com.omertron.themoviedbapi.model.person.PersonCredits; +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; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.yamj.api.common.http.DefaultPoolingHttpClient; + +/** + * + * @author stuart.boston + */ +public class TmdbCreditsTest extends AbstractTests{ + + // Logger + private static final Logger LOG = LoggerFactory.getLogger(TmdbCreditsTest.class); + // API + private static TmdbCredits instance; + + public TmdbCreditsTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + instance = new TmdbCredits(getApiKey(),getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getCreditInfo method, of class TmdbCredits. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testGetCreditInfo() throws MovieDbException { + LOG.info("getCreditInfo"); + String creditId = "525346f619c29579400d4145"; + String language = ""; + PersonCredits result = instance.getCreditInfo(creditId, language); + assertEquals("Wrong name", "Sean Bean", result.getPerson().getName()); + assertEquals("Wrong job", "Actor", result.getJob()); + assertFalse("No seasons", result.getMedia().getSeasons().isEmpty()); + } + +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbDiscoverTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbDiscoverTest.java new file mode 100644 index 000000000..ee2e55e17 --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbDiscoverTest.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import static com.omertron.themoviedbapi.TheMovieDbApiTest.getApiKey(); +import static com.omertron.themoviedbapi.TheMovieDbApiTest.LANGUAGE_ENGLISH; +import com.omertron.themoviedbapi.model.discover.Discover; +import com.omertron.themoviedbapi.model.movie.MovieDb; +import com.omertron.themoviedbapi.results.TmdbResultsList; +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; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.yamj.api.common.http.DefaultPoolingHttpClient; + +/** + * + * @author stuart.boston + */ +public class TmdbDiscoverTest extends AbstractTests { + + // Logger + private static final Logger LOG = LoggerFactory.getLogger(TmdbDiscoverTest.class); + // API + private static TmdbDiscover instance; + + public TmdbDiscoverTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + instance = new TmdbDiscover(getApiKey(),getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getDiscoverMovie method, of class TmdbDiscover. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testGetDiscoverMovie() throws MovieDbException { + LOG.info("getDiscoverMovie"); + Discover discover = new Discover(); + discover.year(2013).language(LANGUAGE_ENGLISH); + + TmdbResultsList result = instance.getDiscoverMovie(discover); + assertFalse("No movies discovered", result.getResults().isEmpty()); + } + + /** + * Test of getDiscoverTv method, of class TmdbDiscover. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testGetDiscoverTv() throws MovieDbException { + LOG.info("getDiscoverTv"); + Discover discover = new Discover(); + discover.year(2013).language(LANGUAGE_ENGLISH); + + TmdbResultsList result = instance.getDiscoverMovie(discover); + assertFalse("No TV shows discovered", result.getResults().isEmpty()); + } + +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbFindTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbFindTest.java new file mode 100644 index 000000000..048d03dbe --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbFindTest.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import static com.omertron.themoviedbapi.TheMovieDbApiTest.getApiKey(); +import com.omertron.themoviedbapi.model.FindResults; +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; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.yamj.api.common.http.DefaultPoolingHttpClient; + +/** + * + * @author stuart.boston + * @author Luca Tagliani + */ +public class TmdbFindTest extends AbstractTests { + + // Logger + private static final Logger LOG = LoggerFactory.getLogger(TmdbFindTest.class); + // API + private static TmdbFind instance; + + public TmdbFindTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + instance = new TmdbFind(getApiKey(),getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getMovieChangesList method, of class TmdbFindTest. + * + * @throws MovieDbException + */ + @Test + public void testFindMoviesImdbID() throws MovieDbException { + LOG.info("findMoviesImdbID"); + FindResults result = instance.find("tt0196229", TmdbFind.ExternalSource.imdb_id, "it"); + assertFalse("No movie for id.", result.getMovieResults().isEmpty()); + } + + @Test + public void testFindTvSeriesImdbID() throws MovieDbException { + LOG.info("findTvSeriesImdbID"); + FindResults result = instance.find("tt1219024", TmdbFind.ExternalSource.imdb_id, "it"); + assertFalse("No tv for id.", result.getTvResults().isEmpty()); + } + + @Test + public void testFindPersonImdbID() throws MovieDbException { + LOG.info("findPersonImdbID"); + FindResults result = instance.find("nm0001774", TmdbFind.ExternalSource.imdb_id, "it"); + assertFalse("No person for id.", result.getPersonResults().isEmpty()); + } + + +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbGenresTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbGenresTest.java new file mode 100644 index 000000000..74cbcc547 --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbGenresTest.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import static com.omertron.themoviedbapi.TheMovieDbApiTest.getApiKey(); +import static com.omertron.themoviedbapi.TheMovieDbApiTest.LANGUAGE_DEFAULT; +import com.omertron.themoviedbapi.model.Genre; +import com.omertron.themoviedbapi.model.movie.MovieDb; +import com.omertron.themoviedbapi.results.TmdbResultsList; +import org.junit.After; +import org.junit.AfterClass; +import static org.junit.Assert.assertTrue; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.yamj.api.common.http.DefaultPoolingHttpClient; + +/** + * + * @author stuart.boston + */ +public class TmdbGenresTest extends AbstractTests { + + // Logger + private static final Logger LOG = LoggerFactory.getLogger(TmdbGenresTest.class); + // API + private static TmdbGenres instance; + private static final int ID_GENRE_ACTION = 28; + + public TmdbGenresTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + instance = new TmdbGenres(getApiKey(),getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getGenreList method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetGenreList() throws MovieDbException { + LOG.info("getGenreList"); + TmdbResultsList result = instance.getGenreList(LANGUAGE_DEFAULT); + assertTrue("No genres found", !result.getResults().isEmpty()); + } + + /** + * Test of getGenreMovies method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetGenreMovies() throws MovieDbException { + LOG.info("getGenreMovies"); + TmdbResultsList result = instance.getGenreMovies(ID_GENRE_ACTION, LANGUAGE_DEFAULT, 0, Boolean.TRUE); + assertTrue("No genre movies found", !result.getResults().isEmpty()); + } + +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbJobsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbJobsTest.java new file mode 100644 index 000000000..7d23343ef --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbJobsTest.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import static com.omertron.themoviedbapi.TheMovieDbApiTest.getApiKey(); +import com.omertron.themoviedbapi.model.JobDepartment; +import com.omertron.themoviedbapi.results.TmdbResultsList; +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; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.yamj.api.common.http.DefaultPoolingHttpClient; + +/** + * + * @author stuart.boston + */ +public class TmdbJobsTest extends AbstractTests { + + // Logger + private static final Logger LOG = LoggerFactory.getLogger(TmdbGenresTest.class); + // API + private static TmdbJobs tmdb; + + public TmdbJobsTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + tmdb = new TmdbJobs(getApiKey(),getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getJobs method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetJobs() throws MovieDbException { + LOG.info("getJobs"); + TmdbResultsList result = tmdb.getJobs(); + assertFalse("No jobs found", result.getResults().isEmpty()); + } + +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbKeywordsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbKeywordsTest.java new file mode 100644 index 000000000..3e758109c --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbKeywordsTest.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import static com.omertron.themoviedbapi.TheMovieDbApiTest.getApiKey(); +import static com.omertron.themoviedbapi.TheMovieDbApiTest.LANGUAGE_DEFAULT; +import com.omertron.themoviedbapi.model.Keyword; +import com.omertron.themoviedbapi.model.movie.MovieDbBasic; +import com.omertron.themoviedbapi.results.TmdbResultsList; +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; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.yamj.api.common.http.DefaultPoolingHttpClient; + +/** + * + * @author stuart.boston + */ +public class TmdbKeywordsTest extends AbstractTests{ + + // Logger + private static final Logger LOG = LoggerFactory.getLogger(TmdbGenresTest.class); + // API + private static TmdbKeywords tmdb; + private static final String ID_KEYWORD = "1721"; + + public TmdbKeywordsTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + tmdb = new TmdbKeywords(getApiKey(),getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getKeyword method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetKeyword() throws MovieDbException { + LOG.info("getKeyword"); + Keyword result = tmdb.getKeyword(ID_KEYWORD); + assertEquals("fight", result.getName()); + } + + /** + * Test of getMovieDbBasics method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetKeywordMovies() throws MovieDbException { + LOG.info("getKeywordMovies"); + int page = 0; + TmdbResultsList result = tmdb.getKeywordMovies(ID_KEYWORD, LANGUAGE_DEFAULT, page); + assertFalse("No keyword movies found", result.getResults().isEmpty()); + } + +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbListsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbListsTest.java new file mode 100644 index 000000000..a31c28b49 --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbListsTest.java @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import static com.omertron.themoviedbapi.TheMovieDbApiTest.getApiKey(); +import static com.omertron.themoviedbapi.TheMovieDbApiTest.SESSION_ID_APITESTS; +import com.omertron.themoviedbapi.model.StatusCode; +import com.omertron.themoviedbapi.model.StatusCodeList; +import com.omertron.themoviedbapi.model.movie.MovieDbList; +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.fail; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runners.MethodSorters; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.yamj.api.common.http.DefaultPoolingHttpClient; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TmdbListsTest extends AbstractTests{ + + // Logger + private static final Logger LOG = LoggerFactory.getLogger(TmdbGenresTest.class); + // API + private static TmdbLists instance; + + public TmdbListsTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + instance = new TmdbLists(getApiKey(),getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of createList method, of class TmdbList. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Ignore("Not working") + public void test1CreateList() throws MovieDbException { + LOG.info("createList"); + String name = "My Totally Awesome List"; + String description = "This list was created to share all of the totally awesome movies I've seen."; + StatusCodeList result = instance.createList(SESSION_ID_APITESTS, name, description); + LOG.info(result.toString()); + // TODO review the generated test code and remove the default call to fail. +// fail("The test case is a prototype."); + } + + /** + * Test of getList method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void test2GetList() throws MovieDbException { + LOG.info("getList"); + String listId = "509ec17b19c2950a0600050d"; + MovieDbList result = instance.getList(listId); + assertFalse("List not found", result.getItems().isEmpty()); + } + + /** + * Test of addMovieToList method, of class TmdbList. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Ignore("Not working") + public void test3AddMovieToList() throws MovieDbException { + LOG.info("addMovieToList"); + String listId = ""; + Integer movieId = null; + StatusCode expResult = null; + StatusCode result = instance.addMovieToList(SESSION_ID_APITESTS, listId, movieId); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of isMovieOnList method, of class TmdbList. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Ignore("Not working") + public void test4IsMovieOnList() throws MovieDbException { + LOG.info("isMovieOnList"); + String listId = ""; + Integer movieId = null; + boolean expResult = false; + boolean result = instance.isMovieOnList(listId, movieId); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of removeMovieFromList method, of class TmdbList. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Ignore("Not working") + public void test5RemoveMovieFromList() throws MovieDbException { + LOG.info("removeMovieFromList"); + String listId = ""; + Integer movieId = null; + StatusCode expResult = null; + StatusCode result = instance.removeMovieFromList(SESSION_ID_APITESTS, listId, movieId); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of deleteMovieList method, of class TmdbList. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Ignore("Not working") + public void test6DeleteMovieList() throws MovieDbException { + LOG.info("deleteMovieList"); + String listId = ""; + StatusCode expResult = null; + StatusCode result = instance.deleteMovieList(SESSION_ID_APITESTS, listId); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java new file mode 100644 index 000000000..c6add35c5 --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java @@ -0,0 +1,420 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import static com.omertron.themoviedbapi.TheMovieDbApiTest.ACCOUNT_ID_APITESTS; +import static com.omertron.themoviedbapi.TheMovieDbApiTest.getApiKey(); +import static com.omertron.themoviedbapi.TheMovieDbApiTest.LANGUAGE_DEFAULT; +import static com.omertron.themoviedbapi.TheMovieDbApiTest.LANGUAGE_ENGLISH; +import static com.omertron.themoviedbapi.TheMovieDbApiTest.SESSION_ID_APITESTS; +import com.omertron.themoviedbapi.model.AlternativeTitle; +import com.omertron.themoviedbapi.model.Artwork; +import com.omertron.themoviedbapi.model.ChangedItem; +import com.omertron.themoviedbapi.model.Keyword; +import com.omertron.themoviedbapi.model.ReleaseInfo; +import com.omertron.themoviedbapi.model.Review; +import com.omertron.themoviedbapi.model.Trailer; +import com.omertron.themoviedbapi.model.Translation; +import com.omertron.themoviedbapi.model.movie.MovieDb; +import com.omertron.themoviedbapi.model.movie.MovieList; +import com.omertron.themoviedbapi.model.movie.MovieState; +import com.omertron.themoviedbapi.model.person.PersonMovieOld; +import com.omertron.themoviedbapi.results.TmdbResultsList; +import com.omertron.themoviedbapi.results.TmdbResultsMap; +import java.util.List; +import java.util.Random; +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.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +/** + * + * @author stuart.boston + */ +public class TmdbMoviesTest extends AbstractTests{ + + // API + private static TmdbMovies instance; + private static final int ID_MOVIE_BLADE_RUNNER = 78; + private static final int ID_MOVIE_THE_AVENGERS = 24428; + + public TmdbMoviesTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + instance = new TmdbMovies(getApiKey(),getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + /** + * Test of getMovieInfo method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetMovieInfo() throws MovieDbException { + LOG.info("getMovieInfo"); + MovieDb result = instance.getMovieInfo(ID_MOVIE_BLADE_RUNNER, LANGUAGE_ENGLISH, "alternative_titles,casts,images,keywords,releases,trailers,translations,similar_movies,reviews,lists"); + assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle()); + } + + /** + * Test of getMovieInfoImdb method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetMovieInfoImdb() throws MovieDbException { + LOG.info("getMovieInfoImdb"); + MovieDb result = instance.getMovieInfoImdb("tt0076759", "en-US"); + assertTrue("Error getting the movie from IMDB ID", result.getId() == 11); + } + + /** + * Test of getMovieAlternativeTitles method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetMovieAlternativeTitles() throws MovieDbException { + LOG.info("getMovieAlternativeTitles"); + String country = ""; + TmdbResultsList result = instance.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country, "casts,images,keywords,releases,trailers,translations,similar_movies,reviews,lists"); + assertTrue("No alternative titles found", result.getResults().size() > 0); + + country = "US"; + result = instance.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country); + assertTrue("No alternative titles found", result.getResults().size() > 0); + + } + + /** + * Test of getMovieCredits method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetMovieCasts() throws MovieDbException { + LOG.info("getMovieCasts"); + TmdbResultsList people = instance.getMovieCredits(ID_MOVIE_BLADE_RUNNER, "alternative_titles,casts,images,keywords,releases,trailers,translations,similar_movies,reviews,lists"); + assertTrue("No cast information", people.getResults().size() > 0); + + String name1 = "Harrison Ford"; + String name2 = "Charles Knode"; + boolean foundName1 = Boolean.FALSE; + boolean foundName2 = Boolean.FALSE; + + for (PersonMovieOld person : people.getResults()) { + if (!foundName1 && person.getName().equalsIgnoreCase(name1)) { + foundName1 = Boolean.TRUE; + } + + if (!foundName2 && person.getName().equalsIgnoreCase(name2)) { + foundName2 = Boolean.TRUE; + } + } + assertTrue("Couldn't find " + name1, foundName1); + assertTrue("Couldn't find " + name2, foundName2); + } + + /** + * Test of getMovieImages method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetMovieImages() throws MovieDbException { + LOG.info("getMovieImages"); + String language = ""; + TmdbResultsList result = instance.getMovieImages(ID_MOVIE_BLADE_RUNNER, language); + assertFalse("No artwork found", result.getResults().isEmpty()); + } + + /** + * Test of getMovieKeywords method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetMovieKeywords() throws MovieDbException { + LOG.info("getMovieKeywords"); + TmdbResultsList result = instance.getMovieKeywords(ID_MOVIE_BLADE_RUNNER); + assertFalse("No keywords found", result.getResults().isEmpty()); + } + + /** + * Test of getMovieReleaseInfo method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetMovieReleaseInfo() throws MovieDbException { + LOG.info("getMovieReleaseInfo"); + TmdbResultsList result = instance.getMovieReleaseInfo(ID_MOVIE_BLADE_RUNNER, ""); + assertFalse("Release information missing", result.getResults().isEmpty()); + } + + /** + * Test of getMovieTrailers method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetMovieTrailers() throws MovieDbException { + LOG.info("getMovieTrailers"); + TmdbResultsList result = instance.getMovieTrailers(ID_MOVIE_BLADE_RUNNER, ""); + assertFalse("Movie trailers missing", result.getResults().isEmpty()); + } + + /** + * Test of getMovieTranslations method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetMovieTranslations() throws MovieDbException { + LOG.info("getMovieTranslations"); + TmdbResultsList result = instance.getMovieTranslations(ID_MOVIE_BLADE_RUNNER); + assertFalse("No translations found", result.getResults().isEmpty()); + } + + /** + * Test of getSimilarMovies method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetSimilarMovies() throws MovieDbException { + LOG.info("getSimilarMovies"); + TmdbResultsList result = instance.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, LANGUAGE_DEFAULT, 0); + assertTrue("No similar movies found", !result.getResults().isEmpty()); + } + + /** + * Test of getReview method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetReviews() throws MovieDbException { + LOG.info("getReviews"); + int page = 0; + TmdbResultsList result = instance.getReviews(ID_MOVIE_THE_AVENGERS, LANGUAGE_DEFAULT, page); + assertFalse("No reviews found", result.getResults().isEmpty()); + } + + /** + * Test of getMovieLists method, of class TmdbMovie. + * + * @throws MovieDbException + */ + @Test + public void testGetMovieLists() throws MovieDbException { + LOG.info("getMovieLists"); + TmdbResultsList result = instance.getMovieLists(ID_MOVIE_BLADE_RUNNER, LANGUAGE_ENGLISH, 0); + assertNotNull("No results found", result); + assertTrue("No results found", result.getResults().size() > 0); + } + + /** + * Test of getMovieChanges method,of class TheMovieDbApi + * + * @throws MovieDbException + */ + @Ignore("Do not test this until it is fixed") + public void testGetMovieChanges() throws MovieDbException { + LOG.info("getMovieChanges"); + + String startDate = ""; + String endDate = null; + + // Get some popular movies + TmdbResultsList movieList = instance.getPopularMovieList(LANGUAGE_DEFAULT, 0); + for (MovieDb movie : movieList.getResults()) { + TmdbResultsMap> result = instance.getMovieChanges(movie.getId(), startDate, endDate); + LOG.info("{} has {} changes.", movie.getTitle(), result.getResults().size()); + assertTrue("No changes found", result.getResults().size() > 0); + break; + } + } + + /** + * Test of getLatestMovie method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetLatestMovie() throws MovieDbException { + LOG.info("getLatestMovie"); + MovieDb result = instance.getLatestMovie(); + assertTrue("No latest movie found", result != null); + assertTrue("No latest movie found", result.getId() > 0); + } + + /** + * Test of getUpcoming method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetUpcoming() throws MovieDbException { + LOG.info("getUpcoming"); + TmdbResultsList result = instance.getUpcoming(LANGUAGE_DEFAULT, 0); + assertTrue("No upcoming movies found", !result.getResults().isEmpty()); + } + + /** + * Test of getNowPlayingMovies method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetNowPlayingMovies() throws MovieDbException { + LOG.info("getNowPlayingMovies"); + TmdbResultsList result = instance.getNowPlayingMovies(LANGUAGE_DEFAULT, 0); + assertTrue("No now playing movies found", !result.getResults().isEmpty()); + } + + /** + * Test of getPopularMovieList method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetPopularMovieList() throws MovieDbException { + LOG.info("getPopularMovieList"); + TmdbResultsList result = instance.getPopularMovieList(LANGUAGE_DEFAULT, 0); + assertTrue("No popular movies found", !result.getResults().isEmpty()); + } + + /** + * Test of getTopRatedMovies method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetTopRatedMovies() throws MovieDbException { + LOG.info("getTopRatedMovies"); + TmdbResultsList result = instance.getTopRatedMovies(LANGUAGE_DEFAULT, 0); + assertTrue("No top rated movies found", !result.getResults().isEmpty()); + } + + /** + * Test of postMovieRating method, of class TheMovieDbApi. + * + * TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication /** + * + * @throws MovieDbException + */ + @Test + public void testMovieRating() throws MovieDbException { + LOG.info("postMovieRating"); + Integer movieID = 68724; + Integer rating = new Random().nextInt(10) + 1; + + boolean wasPosted = instance.postMovieRating(SESSION_ID_APITESTS, movieID, rating); + assertTrue("Failed to post rating", wasPosted); + + try { + // Make sure that we pause long enough for the record to by updated + Thread.sleep(5000); + } catch (InterruptedException ex) { + // Ignore the exception and move on + } + + // get all rated movies + TmdbAccount account = new TmdbAccount(getApiKey(),getHttpTools()); + List ratedMovies = account.getRatedMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS); + assertTrue(ratedMovies.size() > 0); + + // make sure that we find the movie and it is rated correctly + boolean foundMovie = false; + for (MovieDb movie : ratedMovies) { + if (movie.getId() == movieID) { + assertEquals("Incorrect rating", movie.getUserRating(), (float) rating, 0); + foundMovie = true; + break; + } + } + assertTrue("Movie not found!", foundMovie); + } + + /** + * Test of getMovieCredits method, of class TmdbMovies. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testGetMovieCredits() throws MovieDbException { + LOG.info("getMovieCredits"); + TmdbResultsList result = instance.getMovieCredits(ID_MOVIE_BLADE_RUNNER, ""); + assertFalse("No credits returned", result.getResults().isEmpty()); + } + + /** + * Test of getMovieStatus method, of class TmdbMovies. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testGetMovieStatus() throws MovieDbException { + LOG.info("getMovieStatus"); + // This movie should be rated + MovieState result = instance.getMovieStatus(SESSION_ID_APITESTS, ID_MOVIE_BLADE_RUNNER); + assertNotNull("No state returned", result); + assertFalse("Movie is favourited", result.isFavorite()); + assertFalse("Movie is not rated", result.getRating() < 0); + assertFalse("Movie is watch listed", result.isWatchlist()); + + // This movie should not be rated + result = instance.getMovieStatus(SESSION_ID_APITESTS, ID_MOVIE_THE_AVENGERS); + assertNotNull("No state returned", result); + assertFalse("Movie is favourited", result.isFavorite()); + assertFalse("Movie is rated", result.getRating() > -1); + assertFalse("Movie is watch listed", result.isWatchlist()); + } + + /** + * Test of postMovieRating method, of class TmdbMovies. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testPostMovieRating() throws MovieDbException { + LOG.info("postMovieRating"); + Integer rating = 10; + boolean result = instance.postMovieRating(SESSION_ID_APITESTS, ID_MOVIE_BLADE_RUNNER, rating); + assertEquals("Failed to set rating", true, result); + } + +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbNetworksTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbNetworksTest.java new file mode 100644 index 000000000..54b9c51d0 --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbNetworksTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import com.omertron.themoviedbapi.model.tv.Network; +import org.junit.AfterClass; +import static org.junit.Assert.assertEquals; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * + * @author stuart.boston + */ +public class TmdbNetworksTest extends AbstractTests { + + // API + private static TmdbNetworks instance; + + public TmdbNetworksTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + instance = new TmdbNetworks(getApiKey(), getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + /** + * Test of getNetworkInfo method, of class TmdbNetworks. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testGetNetworkInfo() throws MovieDbException { + LOG.info("getNetworkInfo"); + Network result = instance.getNetworkInfo(1); + assertEquals("Wrong network returned", "Fuji Television", result.getName()); + } + +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbPeopleTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbPeopleTest.java new file mode 100644 index 000000000..29320677e --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbPeopleTest.java @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import static com.omertron.themoviedbapi.TheMovieDbApiTest.getApiKey(); +import static com.omertron.themoviedbapi.TheMovieDbApiTest.LANGUAGE_DEFAULT; +import com.omertron.themoviedbapi.model.Artwork; +import com.omertron.themoviedbapi.model.person.NewCast; +import com.omertron.themoviedbapi.model.person.NewPersonCredits; +import com.omertron.themoviedbapi.model.person.Person; +import com.omertron.themoviedbapi.model.person.PersonBasic; +import com.omertron.themoviedbapi.results.TmdbResultsList; +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; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.yamj.api.common.http.DefaultPoolingHttpClient; + +/** + * + * @author stuart.boston + */ +public class TmdbPeopleTest extends AbstractTests{ + + // Logger + private static final Logger LOG = LoggerFactory.getLogger(TmdbGenresTest.class); + // API + private static TmdbPeople instance; + private static final int ID_BRUCE_WILLIS = 62; + private static final int ID_SEAN_BEAN = 48; + private static final int ID_DICK_WOLF = 117443; + + public TmdbPeopleTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + instance = new TmdbPeople(getApiKey(),getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getPersonMovieOldInfo method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ +// @Test + public void testGetPersonInfo() throws MovieDbException { + LOG.info("getPersonInfo"); + Person result = instance.getPersonInfo(ID_BRUCE_WILLIS); + assertTrue("Wrong actor returned", result.getId() == ID_BRUCE_WILLIS); + assertTrue("Missing bio", StringUtils.isNotBlank(result.getBiography())); + assertTrue("Missing birthday", StringUtils.isNotBlank(result.getBirthday())); + assertTrue("Missing homepage", StringUtils.isNotBlank(result.getHomepage())); + assertTrue("Missing IMDB", StringUtils.isNotBlank(result.getImdbId())); + assertTrue("Missing name", StringUtils.isNotBlank(result.getName())); + assertTrue("Missing birth place", StringUtils.isNotBlank(result.getBirthplace())); + assertTrue("Missing artwork", StringUtils.isNotBlank(result.getProfilePath())); + assertTrue("Missing bio", result.getPopularity() > 0F); + } + + /** + * Test of getPersonMovieOldImages method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ +// @Test + public void testGetPersonImages() throws MovieDbException { + LOG.info("getPersonImages"); + + TmdbResultsList result = instance.getPersonImages(ID_BRUCE_WILLIS); + assertTrue("No cast information", result.getResults().size() > 0); + for (Artwork artwork : result.getResults()) { + assertTrue("Artwork is blank", StringUtils.isNotBlank(artwork.getFilePath())); + } + + } + + /** + * Test of getPersonChanges method, of class TmdbPeople. + * + * @throws MovieDbException + */ + @Ignore("Not ready yet") + public void testGetPersonChanges() throws MovieDbException { + LOG.info("getPersonChanges"); + String startDate = ""; + String endDate = ""; + instance.getPersonChanges(ID_BRUCE_WILLIS, startDate, endDate); + } + + /** + * Test of getPersonPopular method, of class TmdbPeople. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ +// @Test + public void testGetPersonPopular() throws MovieDbException { + LOG.info("getPersonPopular"); + int page = 0; + TmdbResultsList result = instance.getPersonPopular(page); + assertFalse("No popular people", result.getResults().isEmpty()); + for (PersonBasic person : result.getResults()) { + assertTrue("Missing name", StringUtils.isNotBlank(person.getName())); + } + } + + /** + * Test of getPersonLatest method, of class TmdbPeople. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ +// @Test + public void testGetPersonLatest() throws MovieDbException { + LOG.info("getPersonLatest"); + + Person result = instance.getPersonLatest(); + + assertNotNull("No results found", result); + assertTrue("No results found", StringUtils.isNotBlank(result.getName())); + } + + /** + * Test of getPersonMovieOldCredits method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testGetPersonMovieCredits() throws MovieDbException { + LOG.info("getPersonMovieCredits"); + + NewPersonCredits result = instance.getPersonMovieCredits(ID_BRUCE_WILLIS, LANGUAGE_DEFAULT); + assertEquals("Invalid ID", ID_BRUCE_WILLIS, result.getId()); + assertFalse("No cast information returned", result.getCast().isEmpty()); + for(NewCast person:result.getCast()) { + LOG.info(person.toString()); + } + + assertFalse("No crew information returned", result.getCrew().isEmpty()); + } + + /** + * Test of getPersonTvCredits method, of class TmdbPeople. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ +// @Test + public void testGetPersonTvCredits() throws MovieDbException { + LOG.info("getPersonTvCredits"); + + NewPersonCredits result = instance.getPersonTvCredits(ID_DICK_WOLF, LANGUAGE_DEFAULT); + assertEquals("Invalid ID", ID_DICK_WOLF, result.getId()); + assertFalse("No cast information returned", result.getCast().isEmpty()); + assertFalse("No crew information returned", result.getCrew().isEmpty()); + } + + /** + * Test of getPersonCombinedCredits method, of class TmdbPeople. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ +// @Test + public void testGetPersonCombinedCredits() throws MovieDbException { + LOG.info("getPersonCombinedCredits"); + + NewPersonCredits result = instance.getPersonCombinedCredits(ID_SEAN_BEAN, LANGUAGE_DEFAULT); + assertEquals("Invalid ID", ID_SEAN_BEAN, result.getId()); + assertFalse("No cast information returned", result.getCast().isEmpty()); + assertFalse("No crew information returned", result.getCrew().isEmpty()); + + LOG.info("{}", result.toString()); + } + +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbReviewsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbReviewsTest.java new file mode 100644 index 000000000..91fddb8db --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbReviewsTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import static com.omertron.themoviedbapi.TheMovieDbApiTest.getApiKey(); +import com.omertron.themoviedbapi.model.Review; +import org.apache.commons.lang3.StringUtils; +import org.junit.After; +import org.junit.AfterClass; +import static org.junit.Assert.assertTrue; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.yamj.api.common.http.DefaultPoolingHttpClient; + +/** + * + * @author stuart.boston + */ +public class TmdbReviewsTest extends AbstractTests{ + + // Logger + private static final Logger LOG = LoggerFactory.getLogger(TmdbAuthenticationTest.class); + // API + private static TmdbReviews instance; + + public TmdbReviewsTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + instance = new TmdbReviews(getApiKey(),getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getReview method, of class TmdbReviews. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testGetReview() throws MovieDbException { + LOG.info("getReview"); + String reviewId = "5013bc76760ee372cb00253e"; + Review result = instance.getReview(reviewId); + LOG.info(result.toString()); + assertTrue("No Author", StringUtils.isNotBlank(result.getAuthor())); + assertTrue("No Content", StringUtils.isNotBlank(result.getContent())); + } + +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbSearchTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbSearchTest.java new file mode 100644 index 000000000..c18b2d454 --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbSearchTest.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import com.omertron.themoviedbapi.model.Collection; +import com.omertron.themoviedbapi.model.Company; +import com.omertron.themoviedbapi.model.Keyword; +import com.omertron.themoviedbapi.model.MovieDb; +import com.omertron.themoviedbapi.model.MovieList; +import com.omertron.themoviedbapi.model.person.PersonMovieOld; +import com.omertron.themoviedbapi.model.tv.TVSeriesBasic; +import com.omertron.themoviedbapi.results.TmdbResultsList; +import org.junit.AfterClass; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * + * @author stuart.boston + */ +public class TmdbSearchTest extends AbstractTests { + + // API + private static TmdbSearch instance; + private static final String COMPANY_NAME = "Marvel Studios"; + + public TmdbSearchTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + instance = new TmdbSearch(getApiKey(), getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + /** + * Test of searchMovie method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testSearchMovie() throws MovieDbException { + LOG.info("searchMovie"); + + // Try a movie with less than 1 page of results + TmdbResultsList movieList = instance.searchMovie("Blade Runner", 0, "", true, 0); +// List movieList = tmdb.searchMovie("Blade Runner", "", true); + assertTrue("No movies found, should be at least 1", movieList.getResults().size() > 0); + + // Try a russian langugage movie + movieList = instance.searchMovie("О чём говорят мужчины", 0, LANGUAGE_RUSSIAN, true, 0); + assertTrue("No 'RU' movies found, should be at least 1", movieList.getResults().size() > 0); + + // Try a movie with more than 20 results + movieList = instance.searchMovie("Star Wars", 0, LANGUAGE_ENGLISH, false, 0); + assertTrue("Not enough movies found, should be over 15, found " + movieList.getResults().size(), movieList.getResults().size() >= 15); + } + + /** + * Test of searchTv method, of class TmdbSearch. + * + * @throws MovieDbException + */ + @Test + public void testSearchTv() throws MovieDbException { + LOG.info("searchTv"); + TmdbResultsList results = instance.searchTv("Big Bang Theory", 0, LANGUAGE_DEFAULT, null, 0); + assertFalse("No shows found, should be at least 1", results.getResults().isEmpty()); + } + + /** + * Test of searchCollection method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testSearchCollection() throws MovieDbException { + LOG.info("searchCollection"); + String query = "batman"; + int page = 0; + TmdbResultsList result = instance.searchCollection(query, LANGUAGE_DEFAULT, page); + assertFalse("No collections found", result == null); + assertTrue("No collections found", result.getResults().size() > 0); + } + + /** + * Test of searchPeople method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testSearchPeople() throws MovieDbException { + LOG.info("searchPeople"); + String personName = "Bruce Willis"; + boolean includeAdult = false; + TmdbResultsList result = instance.searchPeople(personName, includeAdult, 0); + assertTrue("Couldn't find the person", result.getResults().size() > 0); + } + + /** + * Test of searchList method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testSearchList() throws MovieDbException { + LOG.info("searchList"); + String query = "watch"; + int page = 0; + TmdbResultsList result = instance.searchList(query, LANGUAGE_DEFAULT, page); + assertFalse("No lists found", result.getResults() == null); + assertTrue("No lists found", result.getResults().size() > 0); + } + + /** + * Test of searchCompanies method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testSearchCompanies() throws MovieDbException { + LOG.info("searchCompanies"); + TmdbResultsList result = instance.searchCompanies(COMPANY_NAME, 0); + assertTrue("No company information found", !result.getResults().isEmpty()); + } + + /** + * Test of searchKeyword method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Test + public void testSearchKeyword() throws MovieDbException { + LOG.info("searchKeyword"); + String query = "action"; + int page = 0; + TmdbResultsList result = instance.searchKeyword(query, page); + assertFalse("No keywords found", result.getResults() == null); + assertTrue("No keywords found", result.getResults().size() > 0); + } + +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbTVTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbTVTest.java new file mode 100644 index 000000000..4e5ced56f --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbTVTest.java @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2004-2015 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.methods; + +import com.omertron.themoviedbapi.AbstractTests; +import com.omertron.themoviedbapi.MovieDbException; +import com.omertron.themoviedbapi.TestLogger; +import com.omertron.themoviedbapi.model.Artwork; +import com.omertron.themoviedbapi.model.ExternalIds; +import com.omertron.themoviedbapi.model.tv.TVCredits; +import com.omertron.themoviedbapi.model.tv.TVEpisode; +import com.omertron.themoviedbapi.model.tv.TVSeason; +import com.omertron.themoviedbapi.model.tv.TVSeries; +import com.omertron.themoviedbapi.results.TmdbResultsList; +import org.apache.commons.lang3.StringUtils; +import org.junit.AfterClass; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Test for the TV Method + * + * @author stuart.boston + */ +public class TmdbTVTest extends AbstractTests { + + // API + private static TmdbTV instance; + // IDs + private static final int ID_BIG_BANG_THEORY = 1418; + + public TmdbTVTest() { + } + + @BeforeClass + public static void setUpClass() throws MovieDbException { + TestLogger.Configure(); + instance = new TmdbTV(getApiKey(),getHttpTools()); + } + + @AfterClass + public static void tearDownClass() { + } + + /** + * Test of getTv method, of class TV. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + //@Test + public void testGetTv() throws MovieDbException { + LOG.info("getTv"); + TVSeries result = instance.getTv(ID_BIG_BANG_THEORY, LANGUAGE_DEFAULT, null); + assertEquals("Wrong title returned", "The Big Bang Theory", result.getName()); + assertTrue("No seasons returned", result.getNumberSeasons() >= 5); + assertTrue("No episodes returned", result.getNumberEpisodes() > 100); + assertFalse("No genres returned", result.getGenres().isEmpty()); + assertFalse("No created by", result.getCreatedBy().isEmpty()); + } + + /** + * Test of getTvCredits method, of class TV. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testGetTvCredits() throws MovieDbException { + LOG.info("getTvCredits"); + + TVCredits result = instance.getTvCredits(ID_BIG_BANG_THEORY, LANGUAGE_DEFAULT, null); + assertFalse("No cast", result.getCast().isEmpty()); + assertFalse("No crew", result.getCrew().isEmpty()); + assertTrue("Guest stars returned", result.getGuestStar().isEmpty()); + } + + /** + * Test of getTvExternalIds method, of class TV. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + //@Test + public void testGetTvExternalIds() throws MovieDbException { + LOG.info("getTvExternalIds"); + ExternalIds result = instance.getTvExternalIds(ID_BIG_BANG_THEORY, LANGUAGE_DEFAULT); + assertFalse("No ids found", result.getIds().isEmpty()); + assertTrue("TMDB Id not found", result.hasId("id")); + assertEquals("Wrong id returned", Integer.toString(ID_BIG_BANG_THEORY), result.getId("id")); + assertEquals("Wrong TVDB Id returned", "80379", result.getId("tvdb_id")); + } + + /** + * Test of getTvImages method, of class TV. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + //@Test + public void testGetTvImages() throws MovieDbException { + LOG.info("getTvImages"); + TmdbResultsList result = instance.getTvImages(ID_BIG_BANG_THEORY, LANGUAGE_DEFAULT); + assertFalse("No results found", result.getResults().isEmpty()); + } + + /** + * Test of getTvSeason method, of class TV. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + //@Test + public void testGetTvSeason() throws MovieDbException { + LOG.info("getTvSeason"); + + TVSeason result = instance.getTvSeason(ID_BIG_BANG_THEORY, 1, LANGUAGE_DEFAULT, null); + assertFalse("No episodes found for season", result.getEpisodes().isEmpty()); + assertEquals("Wrong air date", "2007-09-24", result.getAirDate()); + assertEquals("Wrong season name", "Season 1", result.getName()); + } + + /** + * Test of getTvSeasonExternalIds method, of class TV. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + //@Test + public void testGetTvSeasonExternalIds() throws MovieDbException { + LOG.info("getTvSeasonExternalIds"); + + ExternalIds result = instance.getTvSeasonExternalIds(ID_BIG_BANG_THEORY, 1, LANGUAGE_DEFAULT); + assertFalse("No ids found", result.getIds().isEmpty()); + assertTrue("TMDB Id not found", result.hasId("id")); + assertEquals("Wrong season id returned", "3738", result.getId("id")); + assertEquals("Wrong TVDB Id returned", "28047", result.getId("tvdb_id")); + } + + /** + * Test of getTvSeasonImages method, of class TV. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + //@Test + public void testGetTvSeasonImages() throws MovieDbException { + LOG.info("getTvSeasonImages"); + TmdbResultsList result = instance.getTvSeasonImages(ID_BIG_BANG_THEORY, 1, LANGUAGE_DEFAULT); + assertFalse("No results found", result.getResults().isEmpty()); + } + + /** + * Test of getTvEpisode method, of class TV. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + //@Test + public void testGetTvEpisode() throws MovieDbException { + LOG.info("getTvEpisode"); + TVEpisode result = instance.getTvEpisode(ID_BIG_BANG_THEORY, 1, 1, LANGUAGE_DEFAULT, null); + assertEquals("Wrong ID", 64766, result.getId()); + assertEquals("Wrong date", "2007-09-24", result.getAirDate()); + assertTrue("No overview", StringUtils.isNotBlank(result.getOverview())); + } + + /** + * Test of getTvEpisodeCredits method, of class TV. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Test + public void testGetTvEpisodeCredits() throws MovieDbException { + LOG.info("getTvEpisodeCredits"); + TVCredits result = instance.getTvEpisodeCredits(ID_BIG_BANG_THEORY, 1, 1, LANGUAGE_DEFAULT); + assertFalse("No cast", result.getCast().isEmpty()); + assertFalse("No crew", result.getCrew().isEmpty()); + assertFalse("No Guest stars returned", result.getGuestStar().isEmpty()); + } + + /** + * Test of getTvEpisodeExternalIds method, of class TV. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + @Ignore("Find an episode with ids to test this on") + public void testGetTvEpisodeExternalIds() throws MovieDbException { + LOG.info("getTvEpisodeExternalIds"); + ExternalIds result = instance.getTvEpisodeExternalIds(ID_BIG_BANG_THEORY, 1, 1, LANGUAGE_DEFAULT); + LOG.info("{}", result); + assertFalse("No ids found", result.getIds().isEmpty()); + assertTrue("TMDB Id not found", result.hasId("id")); + assertEquals("Wrong season id returned", "3738", result.getId("id")); + assertEquals("Wrong TVDB Id returned", "28047", result.getId("tvdb_id")); + } + + /** + * Test of getTvEpisodeImages method, of class TV. + * + * @throws com.omertron.themoviedbapi.MovieDbException + */ + //@Test + public void testGetTvEpisodeImages() throws MovieDbException { + LOG.info("getTvEpisodeImages"); + String result = instance.getTvEpisodeImages(ID_BIG_BANG_THEORY, 1, 1, LANGUAGE_DEFAULT); + LOG.info("{}", result); + fail("Unfinished"); + } + +}