From 66de073677dc6e0de03b9565d8d062f6db8b1e9a Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Thu, 25 Feb 2016 10:51:07 +0000 Subject: [PATCH] Sonar fixes --- .../themoviedbapi/tools/PostTools.java | 4 ++ .../themoviedbapi/tools/TmdbParameters.java | 1 + .../omertron/themoviedbapi/AbstractTests.java | 40 ++++++----- .../omertron/themoviedbapi/CompareTest.java | 15 ----- .../com/omertron/themoviedbapi/TestSuite.java | 31 +++++---- .../methods/TmdbAccountTest.java | 66 ++++++++----------- .../methods/TmdbAuthenticationTest.java | 15 ----- .../methods/TmdbCertificationsTest.java | 5 -- .../methods/TmdbChangesTest.java | 5 -- .../methods/TmdbCollectionsTest.java | 7 +- .../methods/TmdbCompaniesTest.java | 17 +---- .../methods/TmdbConfigurationTest.java | 19 +----- .../methods/TmdbCreditsTest.java | 15 ----- .../methods/TmdbDiscoverTest.java | 15 ----- .../methods/TmdbEpisodesTest.java | 28 ++------ .../themoviedbapi/methods/TmdbFindTest.java | 22 ++----- .../themoviedbapi/methods/TmdbGenresTest.java | 29 +++----- .../methods/TmdbKeywordsTest.java | 15 ----- .../themoviedbapi/methods/TmdbListsTest.java | 27 ++------ .../themoviedbapi/methods/TmdbMoviesTest.java | 7 +- .../methods/TmdbNetworksTest.java | 13 ++-- .../themoviedbapi/methods/TmdbPeopleTest.java | 40 ++++------- .../methods/TmdbReviewsTest.java | 15 ----- .../methods/TmdbSeasonsTest.java | 28 ++------ .../themoviedbapi/tools/ApiUrlTest.java | 7 +- 25 files changed, 135 insertions(+), 351 deletions(-) diff --git a/src/main/java/com/omertron/themoviedbapi/tools/PostTools.java b/src/main/java/com/omertron/themoviedbapi/tools/PostTools.java index dfee4f1f6..ca2d777a6 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/PostTools.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/PostTools.java @@ -37,7 +37,11 @@ public class PostTools { private final Map values = new HashMap<>(); + /** + * Construct an empty set of values + */ public PostTools() { + // Create an empty set of values } public PostTools add(PostBody key, Object value) { diff --git a/src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java b/src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java index 30166563d..2cd88eb78 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/TmdbParameters.java @@ -39,6 +39,7 @@ public class TmdbParameters { * Construct an empty set of parameters */ public TmdbParameters() { + // Create an empty set of parameters } /** diff --git a/src/test/java/com/omertron/themoviedbapi/AbstractTests.java b/src/test/java/com/omertron/themoviedbapi/AbstractTests.java index 6e2b8bf47..52fdffb46 100644 --- a/src/test/java/com/omertron/themoviedbapi/AbstractTests.java +++ b/src/test/java/com/omertron/themoviedbapi/AbstractTests.java @@ -44,9 +44,9 @@ 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 String PROP_FILENAME = "testing.properties"; private static final String FILENAME_EXT = ".bin"; - private static final Properties props = new Properties(); + private static final Properties PROPS = new Properties(); private static HttpClient httpClient; private static HttpTools httpTools; // Session informaion @@ -57,6 +57,10 @@ public class AbstractTests { protected static final String LANGUAGE_ENGLISH = "en"; protected static final String LANGUAGE_RUSSIAN = "ru"; + protected AbstractTests() { + throw new UnsupportedOperationException("Utility class"); + } + /** * Do the initial configuration for the test cases * @@ -67,21 +71,21 @@ public class AbstractTests { httpClient = new SimpleHttpClientBuilder().build(); httpTools = new HttpTools(httpClient); - if (props.isEmpty()) { - File f = new File(PROP_FIlENAME); + if (PROPS.isEmpty()) { + File f = new File(PROP_FILENAME); if (f.exists()) { - LOG.info("Loading properties from '{}'", PROP_FIlENAME); - TestLogger.loadProperties(props, f); + LOG.info("Loading properties from '{}'", PROP_FILENAME); + TestLogger.loadProperties(PROPS, f); } else { - LOG.info("Property file '{}' not found, creating dummy file.", PROP_FIlENAME); + 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"); - props.setProperty("GuestSession", "INSERT_YOUR_GUEST_SESSION_ID_HERE"); + PROPS.setProperty("API_Key", "INSERT_YOUR_KEY_HERE"); + PROPS.setProperty("Username", "INSERT_YOUR_USERNAME_HERE"); + PROPS.setProperty("Password", "INSERT_YOUR_PASSWORD_HERE"); + PROPS.setProperty("GuestSession", "INSERT_YOUR_GUEST_SESSION_ID_HERE"); - TestLogger.saveProperties(props, f, "Properties file for tests"); - fail("Failed to get key information from properties file '" + PROP_FIlENAME + "'"); + TestLogger.saveProperties(PROPS, f, "Properties file for tests"); + fail("Failed to get key information from properties file '" + PROP_FILENAME + "'"); } } } @@ -225,7 +229,7 @@ public class AbstractTests { * @return */ protected static String getApiKey() { - return props.getProperty("API_Key"); + return PROPS.getProperty("API_Key"); } /** @@ -234,7 +238,7 @@ public class AbstractTests { * @return */ protected static String getUsername() { - return props.getProperty("Username"); + return PROPS.getProperty("Username"); } /** @@ -243,7 +247,7 @@ public class AbstractTests { * @return */ protected static String getPassword() { - return props.getProperty("Password"); + return PROPS.getProperty("Password"); } /** @@ -252,7 +256,7 @@ public class AbstractTests { * @return */ protected static String getGuestSession() { - return props.getProperty("GuestSession"); + return PROPS.getProperty("GuestSession"); } /** @@ -263,7 +267,7 @@ public class AbstractTests { */ protected static String getProperty(String property) { appendToResponseBuilder(MovieMethod.class); - return props.getProperty(property); + return PROPS.getProperty(property); } /** diff --git a/src/test/java/com/omertron/themoviedbapi/CompareTest.java b/src/test/java/com/omertron/themoviedbapi/CompareTest.java index 63ebd8287..d4a7662a9 100644 --- a/src/test/java/com/omertron/themoviedbapi/CompareTest.java +++ b/src/test/java/com/omertron/themoviedbapi/CompareTest.java @@ -21,10 +21,7 @@ package com.omertron.themoviedbapi; import com.omertron.themoviedbapi.model.movie.MovieInfo; 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; @@ -61,18 +58,6 @@ public class CompareTest { moviedb.setReleaseDate(YEAR_FULL); } - @AfterClass - public static void tearDownClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - /** * Exact match */ diff --git a/src/test/java/com/omertron/themoviedbapi/TestSuite.java b/src/test/java/com/omertron/themoviedbapi/TestSuite.java index 7f1ff94fc..dfb490d31 100644 --- a/src/test/java/com/omertron/themoviedbapi/TestSuite.java +++ b/src/test/java/com/omertron/themoviedbapi/TestSuite.java @@ -45,6 +45,11 @@ import static org.junit.Assert.assertTrue; public class TestSuite { + private static final String MISSING_NAME = ": Missing name"; + private static final String MISSING_POSTER = ": Missing poster"; + private static final String MISSING_TITLE = ": Missing title"; + private static final String MISSING_ID = ": Missing ID"; + private TestSuite() { throw new UnsupportedOperationException("Utility class"); } @@ -66,16 +71,16 @@ public class TestSuite { public static void test(MovieBasic test) { String message = test.getClass().getSimpleName(); - assertTrue(message + ": Missing title", isNotBlank(test.getTitle())); - assertTrue(message + ": Missing poster", isNotBlank(test.getPosterPath())); + assertTrue(message + MISSING_TITLE, isNotBlank(test.getTitle())); + assertTrue(message + MISSING_POSTER, isNotBlank(test.getPosterPath())); assertTrue(message + ": Missing release date", isNotBlank(test.getReleaseDate())); } public static void test(MovieInfo test) { String message = test.getClass().getSimpleName(); - assertTrue(message + ": Missing title", isNotBlank(test.getTitle())); + assertTrue(message + MISSING_TITLE, isNotBlank(test.getTitle())); assertTrue(message + ": Missing original title", isNotBlank(test.getOriginalTitle())); - assertTrue(message + ": Missing poster", isNotBlank(test.getPosterPath())); + assertTrue(message + MISSING_POSTER, isNotBlank(test.getPosterPath())); assertTrue(message + ": Missing release date", isNotBlank(test.getReleaseDate())); assertTrue(message + ": Missing backdrop", isNotBlank(test.getBackdropPath())); assertTrue(message + ": Missing poster path", isNotBlank(test.getPosterPath())); @@ -88,20 +93,20 @@ public class TestSuite { public static void test(UserList test) { String message = test.getClass().getSimpleName(); - assertTrue(message + ": Missing ID", isNotBlank(test.getId())); + assertTrue(message + MISSING_ID, isNotBlank(test.getId())); assertTrue(message + ": Missing Description", isNotBlank(test.getDescription())); } public static void test(TVBasic test) { String message = test.getClass().getSimpleName(); - assertTrue(message + ": Missing name", isNotBlank(test.getName())); - assertTrue(message + ": Missing poster", isNotBlank(test.getPosterPath())); + assertTrue(message + MISSING_NAME, isNotBlank(test.getName())); + assertTrue(message + MISSING_POSTER, isNotBlank(test.getPosterPath())); assertTrue(message + ": Missing first air date", isNotBlank(test.getFirstAirDate())); } public static void test(TVInfo test) { String message = test.getClass().getSimpleName(); - assertTrue(message + ": Missing ID", test.getId() > 0); + assertTrue(message + MISSING_ID, test.getId() > 0); assertFalse(message + ": Missing runtime", test.getEpisodeRunTime().isEmpty()); assertFalse(message + ": Missing genres", test.getGenres().isEmpty()); assertTrue(message + ": Missing season count", test.getNumberOfSeasons() > 0); @@ -110,8 +115,8 @@ public class TestSuite { public static void test(TVEpisodeInfo test) { String message = test.getClass().getSimpleName(); - assertTrue(message + ": Missing ID", test.getId() > 0); - assertTrue(message + ": Missing name", StringUtils.isNotBlank(test.getName())); + assertTrue(message + MISSING_ID, test.getId() > 0); + assertTrue(message + MISSING_NAME, StringUtils.isNotBlank(test.getName())); assertFalse(message + ": Missing crew", test.getCrew().isEmpty()); assertFalse(message + ": Missing guest stars", test.getGuestStars().isEmpty()); } @@ -121,7 +126,7 @@ public class TestSuite { assertTrue(message + ": Missing bio", StringUtils.isNotBlank(test.getBiography())); assertTrue(message + ": Missing birthday", StringUtils.isNotBlank(test.getBirthday())); assertTrue(message + ": Missing homepage", StringUtils.isNotBlank(test.getHomepage())); - assertTrue(message + ": Missing name", StringUtils.isNotBlank(test.getName())); + assertTrue(message + MISSING_NAME, StringUtils.isNotBlank(test.getName())); assertTrue(message + ": Missing birth place", StringUtils.isNotBlank(test.getPlaceOfBirth())); assertTrue(message + ": Missing artwork", StringUtils.isNotBlank(test.getProfilePath())); assertTrue(message + ": Missing bio", test.getPopularity() > 0F); @@ -129,8 +134,8 @@ public class TestSuite { public static void test(TVSeasonInfo test) { String message = test.getClass().getSimpleName(); - assertTrue(message + ": Missing ID", test.getId() > 0); - assertTrue(message + ": Missing name", StringUtils.isNotBlank(test.getName())); + assertTrue(message + MISSING_ID, test.getId() > 0); + assertTrue(message + MISSING_NAME, StringUtils.isNotBlank(test.getName())); assertTrue(message + ": Missing overview", StringUtils.isNotBlank(test.getOverview())); assertTrue(message + ": Missing episodes", test.getEpisodes().size() > 0); } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbAccountTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbAccountTest.java index c04960177..28a6b7a70 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbAccountTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbAccountTest.java @@ -31,12 +31,9 @@ import com.omertron.themoviedbapi.model.movie.MovieBasic; import com.omertron.themoviedbapi.model.tv.TVBasic; import com.omertron.themoviedbapi.results.ResultList; import java.util.concurrent.TimeUnit; -import org.junit.After; -import org.junit.AfterClass; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -46,6 +43,9 @@ import org.junit.Test; */ public class TmdbAccountTest extends AbstractTests { + private static final String RESULT = "Result: {}"; + private static final String INCORRECT_STATUS_CODE = "Incorrect status code"; + private static TmdbAccount instance; // Constants private static final int ID_MOVIE_FIGHT_CLUB = 550; @@ -60,18 +60,6 @@ public class TmdbAccountTest extends AbstractTests { instance = new TmdbAccount(getApiKey(), getHttpTools()); } - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() throws MovieDbException { - } - - @After - public void tearDown() throws MovieDbException { - } - /** * Test of getAccountId method, of class TmdbAccount. * @@ -95,7 +83,7 @@ public class TmdbAccountTest extends AbstractTests { public void testGetUserLists() throws MovieDbException { LOG.info("getUserLists"); ResultList results = instance.getUserLists(getSessionId(), getAccountId()); - TestSuite.test(results,"UserLists"); + TestSuite.test(results, "UserLists"); for (UserList result : results.getResults()) { TestSuite.test(result); @@ -111,7 +99,7 @@ public class TmdbAccountTest extends AbstractTests { public void testGetFavoriteMovies() throws MovieDbException { LOG.info("getFavoriteMovies"); ResultList results = instance.getFavoriteMovies(getSessionId(), getAccountId()); - TestSuite.test(results,"Fav Movies"); + TestSuite.test(results, "Fav Movies"); for (MovieBasic result : results.getResults()) { TestSuite.test(result); @@ -127,7 +115,7 @@ public class TmdbAccountTest extends AbstractTests { public void testGetFavoriteTv() throws MovieDbException { LOG.info("getFavoriteTv"); ResultList results = instance.getFavoriteTv(getSessionId(), getAccountId()); - TestSuite.test(results,"Fav TV"); + TestSuite.test(results, "Fav TV"); for (TVBasic result : results.getResults()) { TestSuite.test(result); @@ -145,23 +133,23 @@ public class TmdbAccountTest extends AbstractTests { // Add a movie as a favourite StatusCode result = instance.modifyFavoriteStatus(getSessionId(), getAccountId(), MediaType.MOVIE, ID_MOVIE_FIGHT_CLUB, true); - LOG.info("Result: {}", result); - assertTrue("Incorrect status code", result.getCode() == 1 || result.getCode() == 12); + LOG.info(RESULT, result); + assertTrue(INCORRECT_STATUS_CODE, result.getCode() == 1 || result.getCode() == 12); // Remove a movie as a favourite result = instance.modifyFavoriteStatus(getSessionId(), getAccountId(), MediaType.MOVIE, ID_MOVIE_FIGHT_CLUB, false); - LOG.info("Result: {}", result); - assertTrue("Incorrect status code", result.getCode() == 13); + LOG.info(RESULT, result); + assertTrue(INCORRECT_STATUS_CODE, result.getCode() == 13); // Add a TV Show as a favourite result = instance.modifyFavoriteStatus(getSessionId(), getAccountId(), MediaType.TV, ID_TV_WALKING_DEAD, true); - LOG.info("Result: {}", result); - assertTrue("Incorrect status code", result.getCode() == 1 || result.getCode() == 12); + LOG.info(RESULT, result); + assertTrue(INCORRECT_STATUS_CODE, result.getCode() == 1 || result.getCode() == 12); // Remove a TV Show as a favourite result = instance.modifyFavoriteStatus(getSessionId(), getAccountId(), MediaType.TV, ID_TV_WALKING_DEAD, false); - LOG.info("Result: {}", result); - assertTrue("Incorrect status code", result.getCode() == 13); + LOG.info(RESULT, result); + assertTrue(INCORRECT_STATUS_CODE, result.getCode() == 13); } /** @@ -173,7 +161,7 @@ public class TmdbAccountTest extends AbstractTests { public void testGetRatedMovies() throws MovieDbException { LOG.info("getRatedMovies"); ResultList results = instance.getRatedMovies(getSessionId(), getAccountId(), null, null, null); - TestSuite.test(results,"Rated Movies"); + TestSuite.test(results, "Rated Movies"); } /** @@ -185,7 +173,7 @@ public class TmdbAccountTest extends AbstractTests { public void testGetRatedTV() throws MovieDbException { LOG.info("getRatedTV"); ResultList results = instance.getRatedTV(getSessionId(), getAccountId(), null, null, null); - TestSuite.test(results,"Rated TV"); + TestSuite.test(results, "Rated TV"); for (TVBasic result : results.getResults()) { TestSuite.test(result); } @@ -200,7 +188,7 @@ public class TmdbAccountTest extends AbstractTests { public void testGetWatchListMovie() throws MovieDbException { LOG.info("getWatchListMovie"); ResultList results = instance.getWatchListMovie(getSessionId(), getAccountId(), null, null, null); - TestSuite.test(results,"Watch List Movie"); + TestSuite.test(results, "Watch List Movie"); for (MovieBasic result : results.getResults()) { TestSuite.test(result); } @@ -215,7 +203,7 @@ public class TmdbAccountTest extends AbstractTests { public void testGetWatchListTV() throws MovieDbException { LOG.info("getWatchListTV"); ResultList results = instance.getWatchListTV(getSessionId(), getAccountId(), null, null, null); - TestSuite.test(results,"Watch List TV"); + TestSuite.test(results, "Watch List TV"); for (TVBasic result : results.getResults()) { TestSuite.test(result); } @@ -232,23 +220,23 @@ public class TmdbAccountTest extends AbstractTests { // Add a movie to the watch list StatusCode result = instance.modifyWatchList(getSessionId(), getAccountId(), MediaType.MOVIE, ID_MOVIE_FIGHT_CLUB, true); - LOG.info("Result: {}", result); - assertTrue("Incorrect status code", result.getCode() == 1 || result.getCode() == 12); + LOG.info(RESULT, result); + assertTrue(INCORRECT_STATUS_CODE, result.getCode() == 1 || result.getCode() == 12); // Remove a movie from the watch list result = instance.modifyWatchList(getSessionId(), getAccountId(), MediaType.MOVIE, ID_MOVIE_FIGHT_CLUB, false); - LOG.info("Result: {}", result); - assertTrue("Incorrect status code", result.getCode() == 13); + LOG.info(RESULT, result); + assertTrue(INCORRECT_STATUS_CODE, result.getCode() == 13); // Add a TV Show to the watch list result = instance.modifyWatchList(getSessionId(), getAccountId(), MediaType.TV, ID_TV_WALKING_DEAD, true); - LOG.info("Result: {}", result); - assertTrue("Incorrect status code", result.getCode() == 1 || result.getCode() == 12); + LOG.info(RESULT, result); + assertTrue(INCORRECT_STATUS_CODE, result.getCode() == 1 || result.getCode() == 12); // Remove a TV Show from the watch list result = instance.modifyWatchList(getSessionId(), getAccountId(), MediaType.TV, ID_TV_WALKING_DEAD, false); - LOG.info("Result: {}", result); - assertTrue("Incorrect status code", result.getCode() == 13); + LOG.info(RESULT, result); + assertTrue(INCORRECT_STATUS_CODE, result.getCode() == 13); } /** @@ -284,7 +272,7 @@ public class TmdbAccountTest extends AbstractTests { result = instance.getGuestRatedMovies(guestSession, language, page, sortBy); } - TestSuite.test(result,"Guest Reated Movies"); + TestSuite.test(result, "Guest Reated Movies"); } private void postGuestRating(String guestSessionId, int movieId) throws MovieDbException { diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbAuthenticationTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbAuthenticationTest.java index 17f0fbec4..f6e426558 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbAuthenticationTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbAuthenticationTest.java @@ -24,12 +24,9 @@ import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.model.authentication.TokenAuthorisation; import com.omertron.themoviedbapi.model.authentication.TokenSession; 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.assertNotNull; import static org.junit.Assert.assertTrue; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; @@ -51,18 +48,6 @@ public class TmdbAuthenticationTest extends AbstractTests { instance = new TmdbAuthentication(getApiKey(), getHttpTools()); } - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - /** * Test of getAuthorisationToken method, of class TmdbAuthentication. * diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCertificationsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCertificationsTest.java index 57443100b..2d5699c96 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCertificationsTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCertificationsTest.java @@ -25,7 +25,6 @@ import com.omertron.themoviedbapi.model.Certification; import com.omertron.themoviedbapi.results.ResultsMap; import java.util.List; import java.util.Map; -import org.junit.AfterClass; import static org.junit.Assert.assertFalse; import org.junit.BeforeClass; import org.junit.Test; @@ -48,10 +47,6 @@ public class TmdbCertificationsTest extends AbstractTests { instance = new TmdbCertifications(getApiKey(), getHttpTools()); } - @AfterClass - public static void tearDownClass() { - } - /** * Test of getMoviesCertification method, of class TmdbCertifications. * diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbChangesTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbChangesTest.java index 017413355..9edbfffe4 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbChangesTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbChangesTest.java @@ -25,7 +25,6 @@ import com.omertron.themoviedbapi.TestSuite; import com.omertron.themoviedbapi.model.change.ChangeListItem; import com.omertron.themoviedbapi.results.ResultList; import com.omertron.themoviedbapi.tools.MethodBase; -import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -46,10 +45,6 @@ public class TmdbChangesTest extends AbstractTests { instance = new TmdbChanges(getApiKey(), getHttpTools()); } - @AfterClass - public static void tearDownClass() { - } - /** * Test of getChangeList(MOVIE) method, of class TmdbChanges. * diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCollectionsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCollectionsTest.java index d719203dd..1ed1ef844 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCollectionsTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCollectionsTest.java @@ -25,7 +25,6 @@ import com.omertron.themoviedbapi.TestSuite; import com.omertron.themoviedbapi.model.artwork.Artwork; import com.omertron.themoviedbapi.model.collection.CollectionInfo; import com.omertron.themoviedbapi.results.ResultList; -import org.junit.AfterClass; import static org.junit.Assert.assertFalse; import org.junit.BeforeClass; import org.junit.Test; @@ -48,10 +47,6 @@ public class TmdbCollectionsTest extends AbstractTests { instance = new TmdbCollections(getApiKey(), getHttpTools()); } - @AfterClass - public static void tearDownClass() { - } - /** * Test of getCollectionInfo method, of class TheMovieDbApi. * @@ -74,7 +69,7 @@ public class TmdbCollectionsTest extends AbstractTests { public void testGetCollectionImages() throws MovieDbException { LOG.info("getCollectionImages"); ResultList result = instance.getCollectionImages(ID_COLLECTION_STAR_WARS, LANGUAGE_DEFAULT); - TestSuite.test(result,"Collection Images"); + TestSuite.test(result, "Collection Images"); } } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCompaniesTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCompaniesTest.java index 2a029cc2e..012c37f7f 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCompaniesTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCompaniesTest.java @@ -25,11 +25,8 @@ import com.omertron.themoviedbapi.TestSuite; import com.omertron.themoviedbapi.model.company.Company; import com.omertron.themoviedbapi.model.movie.MovieBasic; import com.omertron.themoviedbapi.results.ResultList; -import org.junit.After; -import org.junit.AfterClass; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -51,18 +48,6 @@ public class TmdbCompaniesTest extends AbstractTests { 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. * @@ -85,6 +70,6 @@ public class TmdbCompaniesTest extends AbstractTests { public void testGetCompanyMovies() throws MovieDbException { LOG.info("getCompanyMovies"); ResultList result = instance.getCompanyMovies(ID_COMPANY, LANGUAGE_DEFAULT, 0); - TestSuite.test(result,"Company Movies"); + TestSuite.test(result, "Company Movies"); } } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbConfigurationTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbConfigurationTest.java index 19644bba1..e0c8d733d 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbConfigurationTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbConfigurationTest.java @@ -28,12 +28,9 @@ import com.omertron.themoviedbapi.results.ResultList; import com.omertron.themoviedbapi.results.ResultsMap; import java.util.List; 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.assertNotNull; import static org.junit.Assert.assertTrue; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -54,18 +51,6 @@ public class TmdbConfigurationTest extends AbstractTests { 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. * @@ -121,8 +106,8 @@ public class TmdbConfigurationTest extends AbstractTests { ResultsMap> result = instance.getTimezones(); assertNotNull("Null results", result); assertFalse("Empty results", result.isEmpty()); - assertTrue("No US TZ",result.containsKey("US")); - assertTrue("No GB TZ",result.containsKey("GB")); + assertTrue("No US TZ", result.containsKey("US")); + assertTrue("No GB TZ", result.containsKey("GB")); } } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCreditsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCreditsTest.java index 32b4c9694..99b4b97cc 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCreditsTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCreditsTest.java @@ -22,11 +22,8 @@ package com.omertron.themoviedbapi.methods; import com.omertron.themoviedbapi.AbstractTests; import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.model.person.CreditInfo; -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; @@ -47,18 +44,6 @@ public class TmdbCreditsTest extends AbstractTests { 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. * diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbDiscoverTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbDiscoverTest.java index aa101d7ab..1242cfb9d 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbDiscoverTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbDiscoverTest.java @@ -26,9 +26,6 @@ import com.omertron.themoviedbapi.model.discover.Discover; import com.omertron.themoviedbapi.model.movie.MovieBasic; import com.omertron.themoviedbapi.model.tv.TVBasic; import com.omertron.themoviedbapi.results.ResultList; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -49,18 +46,6 @@ public class TmdbDiscoverTest extends AbstractTests { 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. * diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbEpisodesTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbEpisodesTest.java index 7dd93df63..927bb33a6 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbEpisodesTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbEpisodesTest.java @@ -37,13 +37,10 @@ import com.omertron.themoviedbapi.model.tv.TVEpisodeInfo; import com.omertron.themoviedbapi.results.ResultList; import java.util.ArrayList; import java.util.List; -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.Test; @@ -55,6 +52,7 @@ public class TmdbEpisodesTest extends AbstractTests { private static TmdbEpisodes instance; private static final List TV_IDS = new ArrayList<>(); + private static final String TESTING = "Testing: {}"; public TmdbEpisodesTest() { } @@ -69,18 +67,6 @@ public class TmdbEpisodesTest extends AbstractTests { TV_IDS.add(new TestID("The Big Bang Theory", "tt0775431", 1418, "Kaley Cuoco")); } - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - /** * Test of getEpisodeInfo method, of class TmdbEpisodes. * @@ -96,7 +82,7 @@ public class TmdbEpisodesTest extends AbstractTests { String appendToResponse = appendToResponseBuilder(TVEpisodeMethod.class); for (TestID test : TV_IDS) { - LOG.info("Testing: {}", test); + LOG.info(TESTING, test); TVEpisodeInfo result = instance.getEpisodeInfo(test.getTmdb(), seasonNumber, episodeNumber, language, appendToResponse); TestSuite.test(result); TestSuite.testATR(result, TVEpisodeMethod.class, null); @@ -127,7 +113,7 @@ public class TmdbEpisodesTest extends AbstractTests { int episodeNumber = 1; for (TestID test : TV_IDS) { - LOG.info("Testing: {}", test); + LOG.info(TESTING, test); MediaState result = instance.getEpisodeAccountState(test.getTmdb(), seasonNumber, episodeNumber, getSessionId()); assertNotNull("Null result", result); assertTrue("Invalid rating", result.getRated() > -2f); @@ -147,7 +133,7 @@ public class TmdbEpisodesTest extends AbstractTests { int episodeNumber = 1; for (TestID test : TV_IDS) { - LOG.info("Testing: {}", test); + LOG.info(TESTING, test); MediaCreditList result = instance.getEpisodeCredits(test.getTmdb(), seasonNumber, episodeNumber); assertNotNull(result); assertFalse(result.getCast().isEmpty()); @@ -180,7 +166,7 @@ public class TmdbEpisodesTest extends AbstractTests { String language = LANGUAGE_DEFAULT; for (TestID test : TV_IDS) { - LOG.info("Testing: {}", test); + LOG.info(TESTING, test); ExternalID result = instance.getEpisodeExternalID(test.getTmdb(), seasonNumber, episodeNumber, language); assertEquals("Wrong IMDB ID", test.getImdb(), result.getImdbId()); } @@ -199,7 +185,7 @@ public class TmdbEpisodesTest extends AbstractTests { int episodeNumber = 1; for (TestID test : TV_IDS) { - LOG.info("Testing: {}", test); + LOG.info(TESTING, test); ArtworkResults results = new ArtworkResults(); ResultList result = instance.getEpisodeImages(test.getTmdb(), seasonNumber, episodeNumber); assertFalse("No artwork", result.isEmpty()); @@ -227,7 +213,7 @@ public class TmdbEpisodesTest extends AbstractTests { String guestSessionID = null; for (TestID test : TV_IDS) { - LOG.info("Testing: {}", test); + LOG.info(TESTING, test); int rating = TestSuite.randomRating(); StatusCode result = instance.postEpisodeRating(test.getTmdb(), seasonNumber, episodeNumber, rating, getSessionId(), guestSessionID); assertEquals("failed to post rating", 12, result.getCode()); diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbFindTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbFindTest.java index 58f38fb52..61be8e096 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbFindTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbFindTest.java @@ -28,9 +28,6 @@ import com.omertron.themoviedbapi.model.FindResults; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -45,6 +42,7 @@ public class TmdbFindTest extends AbstractTests { private static final List PERSON_IDS = new ArrayList<>(); private static final List FILM_IDS = new ArrayList<>(); private static final List TV_IDS = new ArrayList<>(); + private static final String TESTING = "Testing {}"; public TmdbFindTest() { } @@ -64,18 +62,6 @@ public class TmdbFindTest extends AbstractTests { TV_IDS.add(new TestID("Supernatural", "tt0460681", 1622)); } - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - /** * Test of Find Movie * @@ -87,7 +73,7 @@ public class TmdbFindTest extends AbstractTests { FindResults result; for (TestID test : FILM_IDS) { - LOG.info("Testing {}", test); + LOG.info(TESTING, test); result = instance.find(test.getImdb(), ExternalSource.IMDB_ID, LANGUAGE_DEFAULT); TestSuite.test(result.getMovieResults(), "Movies IMDB"); TestSuite.testId(result.getMovieResults(), test.getTmdb(), "Movie"); @@ -106,7 +92,7 @@ public class TmdbFindTest extends AbstractTests { FindResults result; for (TestID test : PERSON_IDS) { - LOG.info("Testing {}", test); + LOG.info(TESTING, test); result = instance.find(test.getImdb(), ExternalSource.IMDB_ID, LANGUAGE_DEFAULT); TestSuite.test(result.getPersonResults(), "Person IMDB"); TestSuite.testId(result.getPersonResults(), test.getTmdb(), "Person"); @@ -124,7 +110,7 @@ public class TmdbFindTest extends AbstractTests { FindResults result; for (TestID test : TV_IDS) { - LOG.info("Testing {}", test); + LOG.info(TESTING, test); result = instance.find(test.getImdb(), ExternalSource.IMDB_ID, LANGUAGE_DEFAULT); TestSuite.test(result.getTvResults(), "TV IMDB"); TestSuite.testId(result.getTvResults(), test.getTmdb(), "TV"); diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbGenresTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbGenresTest.java index 99d23a89d..dadfcdc89 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbGenresTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbGenresTest.java @@ -24,11 +24,8 @@ import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.movie.MovieBasic; import com.omertron.themoviedbapi.results.ResultList; -import org.junit.After; -import org.junit.AfterClass; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -39,6 +36,8 @@ import org.junit.Test; public class TmdbGenresTest extends AbstractTests { private static TmdbGenres instance; + private static final String LIST_IS_EMPTY = "List is empty"; + private static final String LIST_IS_NULL = "List is null"; private static final int ID_GENRE_ACTION = 28; public TmdbGenresTest() { @@ -50,18 +49,6 @@ public class TmdbGenresTest extends AbstractTests { instance = new TmdbGenres(getApiKey(), getHttpTools()); } - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - /** * Test of getGenreMovieList method, of class TmdbGenres. * @@ -71,8 +58,8 @@ public class TmdbGenresTest extends AbstractTests { public void testGetGenreMovieList() throws MovieDbException { LOG.info("getGenreMovieList"); ResultList result = instance.getGenreMovieList(LANGUAGE_DEFAULT); - assertNotNull("List is null", result.getResults()); - assertFalse("List is empty", result.getResults().isEmpty()); + assertNotNull(LIST_IS_NULL, result.getResults()); + assertFalse(LIST_IS_EMPTY, result.getResults().isEmpty()); } /** @@ -84,8 +71,8 @@ public class TmdbGenresTest extends AbstractTests { public void testGetGenreTVList() throws MovieDbException { LOG.info("getGenreTVList"); ResultList result = instance.getGenreTVList(LANGUAGE_DEFAULT); - assertNotNull("List is null", result.getResults()); - assertFalse("List is empty", result.getResults().isEmpty()); + assertNotNull(LIST_IS_NULL, result.getResults()); + assertFalse(LIST_IS_EMPTY, result.getResults().isEmpty()); } /** @@ -100,8 +87,8 @@ public class TmdbGenresTest extends AbstractTests { Boolean includeAllMovies = null; Boolean includeAdult = null; ResultList result = instance.getGenreMovies(ID_GENRE_ACTION, LANGUAGE_DEFAULT, page, includeAllMovies, includeAdult); - assertNotNull("List is null", result); - assertFalse("List is empty", result.isEmpty()); + assertNotNull(LIST_IS_NULL, result); + assertFalse(LIST_IS_EMPTY, result.isEmpty()); } } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbKeywordsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbKeywordsTest.java index 4c88bd28c..daaaf70d7 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbKeywordsTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbKeywordsTest.java @@ -25,10 +25,7 @@ import com.omertron.themoviedbapi.TestSuite; import com.omertron.themoviedbapi.model.keyword.Keyword; import com.omertron.themoviedbapi.model.movie.MovieBasic; import com.omertron.themoviedbapi.results.ResultList; -import org.junit.After; -import org.junit.AfterClass; import static org.junit.Assert.assertEquals; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -50,18 +47,6 @@ public class TmdbKeywordsTest extends AbstractTests { 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. * diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbListsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbListsTest.java index ca5c84cce..20113d952 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbListsTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbListsTest.java @@ -25,12 +25,9 @@ import com.omertron.themoviedbapi.model.StatusCode; import com.omertron.themoviedbapi.model.list.ListItem; import java.util.Random; 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.assertTrue; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; @@ -39,6 +36,8 @@ import org.junit.rules.ExpectedException; public class TmdbListsTest extends AbstractTests { private static TmdbLists instance; + private static final String RESULT = "Result: {}"; + private static final String INVALID_RESPONSE = "Invalid response: "; private static final int ID_JUPITER_ASCENDING = 76757; private static final int ID_BIG_HERO_6 = 177572; // Status codes @@ -57,18 +56,6 @@ public class TmdbListsTest extends AbstractTests { instance = new TmdbLists(getApiKey(), getHttpTools()); } - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - @Test public void testSuite() throws MovieDbException { // Test the list creation @@ -144,12 +131,12 @@ public class TmdbListsTest extends AbstractTests { private void testDeleteList(String listId) throws MovieDbException { LOG.info("deleteList"); StatusCode result = instance.deleteList(getSessionId(), listId); - LOG.info("Result: {}", result); + LOG.info(RESULT, result); // We expect there to be an exception thrown here exception.expect(MovieDbException.class); ListItem result2 = instance.getList(listId); - LOG.info("Result: {}", result2); + LOG.info(RESULT, result2); } /** @@ -160,7 +147,7 @@ public class TmdbListsTest extends AbstractTests { private void testAddItem(String listId, int mediaId) throws MovieDbException { LOG.info("addItem"); StatusCode result = instance.addItem(getSessionId(), listId, mediaId); - assertEquals("Invalid response: " + result.toString(), SC_SUCCESS_UPD, result.getCode()); + assertEquals(INVALID_RESPONSE + result.toString(), SC_SUCCESS_UPD, result.getCode()); } /** @@ -171,7 +158,7 @@ public class TmdbListsTest extends AbstractTests { private void testRemoveItem(String listId, int mediaId) throws MovieDbException { LOG.info("removeItem"); StatusCode result = instance.removeItem(getSessionId(), listId, mediaId); - assertEquals("Invalid response: " + result.toString(), SC_SUCCESS_DEL, result.getCode()); + assertEquals(INVALID_RESPONSE + result.toString(), SC_SUCCESS_DEL, result.getCode()); } /** @@ -182,7 +169,7 @@ public class TmdbListsTest extends AbstractTests { private void testClear(String listId) throws MovieDbException { LOG.info("clear"); StatusCode result = instance.clear(getSessionId(), listId, true); - assertEquals("Invalid response: " + result.toString(), SC_SUCCESS_UPD, result.getCode()); + assertEquals(INVALID_RESPONSE + result.toString(), SC_SUCCESS_UPD, result.getCode()); } } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java index 194792946..3bdf87338 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbMoviesTest.java @@ -64,6 +64,7 @@ public class TmdbMoviesTest extends AbstractTests { private static TmdbMovies instance; private static final List FILM_IDS = new ArrayList<>(); + private static final String WRONG_TITLE = "Wrong title"; public TmdbMoviesTest() { } @@ -99,7 +100,7 @@ public class TmdbMoviesTest extends AbstractTests { MovieInfo result = instance.getMovieInfo(test.getTmdb(), language, appendToResponse); assertEquals("Wrong IMDB ID", test.getImdb(), result.getImdbID()); - assertEquals("Wrong title", test.getName(), result.getTitle()); + assertEquals(WRONG_TITLE, test.getName(), result.getTitle()); TestSuite.test(result); TestSuite.testATR(result, MovieMethod.class, MovieMethod.CHANGES); TestSuite.test(result.getAlternativeTitles(), "Alt titles"); @@ -132,7 +133,7 @@ public class TmdbMoviesTest extends AbstractTests { for (TestID test : FILM_IDS) { MovieInfo result = instance.getMovieInfo(test.getTmdb(), language, appendToResponse); assertEquals("Wrong IMDB ID", test.getImdb(), result.getImdbID()); - assertEquals("Wrong title", test.getName(), result.getTitle()); + assertEquals(WRONG_TITLE, test.getName(), result.getTitle()); TestSuite.test(result); } } @@ -151,7 +152,7 @@ public class TmdbMoviesTest extends AbstractTests { for (TestID test : FILM_IDS) { MovieInfo result = instance.getMovieInfoImdb(test.getImdb(), language, appendToResponse); assertEquals("Wrong TMDB ID", test.getTmdb(), result.getId()); - assertEquals("Wrong title", test.getName(), result.getTitle()); + assertEquals(WRONG_TITLE, test.getName(), result.getTitle()); TestSuite.test(result); } } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbNetworksTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbNetworksTest.java index a7b541b52..07b90445e 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbNetworksTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbNetworksTest.java @@ -25,7 +25,6 @@ import com.omertron.themoviedbapi.TestID; import com.omertron.themoviedbapi.model.network.Network; import java.util.ArrayList; import java.util.List; -import org.junit.AfterClass; import static org.junit.Assert.assertEquals; import org.junit.BeforeClass; import org.junit.Test; @@ -37,7 +36,7 @@ import org.junit.Test; public class TmdbNetworksTest extends AbstractTests { private static TmdbNetworks instance; - private static final List testIDs = new ArrayList<>(); + private static final List TEST_IDS = new ArrayList<>(); public TmdbNetworksTest() { } @@ -46,12 +45,8 @@ public class TmdbNetworksTest extends AbstractTests { public static void setUpClass() throws MovieDbException { doConfiguration(); instance = new TmdbNetworks(getApiKey(), getHttpTools()); - testIDs.add(new TestID("Fuji Television", "", 1)); - testIDs.add(new TestID("Sonshine Media Network International", "", 200)); - } - - @AfterClass - public static void tearDownClass() { + TEST_IDS.add(new TestID("Fuji Television", "", 1)); + TEST_IDS.add(new TestID("Sonshine Media Network International", "", 200)); } /** @@ -64,7 +59,7 @@ public class TmdbNetworksTest extends AbstractTests { LOG.info("getNetworkInfo"); Network result; - for (TestID t : testIDs) { + for (TestID t : TEST_IDS) { result = instance.getNetworkInfo(t.getTmdb()); assertEquals("Wrong network returned", t.getName(), result.getName()); } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbPeopleTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbPeopleTest.java index 36d992800..8db7c88d0 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbPeopleTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbPeopleTest.java @@ -45,13 +45,10 @@ import java.util.Date; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateUtils; -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.Test; @@ -63,6 +60,9 @@ public class TmdbPeopleTest extends AbstractTests { private static TmdbPeople instance; private static final List TEST_IDS = new ArrayList<>(); + private static final String NO_TITLE = "No title"; + private static final String INCORRECT_ID = "Incorrect ID"; + private static final String ID_CAST_CREW = "ID: {}, # Cast: {}, # Crew: {}"; public TmdbPeopleTest() { } @@ -75,18 +75,6 @@ public class TmdbPeopleTest extends AbstractTests { TEST_IDS.add(new TestID("Will Smith", "nm0000226", 2888)); } - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - /** * Test of Append_To_Response method, of class TmdbPeople. * @@ -142,14 +130,14 @@ public class TmdbPeopleTest extends AbstractTests { for (TestID test : TEST_IDS) { PersonCreditList result = instance.getPersonMovieCredits(test.getTmdb(), language); - LOG.info("ID: {}, # Cast: {}, # Crew: {}", result.getId(), result.getCast().size(), result.getCrew().size()); - assertEquals("Incorrect ID", test.getTmdb(), result.getId()); + LOG.info(ID_CAST_CREW, result.getId(), result.getCast().size(), result.getCrew().size()); + assertEquals(INCORRECT_ID, test.getTmdb(), result.getId()); TestSuite.test(result.getCast(), "Cast"); TestSuite.test(result.getCrew(), "Crew"); // Check that we have the movie specific fields - assertTrue("No title", StringUtils.isNotBlank(result.getCast().get(0).getTitle())); - assertTrue("No title", StringUtils.isNotBlank(result.getCrew().get(0).getTitle())); + assertTrue(NO_TITLE, StringUtils.isNotBlank(result.getCast().get(0).getTitle())); + assertTrue(NO_TITLE, StringUtils.isNotBlank(result.getCrew().get(0).getTitle())); } } @@ -165,14 +153,14 @@ public class TmdbPeopleTest extends AbstractTests { for (TestID test : TEST_IDS) { PersonCreditList result = instance.getPersonTVCredits(test.getTmdb(), language); - LOG.info("ID: {}, # Cast: {}, # Crew: {}", result.getId(), result.getCast().size(), result.getCrew().size()); - assertEquals("Incorrect ID", test.getTmdb(), result.getId()); + LOG.info(ID_CAST_CREW, result.getId(), result.getCast().size(), result.getCrew().size()); + assertEquals(INCORRECT_ID, test.getTmdb(), result.getId()); TestSuite.test(result.getCast(), "Cast"); TestSuite.test(result.getCrew(), "Crew"); // Check that we have the TV specific fields - assertTrue("No title", StringUtils.isNotBlank(result.getCast().get(0).getName())); - assertTrue("No title", StringUtils.isNotBlank(result.getCrew().get(0).getName())); + assertTrue(NO_TITLE, StringUtils.isNotBlank(result.getCast().get(0).getName())); + assertTrue(NO_TITLE, StringUtils.isNotBlank(result.getCrew().get(0).getName())); } } @@ -188,8 +176,8 @@ public class TmdbPeopleTest extends AbstractTests { for (TestID test : TEST_IDS) { PersonCreditList result = instance.getPersonCombinedCredits(test.getTmdb(), language); - LOG.info("ID: {}, # Cast: {}, # Crew: {}", result.getId(), result.getCast().size(), result.getCrew().size()); - assertEquals("Incorrect ID", test.getTmdb(), result.getId()); + LOG.info(ID_CAST_CREW, result.getId(), result.getCast().size(), result.getCrew().size()); + assertEquals(INCORRECT_ID, test.getTmdb(), result.getId()); TestSuite.test(result.getCast(), "Cast"); TestSuite.test(result.getCrew(), "Crew"); @@ -219,7 +207,7 @@ public class TmdbPeopleTest extends AbstractTests { for (CreditBasic p : result.getCrew()) { if (!checkedMovie && p.getMediaType() == MediaType.MOVIE) { CreditMovieBasic c = (CreditMovieBasic) p; - assertTrue("No title", StringUtils.isNotBlank(c.getTitle())); + assertTrue(NO_TITLE, StringUtils.isNotBlank(c.getTitle())); assertTrue("No department", StringUtils.isNotBlank(c.getDepartment())); checkedMovie = true; } diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbReviewsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbReviewsTest.java index 6d8aefda3..227c5cad6 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbReviewsTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbReviewsTest.java @@ -23,12 +23,9 @@ import com.omertron.themoviedbapi.AbstractTests; import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.model.review.Review; 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.assertNotNull; import static org.junit.Assert.assertTrue; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -49,18 +46,6 @@ public class TmdbReviewsTest extends AbstractTests { 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. * diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbSeasonsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbSeasonsTest.java index b55462324..0768244b6 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbSeasonsTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbSeasonsTest.java @@ -36,12 +36,9 @@ import com.omertron.themoviedbapi.model.tv.TVSeasonInfo; import com.omertron.themoviedbapi.results.ResultList; import java.util.ArrayList; import java.util.List; -import org.junit.After; -import org.junit.AfterClass; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -53,6 +50,7 @@ public class TmdbSeasonsTest extends AbstractTests { private static TmdbSeasons instance; private static final List TV_IDS = new ArrayList<>(); + private static final String TESTING = "Testing: {}"; public TmdbSeasonsTest() { } @@ -67,18 +65,6 @@ public class TmdbSeasonsTest extends AbstractTests { TV_IDS.add(new TestID("The Big Bang Theory", "tt0898266", 1418, "Kaley Cuoco")); } - @AfterClass - public static void tearDownClass() { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - /** * Test of getSeasonInfo method, of class TmdbSeasons. * @@ -93,7 +79,7 @@ public class TmdbSeasonsTest extends AbstractTests { String appendToResponse = appendToResponseBuilder(TVSeasonMethod.class); for (TestID test : TV_IDS) { - LOG.info("Testing: {}", test); + LOG.info(TESTING, test); TVSeasonInfo result = instance.getSeasonInfo(test.getTmdb(), seasonNumber, language, appendToResponse); TestSuite.test(result); TestSuite.testATR(result, TVSeasonMethod.class, null); @@ -125,7 +111,7 @@ public class TmdbSeasonsTest extends AbstractTests { LOG.info("getSeasonAccountState"); for (TestID test : TV_IDS) { - LOG.info("Testing: {}", test); + LOG.info(TESTING, test); MediaState result = instance.getSeasonAccountState(test.getTmdb(), getSessionId()); TestSuite.test(result); } @@ -143,7 +129,7 @@ public class TmdbSeasonsTest extends AbstractTests { int seasonNumber = 0; for (TestID test : TV_IDS) { - LOG.info("Testing: {}", test); + LOG.info(TESTING, test); MediaCreditList result = instance.getSeasonCredits(test.getTmdb(), seasonNumber); assertNotNull(result); @@ -177,7 +163,7 @@ public class TmdbSeasonsTest extends AbstractTests { String language = LANGUAGE_DEFAULT; for (TestID test : TV_IDS) { - LOG.info("Testing: {}", test); + LOG.info(TESTING, test); ExternalID result = instance.getSeasonExternalID(test.getTmdb(), seasonNumber, language); assertEquals("Wrong IMDB ID", test.getImdb(), result.getImdbId()); } @@ -199,7 +185,7 @@ public class TmdbSeasonsTest extends AbstractTests { ArtworkResults results = new ArtworkResults(); for (TestID test : TV_IDS) { - LOG.info("Testing: {}", test); + LOG.info(TESTING, test); ResultList result = instance.getSeasonImages(test.getTmdb(), seasonNumber, language, includeImageLanguage); TestSuite.test(result, "Artwork"); for (Artwork artwork : result.getResults()) { @@ -225,7 +211,7 @@ public class TmdbSeasonsTest extends AbstractTests { boolean found = false; for (TestID test : TV_IDS) { - LOG.info("Testing: {}", test); + LOG.info(TESTING, test); ResultList