diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index ebe0b2dd6..939b50702 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -19,7 +19,6 @@ */ package com.omertron.themoviedbapi; -import com.fasterxml.jackson.databind.ObjectMapper; import com.omertron.themoviedbapi.enumeration.MediaType; import com.omertron.themoviedbapi.methods.TmdbAccount; import com.omertron.themoviedbapi.methods.TmdbAuthentication; @@ -79,8 +78,6 @@ import java.net.URL; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.apache.http.client.HttpClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.yamj.api.common.http.SimpleHttpClientBuilder; /** @@ -92,11 +89,7 @@ import org.yamj.api.common.http.SimpleHttpClientBuilder; */ public class TheMovieDbApi { - private static final Logger LOG = LoggerFactory.getLogger(TheMovieDbApi.class); - private String apiKey; private HttpTools httpTools; - // Jackson JSON configuration - private static final ObjectMapper MAPPER = new ObjectMapper(); // Constants private static final int YEAR_LENGTH = 4; // Sub-methods @@ -138,7 +131,6 @@ public class TheMovieDbApi { * @throws MovieDbException */ public TheMovieDbApi(String apiKey, HttpClient httpClient) throws MovieDbException { - this.apiKey = apiKey; this.httpTools = new HttpTools(httpClient); initialise(apiKey, httpTools); } @@ -687,7 +679,7 @@ public class TheMovieDbApi { * @throws MovieDbException */ public URL createImageUrl(String imagePath, String requiredSize) throws MovieDbException { - return tmdbConfiguration.createImageUrl(imagePath, requiredSize); + return tmdbConfiguration.getConfig().createImageUrl(imagePath, requiredSize); } /** diff --git a/src/main/java/com/omertron/themoviedbapi/methods/TmdbConfiguration.java b/src/main/java/com/omertron/themoviedbapi/methods/TmdbConfiguration.java index 81b7f5ce5..a36f85983 100644 --- a/src/main/java/com/omertron/themoviedbapi/methods/TmdbConfiguration.java +++ b/src/main/java/com/omertron/themoviedbapi/methods/TmdbConfiguration.java @@ -31,7 +31,6 @@ import com.omertron.themoviedbapi.tools.MethodSub; import com.omertron.themoviedbapi.wrapper.WrapperConfig; import com.omertron.themoviedbapi.wrapper.WrapperJobList; import java.io.IOException; -import java.net.MalformedURLException; import java.net.URL; import org.yamj.api.common.exception.ApiExceptionType; @@ -80,29 +79,6 @@ public class TmdbConfiguration extends AbstractMethod { return config; } - /** - * Generate the full image URL from the size and image path - * - * @param imagePath - * @param requiredSize - * @return - * @throws MovieDbException - */ - public URL createImageUrl(String imagePath, String requiredSize) throws MovieDbException { - if (!config.isValidSize(requiredSize)) { - throw new MovieDbException(ApiExceptionType.INVALID_IMAGE, "Required size '" + requiredSize + "' is not valid"); - } - - StringBuilder sb = new StringBuilder(config.getBaseUrl()); - sb.append(requiredSize); - sb.append(imagePath); - try { - return new URL(sb.toString()); - } catch (MalformedURLException ex) { - throw new MovieDbException(ApiExceptionType.INVALID_URL, "Failed to create image URL", sb.toString(), ex); - } - } - /** * Get a list of valid jobs * diff --git a/src/main/java/com/omertron/themoviedbapi/model/Configuration.java b/src/main/java/com/omertron/themoviedbapi/model/Configuration.java index 9e21dfe31..a8338cc13 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Configuration.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Configuration.java @@ -20,8 +20,12 @@ package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.MovieDbException; +import java.net.MalformedURLException; +import java.net.URL; import java.util.List; import org.apache.commons.lang3.StringUtils; +import org.yamj.api.common.exception.ApiExceptionType; /** * @author stuart.boston @@ -180,4 +184,29 @@ public class Configuration extends AbstractJsonMapping { || isValidProfileSize(sizeToCheck) || isValidLogoSize(sizeToCheck); } + + /** + * Generate the full image URL from the size and image path + * + * @param imagePath + * @param requiredSize + * @return + * @throws MovieDbException + */ + public URL createImageUrl(String imagePath, String requiredSize) throws MovieDbException { + if (!isValidSize(requiredSize)) { + throw new MovieDbException(ApiExceptionType.INVALID_IMAGE, "Required size '" + requiredSize + "' is not valid"); + } + + StringBuilder sb = new StringBuilder(getBaseUrl()); + sb.append(requiredSize); + sb.append(imagePath); + + try { + return new URL(sb.toString()); + } catch (MalformedURLException ex) { + throw new MovieDbException(ApiExceptionType.INVALID_URL, "Failed to create image URL", sb.toString(), ex); + } + } + } diff --git a/src/main/java/com/omertron/themoviedbapi/results/TmdbResultsList.java b/src/main/java/com/omertron/themoviedbapi/results/TmdbResultsList.java index f9b29e5f6..d6d7c422f 100644 --- a/src/main/java/com/omertron/themoviedbapi/results/TmdbResultsList.java +++ b/src/main/java/com/omertron/themoviedbapi/results/TmdbResultsList.java @@ -48,6 +48,10 @@ public final class TmdbResultsList extends AbstractResults { this.results = results; } + public boolean isEmpty() { + return results.isEmpty(); + } + @Override public int getTotalResults() { if (super.getTotalResults() == 0) { diff --git a/src/test/java/com/omertron/themoviedbapi/AbstractTests.java b/src/test/java/com/omertron/themoviedbapi/AbstractTests.java index 0b19a628f..a7cb01b55 100644 --- a/src/test/java/com/omertron/themoviedbapi/AbstractTests.java +++ b/src/test/java/com/omertron/themoviedbapi/AbstractTests.java @@ -19,15 +19,17 @@ */ package com.omertron.themoviedbapi; +import com.omertron.themoviedbapi.methods.TmdbAccount; +import com.omertron.themoviedbapi.methods.TmdbAuthentication; +import com.omertron.themoviedbapi.model.Account; +import com.omertron.themoviedbapi.model.TokenAuthorisation; +import com.omertron.themoviedbapi.model.TokenSession; 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 org.apache.http.client.HttpClient; +import static org.junit.Assert.assertTrue; 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; @@ -39,13 +41,15 @@ public class AbstractTests { private static final Properties props = new Properties(); private static HttpClient httpClient; private static HttpTools httpTools; + // Session informaion + private static TokenSession tokenSession = null; + private static Account account = null; // 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 { + public static final void doConfiguration() throws MovieDbException { TestLogger.Configure(); httpClient = new SimpleHttpClientBuilder().build(); httpTools = new HttpTools(httpClient); @@ -68,16 +72,30 @@ public class AbstractTests { } } - @AfterClass - public static void tearDownClass() throws MovieDbException { + public static final String getSessionId() throws MovieDbException { + if (tokenSession == null) { + TmdbAuthentication auth = new TmdbAuthentication(getApiKey(), getHttpTools()); + LOG.info("Test and create a session token for the rest of the tests"); + // 1: Create a request token + TokenAuthorisation token = auth.getAuthorisationToken(); + assertTrue("Token (auth) is not valid", token.getSuccess()); + token = auth.getSessionTokenLogin(token, getUsername(), getPassword()); + assertTrue("Token (login) is not valid", token.getSuccess()); + // 3: Create the sessions ID + tokenSession = auth.getSessionToken(token); + assertTrue("Session token is not valid", tokenSession.getSuccess()); + + } + return tokenSession.getSessionId(); } - @Before - public void setUp() throws MovieDbException { - } - - @After - public void tearDown() throws MovieDbException { + public static final int getAccountId() throws MovieDbException { + if (account == null) { + TmdbAccount instance = new TmdbAccount(getApiKey(), getHttpTools()); + // Get the account for later tests + account = instance.getAccount(tokenSession.getSessionId()); + } + return account.getId(); } public static HttpClient getHttpClient() { diff --git a/src/test/java/com/omertron/themoviedbapi/TestAccounts.java b/src/test/java/com/omertron/themoviedbapi/TestAccounts.java index 547d1e5e0..13699beae 100644 --- a/src/test/java/com/omertron/themoviedbapi/TestAccounts.java +++ b/src/test/java/com/omertron/themoviedbapi/TestAccounts.java @@ -48,11 +48,11 @@ public class TestAccounts extends AbstractTests { @BeforeClass public static void setUpClass() throws MovieDbException { + doConfiguration(); tmdb = new TheMovieDbApi(getApiKey()); } @Before - @Override public void setUp() throws MovieDbException { if (tokenSession == null) { testSessionCreation(); diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbAccountTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbAccountTest.java index f393e6f6a..a7cd50f13 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbAccountTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbAccountTest.java @@ -21,7 +21,7 @@ package com.omertron.themoviedbapi.methods; import com.omertron.themoviedbapi.AbstractTests; import com.omertron.themoviedbapi.MovieDbException; -import com.omertron.themoviedbapi.TestLogger; +import com.omertron.themoviedbapi.enumeration.MediaType; import com.omertron.themoviedbapi.model.Account; import com.omertron.themoviedbapi.model.MovieDb; import com.omertron.themoviedbapi.model.MovieDbList; @@ -42,7 +42,6 @@ import org.junit.Test; */ public class TmdbAccountTest extends AbstractTests { - // API private static TmdbAccount instance; // Constants private static final int ID_MOVIE_FIGHT_CLUB = 550; @@ -52,7 +51,7 @@ public class TmdbAccountTest extends AbstractTests { @BeforeClass public static void setUpClass() throws MovieDbException { - TestLogger.Configure(); + doConfiguration(); instance = new TmdbAccount(getApiKey(), getHttpTools()); } @@ -61,15 +60,17 @@ public class TmdbAccountTest extends AbstractTests { } /** - * Test of getAccount method, of class TmdbAccount. + * Test of getAccountId 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()); + Account result = instance.getAccount(getSessionId()); + assertNotNull("No account returned", result); + // Make sure properties are extracted correctly + assertEquals("Wrong username!", getUsername(), result.getUserName()); } /** @@ -80,7 +81,7 @@ public class TmdbAccountTest extends AbstractTests { @Test public void testGetUserLists() throws MovieDbException { LOG.info("getUserLists"); - List result = instance.getUserLists(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS); + List result = instance.getUserLists(getSessionId(), getAccountId()); assertNotNull("Null list returned", result); } @@ -95,16 +96,16 @@ public class TmdbAccountTest extends AbstractTests { 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); + List favList = instance.getFavoriteMovies(getSessionId(), getAccountId()); 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); + StatusCode status = instance.changeFavoriteStatus(getSessionId(), getAccountId(), ID_MOVIE_FIGHT_CLUB, MediaType.MOVIE, true); LOG.info("Add Status: {}", status); LOG.info("Get favorite list"); - favList = instance.getFavoriteMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS); + favList = instance.getFavoriteMovies(getSessionId(), getAccountId()); assertNotNull("Empty favorite list returned", favList); assertFalse("Favorite list empty", favList.isEmpty()); @@ -112,10 +113,10 @@ public class TmdbAccountTest extends AbstractTests { 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); + status = instance.changeFavoriteStatus(getSessionId(), getAccountId(), movie.getId(), MediaType.MOVIE, false); LOG.info("Remove status: {}", status); } - assertTrue("Favorite list was not empty", instance.getFavoriteMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty()); + assertTrue("Favorite list was not empty", instance.getFavoriteMovies(getSessionId(), getAccountId()).isEmpty()); } /** @@ -135,7 +136,7 @@ public class TmdbAccountTest extends AbstractTests { @Test public void testGetRatedMovies() throws MovieDbException { LOG.info("getRatedMovies"); - List result = instance.getRatedMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS); + List result = instance.getRatedMovies(getSessionId(), getAccountId()); assertFalse("No rated movies", result.isEmpty()); } @@ -150,16 +151,16 @@ public class TmdbAccountTest extends AbstractTests { 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); + List watchList = instance.getWatchListMovie(getSessionId(), getAccountId()); 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); + StatusCode status = instance.modifyWatchList(getSessionId(), getAccountId(), ID_MOVIE_FIGHT_CLUB, MediaType.MOVIE, true); LOG.info("Add Status: {}", status); LOG.info("Get watch list"); - watchList = instance.getWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS); + watchList = instance.getWatchListMovie(getSessionId(), getAccountId()); assertNotNull("Empty watch list returned", watchList); assertFalse("Watchlist list empty", watchList.isEmpty()); @@ -167,11 +168,11 @@ public class TmdbAccountTest extends AbstractTests { // 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); + status = instance.modifyWatchList(getSessionId(), getAccountId(), movie.getId(), MediaType.MOVIE, false); LOG.info("Remove status: {}", status); } - assertTrue(instance.getWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty()); + assertTrue(instance.getWatchListMovie(getSessionId(), getAccountId()).isEmpty()); } /** diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbAuthenticationTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbAuthenticationTest.java index 69bf8e20c..9a73574a6 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbAuthenticationTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbAuthenticationTest.java @@ -21,7 +21,6 @@ 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; @@ -37,7 +36,6 @@ import org.junit.Test; */ public class TmdbAuthenticationTest extends AbstractTests{ - // API private static TmdbAuthentication instance; public TmdbAuthenticationTest() { @@ -45,7 +43,7 @@ public class TmdbAuthenticationTest extends AbstractTests{ @BeforeClass public static void setUpClass() throws MovieDbException { - TestLogger.Configure(); + doConfiguration(); instance = new TmdbAuthentication(getApiKey(),getHttpTools()); } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCertificationsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCertificationsTest.java index 20bbf8625..bf8debd19 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCertificationsTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCertificationsTest.java @@ -20,8 +20,8 @@ package com.omertron.themoviedbapi.methods; import com.omertron.themoviedbapi.AbstractTests; +import static com.omertron.themoviedbapi.AbstractTests.doConfiguration; 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; @@ -37,7 +37,6 @@ import org.junit.Test; */ public class TmdbCertificationsTest extends AbstractTests { - // API private static TmdbCertifications instance; public TmdbCertificationsTest() { @@ -45,7 +44,7 @@ public class TmdbCertificationsTest extends AbstractTests { @BeforeClass public static void setUpClass() throws MovieDbException { - TestLogger.Configure(); + doConfiguration(); instance = new TmdbCertifications(getApiKey(), getHttpTools()); } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbChangesTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbChangesTest.java index fd84ba761..4923c503d 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbChangesTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbChangesTest.java @@ -21,9 +21,9 @@ 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.model.ChangedMedia; import com.omertron.themoviedbapi.results.TmdbResultsList; +import com.omertron.themoviedbapi.tools.MethodBase; import org.junit.AfterClass; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; @@ -45,7 +45,7 @@ public class TmdbChangesTest extends AbstractTests { @BeforeClass public static void setUpClass() throws MovieDbException { - TestLogger.Configure(); + doConfiguration(); instance = new TmdbChanges(getApiKey(), getHttpTools()); } @@ -54,7 +54,7 @@ public class TmdbChangesTest extends AbstractTests { } /** - * Test of getMovieChangesList method, of class TmdbChanges. + * Test of getChangeList(MOVIE) method, of class TmdbChanges. * * @throws MovieDbException */ @@ -64,12 +64,13 @@ public class TmdbChangesTest extends AbstractTests { int page = 0; String startDate = ""; String endDate = ""; - TmdbResultsList result = instance.getMovieChangesList(page, startDate, endDate); + + TmdbResultsList result = instance.getChangeList(MethodBase.MOVIE, page, startDate, endDate); assertFalse("No movie changes.", result.getResults().isEmpty()); } /** - * Test of getPersonMovieOldChangesList method, of class TheMovieDbApi. + * Test of getChangeList(PERSON) method, of class TheMovieDbApi. * * @throws MovieDbException */ @@ -79,7 +80,23 @@ public class TmdbChangesTest extends AbstractTests { int page = 0; String startDate = ""; String endDate = ""; - instance.getPersonChangesList(page, startDate, endDate); + TmdbResultsList result = instance.getChangeList(MethodBase.PERSON, page, startDate, endDate); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of getChangeList(TV) method, of class TheMovieDbApi. + * + * @throws MovieDbException + */ + @Ignore("Not ready yet") + public void testGetTVChangesList() throws MovieDbException { + LOG.info("getPersonChangesList"); + int page = 0; + String startDate = ""; + String endDate = ""; + TmdbResultsList result = instance.getChangeList(MethodBase.PERSON, 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 index 50649b3ea..4c9414e9f 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCollectionsTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCollectionsTest.java @@ -21,7 +21,6 @@ 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; @@ -36,7 +35,6 @@ import org.junit.Test; */ public class TmdbCollectionsTest extends AbstractTests { - // API private static TmdbCollections instance; private static final int ID_COLLECTION_STAR_WARS = 10; @@ -45,7 +43,7 @@ public class TmdbCollectionsTest extends AbstractTests { @BeforeClass public static void setUpClass() throws MovieDbException { - TestLogger.Configure(); + doConfiguration(); instance = new TmdbCollections(getApiKey(), getHttpTools()); } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCompaniesTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCompaniesTest.java index 50344ba87..a3898d00f 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCompaniesTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCompaniesTest.java @@ -21,11 +21,8 @@ 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.model.MovieDb; import com.omertron.themoviedbapi.results.TmdbResultsList; import org.junit.After; import org.junit.AfterClass; @@ -34,19 +31,13 @@ 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{ +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; @@ -55,8 +46,8 @@ public class TmdbCompaniesTest extends AbstractTests{ @BeforeClass public static void setUpClass() throws MovieDbException { - TestLogger.Configure(); - instance = new TmdbCompanies(getApiKey(),getHttpTools()); + doConfiguration(); + instance = new TmdbCompanies(getApiKey(), getHttpTools()); } @AfterClass @@ -93,6 +84,6 @@ public class TmdbCompaniesTest extends AbstractTests{ 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()); + assertTrue("No company movies found", !result.isEmpty()); } } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbConfigurationTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbConfigurationTest.java index 73b80c431..f59f8acfe 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbConfigurationTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbConfigurationTest.java @@ -21,10 +21,7 @@ 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; @@ -33,9 +30,6 @@ 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; /** * @@ -43,19 +37,15 @@ import org.yamj.api.common.http.DefaultPoolingHttpClient; */ 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()); + public static void setUpClass() throws MovieDbException { + doConfiguration(); + instance = new TmdbConfiguration(getApiKey(), getHttpTools()); } @AfterClass @@ -98,7 +88,7 @@ public class TmdbConfigurationTest extends AbstractTests { LOG.info("createImageUrl"); Configuration config = instance.getConfig(); - String result = config.createImageUrl("http://mediaplayersite.com/image.jpg", ArtworkType.POSTER, "original").toString(); + String result = config.createImageUrl("http://mediaplayersite.com/image.jpg", "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 index e2186a91c..2fe107517 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCreditsTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCreditsTest.java @@ -21,19 +21,13 @@ 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 com.omertron.themoviedbapi.model.TBD_PersonCredits; 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.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.yamj.api.common.http.DefaultPoolingHttpClient; /** * @@ -41,9 +35,6 @@ import org.yamj.api.common.http.DefaultPoolingHttpClient; */ public class TmdbCreditsTest extends AbstractTests{ - // Logger - private static final Logger LOG = LoggerFactory.getLogger(TmdbCreditsTest.class); - // API private static TmdbCredits instance; public TmdbCreditsTest() { @@ -51,7 +42,7 @@ public class TmdbCreditsTest extends AbstractTests{ @BeforeClass public static void setUpClass() throws MovieDbException { - TestLogger.Configure(); + doConfiguration(); instance = new TmdbCredits(getApiKey(),getHttpTools()); } @@ -77,10 +68,11 @@ public class TmdbCreditsTest extends AbstractTests{ 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()); + TBD_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()); + fail("The test case is a prototype."); } } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbDiscoverTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbDiscoverTest.java index ee2e55e17..773f26d70 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbDiscoverTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbDiscoverTest.java @@ -21,11 +21,8 @@ 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.model.Discover; +import com.omertron.themoviedbapi.model.MovieDb; import com.omertron.themoviedbapi.results.TmdbResultsList; import org.junit.After; import org.junit.AfterClass; @@ -33,9 +30,6 @@ 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; /** * @@ -43,9 +37,6 @@ import org.yamj.api.common.http.DefaultPoolingHttpClient; */ public class TmdbDiscoverTest extends AbstractTests { - // Logger - private static final Logger LOG = LoggerFactory.getLogger(TmdbDiscoverTest.class); - // API private static TmdbDiscover instance; public TmdbDiscoverTest() { @@ -53,7 +44,7 @@ public class TmdbDiscoverTest extends AbstractTests { @BeforeClass public static void setUpClass() throws MovieDbException { - TestLogger.Configure(); + doConfiguration(); instance = new TmdbDiscover(getApiKey(),getHttpTools()); } @@ -80,7 +71,7 @@ public class TmdbDiscoverTest extends AbstractTests { Discover discover = new Discover(); discover.year(2013).language(LANGUAGE_ENGLISH); - TmdbResultsList result = instance.getDiscoverMovie(discover); + TmdbResultsList result = instance.getDiscoverMovies(discover); assertFalse("No movies discovered", result.getResults().isEmpty()); } @@ -95,7 +86,7 @@ public class TmdbDiscoverTest extends AbstractTests { Discover discover = new Discover(); discover.year(2013).language(LANGUAGE_ENGLISH); - TmdbResultsList result = instance.getDiscoverMovie(discover); + TmdbResultsList result = instance.getDiscoverMovies(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 index 048d03dbe..f4215fde0 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbFindTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbFindTest.java @@ -21,29 +21,20 @@ 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 static org.junit.Assert.fail; 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() { @@ -51,8 +42,8 @@ public class TmdbFindTest extends AbstractTests { @BeforeClass public static void setUpClass() throws MovieDbException { - TestLogger.Configure(); - instance = new TmdbFind(getApiKey(),getHttpTools()); + doConfiguration(); + instance = new TmdbFind(getApiKey(), getHttpTools()); } @AfterClass @@ -75,23 +66,25 @@ public class TmdbFindTest extends AbstractTests { @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()); +// TBD_FindResults result = instance.find("tt0196229", TBD_ExternalSource.imdb_id, "it"); +// assertFalse("No movie for id.", result.getMovieResults().isEmpty()); + fail("The test case is a prototype."); } @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()); +// TBD_FindResults result = instance.find("tt1219024", TBD_ExternalSource.imdb_id, "it"); +// assertFalse("No tv for id.", result.getTvResults().isEmpty()); + fail("The test case is a prototype."); } @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()); +// TBD_FindResults result = instance.find("nm0001774", TBD_ExternalSource.imdb_id, "it"); +// assertFalse("No person for id.", result.getPersonResults().isEmpty()); + fail("The test case is a prototype."); } - } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbGenresTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbGenresTest.java index 74cbcc547..0300efce9 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbGenresTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbGenresTest.java @@ -21,11 +21,8 @@ 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.model.MovieDb; import com.omertron.themoviedbapi.results.TmdbResultsList; import org.junit.After; import org.junit.AfterClass; @@ -33,9 +30,6 @@ 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; /** * @@ -43,9 +37,6 @@ import org.yamj.api.common.http.DefaultPoolingHttpClient; */ 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; @@ -54,8 +45,8 @@ public class TmdbGenresTest extends AbstractTests { @BeforeClass public static void setUpClass() throws MovieDbException { - TestLogger.Configure(); - instance = new TmdbGenres(getApiKey(),getHttpTools()); + doConfiguration(); + instance = new TmdbGenres(getApiKey(), getHttpTools()); } @AfterClass @@ -91,7 +82,7 @@ public class TmdbGenresTest extends AbstractTests { 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()); + assertTrue("No genre movies found", !result.isEmpty()); } } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbJobsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbJobsTest.java deleted file mode 100644 index 7d23343ef..000000000 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbJobsTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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 index 3e758109c..bfbb2ed45 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbKeywordsTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbKeywordsTest.java @@ -21,11 +21,8 @@ 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.model.KeywordMovie; import com.omertron.themoviedbapi.results.TmdbResultsList; import org.junit.After; import org.junit.AfterClass; @@ -34,9 +31,6 @@ 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; /** * @@ -44,9 +38,6 @@ import org.yamj.api.common.http.DefaultPoolingHttpClient; */ 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"; @@ -55,7 +46,7 @@ public class TmdbKeywordsTest extends AbstractTests{ @BeforeClass public static void setUpClass() throws MovieDbException { - TestLogger.Configure(); + doConfiguration(); tmdb = new TmdbKeywords(getApiKey(),getHttpTools()); } @@ -92,8 +83,8 @@ public class TmdbKeywordsTest extends AbstractTests{ 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()); + TmdbResultsList result = tmdb.getKeywordMovies(ID_KEYWORD, LANGUAGE_DEFAULT, page); + assertFalse("No keyword movies found", result.isEmpty()); } } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbListsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbListsTest.java index a31c28b49..640072366 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbListsTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbListsTest.java @@ -21,12 +21,9 @@ 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.MovieDbList; import com.omertron.themoviedbapi.model.StatusCode; -import com.omertron.themoviedbapi.model.StatusCodeList; -import com.omertron.themoviedbapi.model.movie.MovieDbList; +import com.omertron.themoviedbapi.tools.MethodSub; import org.junit.After; import org.junit.AfterClass; import static org.junit.Assert.assertEquals; @@ -38,16 +35,10 @@ 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{ +public class TmdbListsTest extends AbstractTests { - // Logger - private static final Logger LOG = LoggerFactory.getLogger(TmdbGenresTest.class); - // API private static TmdbLists instance; public TmdbListsTest() { @@ -55,8 +46,8 @@ public class TmdbListsTest extends AbstractTests{ @BeforeClass public static void setUpClass() throws MovieDbException { - TestLogger.Configure(); - instance = new TmdbLists(getApiKey(),getHttpTools()); + doConfiguration(); + instance = new TmdbLists(getApiKey(), getHttpTools()); } @AfterClass @@ -81,10 +72,10 @@ public class TmdbListsTest extends AbstractTests{ 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()); + String result = instance.createList(getSessionId(), name, description); + LOG.info(result); // TODO review the generated test code and remove the default call to fail. -// fail("The test case is a prototype."); + fail("The test case is a prototype."); } /** @@ -111,7 +102,7 @@ public class TmdbListsTest extends AbstractTests{ String listId = ""; Integer movieId = null; StatusCode expResult = null; - StatusCode result = instance.addMovieToList(SESSION_ID_APITESTS, listId, movieId); + StatusCode result = instance.modifyMovieList(getSessionId(), listId, movieId, MethodSub.MOVIE); assertEquals(expResult, result); // TODO review the generated test code and remove the default call to fail. fail("The test case is a prototype."); @@ -145,7 +136,7 @@ public class TmdbListsTest extends AbstractTests{ String listId = ""; Integer movieId = null; StatusCode expResult = null; - StatusCode result = instance.removeMovieFromList(SESSION_ID_APITESTS, listId, movieId); + StatusCode result = instance.modifyMovieList(getSessionId(), listId, movieId, MethodSub.MOVIE); assertEquals(expResult, result); // TODO review the generated test code and remove the default call to fail. fail("The test case is a prototype."); @@ -161,7 +152,7 @@ public class TmdbListsTest extends AbstractTests{ LOG.info("deleteMovieList"); String listId = ""; StatusCode expResult = null; - StatusCode result = instance.deleteMovieList(SESSION_ID_APITESTS, listId); + StatusCode result = instance.deleteMovieList(getSessionId(), 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 index c6add35c5..051bac584 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java @@ -21,26 +21,15 @@ 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.MovieDb; +import com.omertron.themoviedbapi.model.MovieList; 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.model.Video; import com.omertron.themoviedbapi.results.TmdbResultsList; -import com.omertron.themoviedbapi.results.TmdbResultsMap; import java.util.List; import java.util.Random; import org.junit.AfterClass; @@ -48,17 +37,16 @@ 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 static org.junit.Assert.fail; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; /** * * @author stuart.boston */ -public class TmdbMoviesTest extends AbstractTests{ +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; @@ -68,8 +56,9 @@ public class TmdbMoviesTest extends AbstractTests{ @BeforeClass public static void setUpClass() throws MovieDbException { - TestLogger.Configure(); - instance = new TmdbMovies(getApiKey(),getHttpTools()); + doConfiguration(); + instance = new TmdbMovies(getApiKey(), getHttpTools()); + } @AfterClass @@ -126,25 +115,29 @@ public class TmdbMoviesTest extends AbstractTests{ @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); + /* + 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; + 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; - } + 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); + */ + fail("The test case is a prototype."); - if (!foundName2 && person.getName().equalsIgnoreCase(name2)) { - foundName2 = Boolean.TRUE; - } - } - assertTrue("Couldn't find " + name1, foundName1); - assertTrue("Couldn't find " + name2, foundName2); } /** @@ -192,7 +185,7 @@ public class TmdbMoviesTest extends AbstractTests{ @Test public void testGetMovieTrailers() throws MovieDbException { LOG.info("getMovieTrailers"); - TmdbResultsList result = instance.getMovieTrailers(ID_MOVIE_BLADE_RUNNER, ""); + TmdbResultsList