diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java
index f821b6bb1..34f1a204b 100644
--- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java
+++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java
@@ -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 {
}
//
- //
+ //
/**
*
* @param movieId
@@ -1230,7 +1230,7 @@ public class TheMovieDbApi {
* @return
* @throws MovieDbException
*/
- public TmdbResultsList getReviews(int movieId, String language, int page, String... appendToResponse) throws MovieDbException {
+ public TmdbResultsList getReviews(int movieId, String language, int page, String... appendToResponse) throws MovieDbException {
return tmdbReviews.getReviews(movieId, language, page, appendToResponse);
}
//
diff --git a/src/main/java/com/omertron/themoviedbapi/methods/TmdbReviews.java b/src/main/java/com/omertron/themoviedbapi/methods/TmdbReviews.java
index be418d3d4..d47bcaab9 100644
--- a/src/main/java/com/omertron/themoviedbapi/methods/TmdbReviews.java
+++ b/src/main/java/com/omertron/themoviedbapi/methods/TmdbReviews.java
@@ -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 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 results = new TmdbResultsList(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);
}
}
diff --git a/src/main/java/com/omertron/themoviedbapi/methods/_Method_List.txt b/src/main/java/com/omertron/themoviedbapi/methods/_Method_List.txt
index e79b09932..2b0e38894 100644
--- a/src/main/java/com/omertron/themoviedbapi/methods/_Method_List.txt
+++ b/src/main/java/com/omertron/themoviedbapi/methods/_Method_List.txt
@@ -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
diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java
index 518cd93ab..fa9b9cbed 100644
--- a/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java
+++ b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java
@@ -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 getReviews() {
+ public List getReviews() {
return reviews.getReviews();
}
//
diff --git a/src/main/java/com/omertron/themoviedbapi/model/Reviews.java b/src/main/java/com/omertron/themoviedbapi/model2/review/Review.java
similarity index 63%
rename from src/main/java/com/omertron/themoviedbapi/model/Reviews.java
rename to src/main/java/com/omertron/themoviedbapi/model2/review/Review.java
index 34f75a288..b73b3028d 100644
--- a/src/main/java/com/omertron/themoviedbapi/model/Reviews.java
+++ b/src/main/java/com/omertron/themoviedbapi/model2/review/Review.java
@@ -17,7 +17,7 @@
* along with TheMovieDB API. If not, see .
*
*/
-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 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 String getUrl() {
- return url;
+ public void setContent(String content) {
+ this.content = content;
}
- public void setId(String id) {
- this.id = id;
+ public String getLangauage() {
+ return langauage;
}
- public void setAuthor(String author) {
- this.author = author;
+ public void setLangauage(String langauage) {
+ this.langauage = langauage;
}
- public void setContent(String content) {
- this.content = content;
+ 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;
}
+
}
diff --git a/src/main/java/com/omertron/themoviedbapi/tools/MethodBase.java b/src/main/java/com/omertron/themoviedbapi/tools/MethodBase.java
index 3c2a38a7d..59a3f039a 100644
--- a/src/main/java/com/omertron/themoviedbapi/tools/MethodBase.java
+++ b/src/main/java/com/omertron/themoviedbapi/tools/MethodBase.java
@@ -41,6 +41,7 @@ public enum MethodBase {
MOVIE("movie"),
NETWORK("network"),
PERSON("person"),
+ REVIEW("review"),
SEARCH("search"),
TV("tv");
diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReviews.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReviews.java
index 0ffa79ee6..9441ab615 100644
--- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReviews.java
+++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReviews.java
@@ -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;
+ private List reviews;
- public List getReviews() {
+ public List getReviews() {
return reviews;
}
- public void setReviews(List reviews) {
+ public void setReviews(List reviews) {
this.reviews = reviews;
}
}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbReviewsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbReviewsTest.java
index f47810e76..c2017a98d 100644
--- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbReviewsTest.java
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbReviewsTest.java
@@ -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());
}
}