Reviews
This commit is contained in:
@@ -59,7 +59,7 @@ import com.omertron.themoviedbapi.model.MovieList;
|
||||
import com.omertron.themoviedbapi.model.person.Person;
|
||||
import com.omertron.themoviedbapi.model.person.PersonCredit;
|
||||
import com.omertron.themoviedbapi.model.ReleaseInfo;
|
||||
import com.omertron.themoviedbapi.model.Reviews;
|
||||
import com.omertron.themoviedbapi.model2.review.Review;
|
||||
import com.omertron.themoviedbapi.model2.StatusCode;
|
||||
import com.omertron.themoviedbapi.enumeration.ExternalSource;
|
||||
import com.omertron.themoviedbapi.enumeration.SortBy;
|
||||
@@ -1220,7 +1220,7 @@ public class TheMovieDbApi {
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Reviews">
|
||||
//<editor-fold defaultstate="collapsed" desc="Review">
|
||||
/**
|
||||
*
|
||||
* @param movieId
|
||||
@@ -1230,7 +1230,7 @@ public class TheMovieDbApi {
|
||||
* @return
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public TmdbResultsList<Reviews> getReviews(int movieId, String language, int page, String... appendToResponse) throws MovieDbException {
|
||||
public TmdbResultsList<Review> getReviews(int movieId, String language, int page, String... appendToResponse) throws MovieDbException {
|
||||
return tmdbReviews.getReviews(movieId, language, page, appendToResponse);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
@@ -21,15 +21,12 @@ package com.omertron.themoviedbapi.methods;
|
||||
|
||||
import com.omertron.themoviedbapi.MovieDbException;
|
||||
import static com.omertron.themoviedbapi.methods.AbstractMethod.MAPPER;
|
||||
import com.omertron.themoviedbapi.model.Reviews;
|
||||
import com.omertron.themoviedbapi.results.TmdbResultsList;
|
||||
import com.omertron.themoviedbapi.model2.review.Review;
|
||||
import com.omertron.themoviedbapi.tools.ApiUrl;
|
||||
import com.omertron.themoviedbapi.tools.HttpTools;
|
||||
import com.omertron.themoviedbapi.tools.MethodBase;
|
||||
import com.omertron.themoviedbapi.tools.MethodSub;
|
||||
import com.omertron.themoviedbapi.tools.Param;
|
||||
import com.omertron.themoviedbapi.tools.TmdbParameters;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperReviews;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import org.yamj.api.common.exception.ApiExceptionType;
|
||||
@@ -54,30 +51,21 @@ public class TmdbReviews extends AbstractMethod {
|
||||
/**
|
||||
* Get the full details of a review by ID.
|
||||
*
|
||||
* @param id
|
||||
* @param language
|
||||
* @param page
|
||||
* @param appendToResponse
|
||||
* @param reviewId
|
||||
* @return
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public TmdbResultsList<Reviews> getReviews(int id, String language, int page, String... appendToResponse) throws MovieDbException {
|
||||
public Review getReview(String reviewId) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.ID, id);
|
||||
parameters.add(Param.LANGUAGE, language);
|
||||
parameters.add(Param.PAGE, page);
|
||||
parameters.add(Param.APPEND, appendToResponse);
|
||||
parameters.add(Param.ID, reviewId);
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.MOVIE).setSubMethod(MethodSub.REVIEWS).buildUrl(parameters);
|
||||
URL url = new ApiUrl(apiKey, MethodBase.REVIEW).buildUrl(parameters);
|
||||
String webpage = httpTools.getRequest(url);
|
||||
|
||||
try {
|
||||
WrapperReviews wrapper = MAPPER.readValue(webpage, WrapperReviews.class);
|
||||
TmdbResultsList<Reviews> results = new TmdbResultsList<Reviews>(wrapper.getReviews());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
return MAPPER.readValue(webpage, Review.class);
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get reviews", url, ex);
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get review", url, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ Movies
|
||||
/movie/popular Get the list of popular movies on The Movie Database. This list refreshes every day.
|
||||
/movie/top_rated Get the list of top rated movies. By default, this list will only include movies that have 10 or more votes. This list refreshes every day.
|
||||
|
||||
Networks
|
||||
Networks (Done)
|
||||
/network/{id} This method is used to retrieve the basic information about a TV network.
|
||||
|
||||
People
|
||||
@@ -102,7 +102,7 @@ People
|
||||
/person/popular Get the list of popular people on The Movie Database. This list refreshes every day.
|
||||
/person/latest Get the latest person id.
|
||||
|
||||
Reviews
|
||||
Reviews (Done)
|
||||
/review/{id} Get the full details of a review by ID.
|
||||
|
||||
Search
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.omertron.themoviedbapi.model2.review.Review;
|
||||
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
|
||||
import com.omertron.themoviedbapi.model2.collection.Collection;
|
||||
import com.omertron.themoviedbapi.model.keyword.Keyword;
|
||||
@@ -374,7 +375,7 @@ public class MovieDb extends AbstractJsonMapping {
|
||||
return lists.getMovieList();
|
||||
}
|
||||
|
||||
public List<Reviews> getReviews() {
|
||||
public List<Review> getReviews() {
|
||||
return reviews.getReviews();
|
||||
}
|
||||
// </editor-fold>
|
||||
|
||||
+55
-17
@@ -17,7 +17,7 @@
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
package com.omertron.themoviedbapi.model2.review;
|
||||
|
||||
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
@@ -25,19 +25,24 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
/**
|
||||
* @author Stuart
|
||||
*/
|
||||
public class Reviews extends AbstractJsonMapping {
|
||||
public class Review extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@JsonProperty("id")
|
||||
private String id;
|
||||
@JsonProperty("author")
|
||||
private String author;
|
||||
@JsonProperty("content")
|
||||
private String content;
|
||||
@JsonProperty("iso_639_1")
|
||||
private String langauage;
|
||||
@JsonProperty("media_id")
|
||||
private String mediaId;
|
||||
@JsonProperty("media_title")
|
||||
private String mediaTitle;
|
||||
@JsonProperty("media_type")
|
||||
private String mediaType;
|
||||
@JsonProperty("url")
|
||||
private String url;
|
||||
|
||||
@@ -45,31 +50,64 @@ public class Reviews extends AbstractJsonMapping {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getLangauage() {
|
||||
return langauage;
|
||||
}
|
||||
|
||||
public void setLangauage(String langauage) {
|
||||
this.langauage = langauage;
|
||||
}
|
||||
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
public String getMediaTitle() {
|
||||
return mediaTitle;
|
||||
}
|
||||
|
||||
public void setMediaTitle(String mediaTitle) {
|
||||
this.mediaTitle = mediaTitle;
|
||||
}
|
||||
|
||||
public String getMediaType() {
|
||||
return mediaType;
|
||||
}
|
||||
|
||||
public void setMediaType(String mediaType) {
|
||||
this.mediaType = mediaType;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,6 +41,7 @@ public enum MethodBase {
|
||||
MOVIE("movie"),
|
||||
NETWORK("network"),
|
||||
PERSON("person"),
|
||||
REVIEW("review"),
|
||||
SEARCH("search"),
|
||||
TV("tv");
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
package com.omertron.themoviedbapi.wrapper;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.model.Reviews;
|
||||
import com.omertron.themoviedbapi.model2.review.Review;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@@ -32,13 +32,13 @@ public class WrapperReviews extends AbstractWrapperAll implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@JsonProperty("results")
|
||||
private List<Reviews> reviews;
|
||||
private List<Review> reviews;
|
||||
|
||||
public List<Reviews> getReviews() {
|
||||
public List<Review> getReviews() {
|
||||
return reviews;
|
||||
}
|
||||
|
||||
public void setReviews(List<Reviews> reviews) {
|
||||
public void setReviews(List<Review> reviews) {
|
||||
this.reviews = reviews;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,13 @@ package com.omertron.themoviedbapi.methods;
|
||||
|
||||
import com.omertron.themoviedbapi.AbstractTests;
|
||||
import com.omertron.themoviedbapi.MovieDbException;
|
||||
import com.omertron.themoviedbapi.model2.review.Review;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import static org.junit.Assert.fail;
|
||||
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;
|
||||
@@ -66,7 +70,11 @@ public class TmdbReviewsTest extends AbstractTests {
|
||||
@Test
|
||||
public void testGetReview() throws MovieDbException {
|
||||
LOG.info("getReview");
|
||||
fail("The test case is a prototype.");
|
||||
String reviewId = "53fc2f600e0a267a7b009aba";
|
||||
Review result = instance.getReview(reviewId);
|
||||
assertNotNull("No review", result);
|
||||
assertTrue("No content", StringUtils.isNotBlank(result.getContent()));
|
||||
assertEquals("Wrong media ID", "70160", result.getMediaId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user