Fixed guest sessions ratings
This commit is contained in:
@@ -58,7 +58,8 @@ public class TmdbAccount extends AbstractMethod {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the basic information for an account. You will need to have a valid session id.
|
||||
* Get the basic information for an account. You will need to have a valid
|
||||
* session id.
|
||||
*
|
||||
* @param sessionId
|
||||
* @return
|
||||
@@ -302,7 +303,14 @@ public class TmdbAccount extends AbstractMethod {
|
||||
parameters.add(Param.PAGE, page);
|
||||
//TODO: Test this works
|
||||
if (sortBy != null) {
|
||||
parameters.add(Param.SORT_BY, sortBy.getPropertyString());
|
||||
// Only created_at is supported
|
||||
parameters.add(Param.SORT_BY, "created_at");
|
||||
|
||||
if (sortBy.getPropertyString().endsWith("asc")) {
|
||||
parameters.add(Param.SORT_ORDER, "asc");
|
||||
} else {
|
||||
parameters.add(Param.SORT_ORDER, "desc");
|
||||
}
|
||||
}
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.GUEST_SESSION).subMethod(MethodSub.RATED_MOVIES_GUEST).buildUrl(parameters);
|
||||
|
||||
@@ -66,6 +66,7 @@ public enum Param {
|
||||
RELEASE_DATE_GTE("release_date.gte="),
|
||||
RELEASE_DATE_LTE("release_date.lte="),
|
||||
SORT_BY("sort_by="),
|
||||
SORT_ORDER("sort_order="),
|
||||
VOTE_AVERAGE_GTE("vote_average.gte="),
|
||||
VOTE_AVERAGE_LTE("vote_average.lte="),
|
||||
VOTE_COUNT_GTE("vote_count.gte="),
|
||||
|
||||
@@ -76,6 +76,7 @@ public class AbstractTests {
|
||||
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 + "'");
|
||||
@@ -243,6 +244,15 @@ public class AbstractTests {
|
||||
return props.getProperty("Password");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Guest Session ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String getGuestSession() {
|
||||
return props.getProperty("GuestSession");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the named property
|
||||
*
|
||||
|
||||
@@ -25,18 +25,18 @@ import com.omertron.themoviedbapi.enumeration.MediaType;
|
||||
import com.omertron.themoviedbapi.enumeration.SortBy;
|
||||
import com.omertron.themoviedbapi.model.StatusCode;
|
||||
import com.omertron.themoviedbapi.model.account.Account;
|
||||
import com.omertron.themoviedbapi.model.authentication.TokenSession;
|
||||
import com.omertron.themoviedbapi.model.list.UserList;
|
||||
import com.omertron.themoviedbapi.model.movie.MovieBasic;
|
||||
import com.omertron.themoviedbapi.model.tv.TVBasic;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@@ -78,7 +78,7 @@ public class TmdbAccountTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
@Test
|
||||
//@Test
|
||||
public void testGetAccount() throws MovieDbException {
|
||||
LOG.info("getAccount");
|
||||
Account result = instance.getAccount(getSessionId());
|
||||
@@ -92,7 +92,7 @@ public class TmdbAccountTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
@Test
|
||||
//@Test
|
||||
public void testGetUserLists() throws MovieDbException {
|
||||
LOG.info("getUserLists");
|
||||
List<UserList> results = instance.getUserLists(getSessionId(), getAccountId());
|
||||
@@ -108,7 +108,7 @@ public class TmdbAccountTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
@Test
|
||||
//@Test
|
||||
public void testGetFavoriteMovies() throws MovieDbException {
|
||||
LOG.info("getFavoriteMovies");
|
||||
List<MovieBasic> results = instance.getFavoriteMovies(getSessionId(), getAccountId());
|
||||
@@ -124,7 +124,7 @@ public class TmdbAccountTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
@Test
|
||||
//@Test
|
||||
public void testGetFavoriteTv() throws MovieDbException {
|
||||
LOG.info("getFavoriteTv");
|
||||
List<TVBasic> results = instance.getFavoriteTv(getSessionId(), getAccountId());
|
||||
@@ -140,7 +140,7 @@ public class TmdbAccountTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
@Test
|
||||
//@Test
|
||||
public void testModifyFavoriteStatus() throws MovieDbException {
|
||||
LOG.info("modifyFavoriteStatus");
|
||||
|
||||
@@ -170,7 +170,7 @@ public class TmdbAccountTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
@Test
|
||||
//@Test
|
||||
public void testGetRatedMovies() throws MovieDbException {
|
||||
LOG.info("getRatedMovies");
|
||||
List<MovieBasic> results = instance.getRatedMovies(getSessionId(), getAccountId(), null, null, null);
|
||||
@@ -183,7 +183,7 @@ public class TmdbAccountTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
@Test
|
||||
//@Test
|
||||
public void testGetRatedTV() throws MovieDbException {
|
||||
LOG.info("getRatedTV");
|
||||
List<TVBasic> results = instance.getRatedTV(getSessionId(), getAccountId(), null, null, null);
|
||||
@@ -199,7 +199,7 @@ public class TmdbAccountTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
@Test
|
||||
//@Test
|
||||
public void testGetWatchListMovie() throws MovieDbException {
|
||||
LOG.info("getWatchListMovie");
|
||||
List<MovieBasic> results = instance.getWatchListMovie(getSessionId(), getAccountId(), null, null, null);
|
||||
@@ -215,7 +215,7 @@ public class TmdbAccountTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
@Test
|
||||
//@Test
|
||||
public void testGetWatchListTV() throws MovieDbException {
|
||||
LOG.info("getWatchListTV");
|
||||
List<TVBasic> results = instance.getWatchListTV(getSessionId(), getAccountId(), null, null, null);
|
||||
@@ -231,7 +231,7 @@ public class TmdbAccountTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
@Test
|
||||
//@Test
|
||||
public void testModifyWatchList() throws MovieDbException {
|
||||
LOG.info("modifyWatchList");
|
||||
|
||||
@@ -265,16 +265,44 @@ public class TmdbAccountTest extends AbstractTests {
|
||||
public void testGetGuestRatedMovies() throws MovieDbException {
|
||||
LOG.info("getGuestRatedMovies");
|
||||
|
||||
//TODO: Need to use rated movies with the guest session to add some movies to get
|
||||
TmdbAuthentication auth = new TmdbAuthentication(getApiKey(), getHttpTools());
|
||||
TokenSession guestToken = auth.getGuestSessionToken();
|
||||
TmdbMovies tmdbM = new TmdbMovies(getApiKey(), getHttpTools());
|
||||
// Get the guest token
|
||||
String guestSession = getGuestSession();
|
||||
|
||||
String language = LANGUAGE_DEFAULT;
|
||||
Integer page = null;
|
||||
SortBy sortBy = null;
|
||||
List<MovieBasic> result = instance.getGuestRatedMovies(guestToken.getGuestSessionId(), language, page, sortBy);
|
||||
LOG.info("{}", result);
|
||||
fail("Need rated movies");
|
||||
SortBy sortBy = SortBy.CREATED_AT_ASC;
|
||||
List<MovieBasic> result = instance.getGuestRatedMovies(guestSession, language, page, sortBy);
|
||||
|
||||
// Check and post some ratings if required
|
||||
if (result.isEmpty()) {
|
||||
postGuestRating(guestSession, ID_MOVIE_FIGHT_CLUB);
|
||||
postGuestRating(guestSession, 78);
|
||||
postGuestRating(guestSession, 76757);
|
||||
postGuestRating(guestSession, 240832);
|
||||
try {
|
||||
Thread.sleep(TimeUnit.SECONDS.toMillis(5));
|
||||
} catch (InterruptedException ex) {
|
||||
LOG.trace("Interrupted");
|
||||
}
|
||||
|
||||
// Get the movie list again
|
||||
result = instance.getGuestRatedMovies(guestSession, language, page, sortBy);
|
||||
}
|
||||
|
||||
for (MovieBasic mb : result) {
|
||||
LOG.info("{}", mb);
|
||||
}
|
||||
|
||||
assertFalse("No movies found!", result.isEmpty());
|
||||
}
|
||||
|
||||
private void postGuestRating(String guestSessionId, int movieId) throws MovieDbException {
|
||||
TmdbMovies tmdbMovies = new TmdbMovies(getApiKey(), getHttpTools());
|
||||
Integer rating = new Random().nextInt(10) + 1;
|
||||
|
||||
LOG.info("Posting rating of '{}' to ID {} for guest session '{}'", rating, movieId, guestSessionId);
|
||||
StatusCode sc = tmdbMovies.postMovieRating(movieId, rating, null, guestSessionId);
|
||||
LOG.info("{}", sc);
|
||||
assertTrue("Failed to post rating", sc.getCode() == 1 || sc.getCode() == 12);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,6 @@ import com.omertron.themoviedbapi.MovieDbException;
|
||||
import com.omertron.themoviedbapi.TestID;
|
||||
import com.omertron.themoviedbapi.enumeration.ArtworkType;
|
||||
import com.omertron.themoviedbapi.model.StatusCode;
|
||||
import com.omertron.themoviedbapi.model.movie.MovieDb;
|
||||
import com.omertron.themoviedbapi.model.movie.ReleaseInfo;
|
||||
import com.omertron.themoviedbapi.model.movie.Translation;
|
||||
import com.omertron.themoviedbapi.model.movie.Video;
|
||||
import com.omertron.themoviedbapi.model.artwork.Artwork;
|
||||
import com.omertron.themoviedbapi.model.change.ChangeKeyItem;
|
||||
import com.omertron.themoviedbapi.model.change.ChangeListItem;
|
||||
@@ -39,6 +35,10 @@ import com.omertron.themoviedbapi.model.media.MediaCreditCast;
|
||||
import com.omertron.themoviedbapi.model.media.MediaCreditList;
|
||||
import com.omertron.themoviedbapi.model.media.MediaState;
|
||||
import com.omertron.themoviedbapi.model.movie.AlternativeTitle;
|
||||
import com.omertron.themoviedbapi.model.movie.MovieDb;
|
||||
import com.omertron.themoviedbapi.model.movie.ReleaseInfo;
|
||||
import com.omertron.themoviedbapi.model.movie.Translation;
|
||||
import com.omertron.themoviedbapi.model.movie.Video;
|
||||
import com.omertron.themoviedbapi.model.review.Review;
|
||||
import com.omertron.themoviedbapi.results.TmdbResultsList;
|
||||
import com.omertron.themoviedbapi.tools.MethodBase;
|
||||
@@ -85,7 +85,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetMovieInfo() throws MovieDbException {
|
||||
LOG.info("getMovieInfo");
|
||||
|
||||
@@ -105,7 +105,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetMovieInfoImdb() throws MovieDbException {
|
||||
LOG.info("getMovieInfoImdb");
|
||||
String language = LANGUAGE_DEFAULT;
|
||||
@@ -123,7 +123,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetMovieAccountState() throws MovieDbException {
|
||||
LOG.info("getMovieAccountState");
|
||||
|
||||
@@ -139,7 +139,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetMovieAlternativeTitles() throws MovieDbException {
|
||||
LOG.info("getMovieAlternativeTitles");
|
||||
|
||||
@@ -157,7 +157,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetMovieCredits() throws MovieDbException {
|
||||
LOG.info("getMovieCredits");
|
||||
|
||||
@@ -187,7 +187,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetMovieImages() throws MovieDbException {
|
||||
LOG.info("getMovieImages");
|
||||
|
||||
@@ -222,7 +222,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetMovieKeywords() throws MovieDbException {
|
||||
LOG.info("getMovieKeywords");
|
||||
|
||||
@@ -239,7 +239,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetMovieReleaseInfo() throws MovieDbException {
|
||||
LOG.info("getMovieReleaseInfo");
|
||||
|
||||
@@ -257,7 +257,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetMovieVideos() throws MovieDbException {
|
||||
LOG.info("getMovieVideos");
|
||||
|
||||
@@ -275,7 +275,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetMovieTranslations() throws MovieDbException {
|
||||
LOG.info("getMovieTranslations");
|
||||
|
||||
@@ -292,7 +292,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetSimilarMovies() throws MovieDbException {
|
||||
LOG.info("getSimilarMovies");
|
||||
|
||||
@@ -334,7 +334,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetMovieLists() throws MovieDbException {
|
||||
LOG.info("getMovieLists");
|
||||
|
||||
@@ -354,7 +354,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetMovieChanges() throws MovieDbException {
|
||||
LOG.info("getMovieChanges");
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
@@ -385,7 +385,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testPostMovieRating() throws MovieDbException {
|
||||
LOG.info("postMovieRating");
|
||||
Integer rating = new Random().nextInt(10) + 1;
|
||||
@@ -401,7 +401,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetLatestMovie() throws MovieDbException {
|
||||
LOG.info("getLatestMovie");
|
||||
|
||||
@@ -416,7 +416,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetUpcoming() throws MovieDbException {
|
||||
LOG.info("getUpcoming");
|
||||
Integer page = null;
|
||||
@@ -431,7 +431,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetNowPlayingMovies() throws MovieDbException {
|
||||
LOG.info("getNowPlayingMovies");
|
||||
Integer page = null;
|
||||
@@ -446,7 +446,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetPopularMovieList() throws MovieDbException {
|
||||
LOG.info("getPopularMovieList");
|
||||
Integer page = null;
|
||||
@@ -461,7 +461,7 @@ public class TmdbMoviesTest extends AbstractTests {
|
||||
*
|
||||
* @throws com.omertron.themoviedbapi.MovieDbException
|
||||
*/
|
||||
//@Test
|
||||
@Test
|
||||
public void testGetTopRatedMovies() throws MovieDbException {
|
||||
LOG.info("getTopRatedMovies");
|
||||
Integer page = null;
|
||||
|
||||
Reference in New Issue
Block a user