partial
This commit is contained in:
@@ -22,8 +22,6 @@ package com.omertron.themoviedbapi.methods;
|
||||
import com.omertron.themoviedbapi.MovieDbException;
|
||||
import com.omertron.themoviedbapi.enumeration.ExternalSource;
|
||||
import com.omertron.themoviedbapi.model2.FindResults;
|
||||
import com.omertron.themoviedbapi.model2.MediaBasic;
|
||||
import com.omertron.themoviedbapi.model2.MediaTypeMixIn;
|
||||
import com.omertron.themoviedbapi.tools.ApiUrl;
|
||||
import com.omertron.themoviedbapi.tools.HttpTools;
|
||||
import com.omertron.themoviedbapi.tools.MethodBase;
|
||||
@@ -48,7 +46,7 @@ public class TmdbFind extends AbstractMethod {
|
||||
*/
|
||||
public TmdbFind(String apiKey, HttpTools httpTools) {
|
||||
super(apiKey, httpTools);
|
||||
MAPPER.addMixIn(MediaBasic.class, MediaTypeMixIn.class);
|
||||
// MAPPER.addMixIn(MediaBasic.class, MediaTypeMixIn.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.omertron.themoviedbapi.model2.person.CreditTVBasic;
|
||||
import com.omertron.themoviedbapi.model2.person.ExternalID;
|
||||
import com.omertron.themoviedbapi.model2.person.Person;
|
||||
import com.omertron.themoviedbapi.model2.person.PersonCredits;
|
||||
import com.omertron.themoviedbapi.model2.person.PersonFind;
|
||||
import com.omertron.themoviedbapi.results.TmdbResultsList;
|
||||
import com.omertron.themoviedbapi.tools.ApiUrl;
|
||||
import com.omertron.themoviedbapi.tools.HttpTools;
|
||||
@@ -38,7 +39,6 @@ import com.omertron.themoviedbapi.tools.Param;
|
||||
import com.omertron.themoviedbapi.tools.TmdbParameters;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperImages;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperPersonList;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import org.yamj.api.common.exception.ApiExceptionType;
|
||||
@@ -277,21 +277,23 @@ public class TmdbPeople extends AbstractMethod {
|
||||
* @return
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
public TmdbResultsList<Person> getPersonPopular(Integer page) throws MovieDbException {
|
||||
public TmdbResultsList<PersonFind> getPersonPopular(Integer page) throws MovieDbException {
|
||||
TmdbParameters parameters = new TmdbParameters();
|
||||
parameters.add(Param.PAGE, page);
|
||||
|
||||
URL url = new ApiUrl(apiKey, MethodBase.PERSON).setSubMethod(MethodSub.POPULAR).buildUrl(parameters);
|
||||
String webpage = httpTools.getRequest(url);
|
||||
|
||||
WrapperGenericList<PersonFind> wrapper;
|
||||
try {
|
||||
WrapperPersonList wrapper = MAPPER.readValue(webpage, WrapperPersonList.class);
|
||||
// TmdbResultsList<Person> results = new TmdbResultsList<Person>(wrapper.getPersonList());
|
||||
// results.copyWrapper(wrapper);
|
||||
// return results;
|
||||
return null;
|
||||
TypeReference tr = new TypeReference<WrapperGenericList<PersonFind>>() {
|
||||
};
|
||||
wrapper = MAPPER.readValue(webpage, tr);
|
||||
TmdbResultsList<PersonFind> results = new TmdbResultsList<PersonFind>(wrapper.getResults());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get popular person", url, ex);
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get tagged images", url, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.omertron.themoviedbapi.model2.movie.MovieBasic;
|
||||
import com.omertron.themoviedbapi.model2.tv.TVBasic;
|
||||
import com.omertron.themoviedbapi.model2.tv.TVEpisodeBasic;
|
||||
|
||||
@JsonTypeInfo(
|
||||
use = JsonTypeInfo.Id.NAME,
|
||||
@@ -13,7 +14,8 @@ import com.omertron.themoviedbapi.model2.tv.TVBasic;
|
||||
)
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = MovieBasic.class, name = "movie"),
|
||||
@JsonSubTypes.Type(value = TVBasic.class, name = "tv")
|
||||
@JsonSubTypes.Type(value = TVBasic.class, name = "tv"),
|
||||
@JsonSubTypes.Type(value = TVEpisodeBasic.class, name = "episode")
|
||||
})
|
||||
public class MediaTypeMixIn {
|
||||
|
||||
|
||||
@@ -20,7 +20,13 @@
|
||||
package com.omertron.themoviedbapi.model2.person;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonSetter;
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.omertron.themoviedbapi.model2.MediaBasic;
|
||||
import com.omertron.themoviedbapi.model2.movie.MovieBasic;
|
||||
import com.omertron.themoviedbapi.model2.tv.TVBasic;
|
||||
import com.omertron.themoviedbapi.model2.tv.TVEpisodeBasic;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -35,7 +41,7 @@ public class PersonFind extends PersonBasic {
|
||||
private Float popularity;
|
||||
@JsonProperty("profile_path")
|
||||
private String profilePath;
|
||||
@JsonProperty("known_for")
|
||||
// @JsonProperty("known_for")
|
||||
private List<? extends MediaBasic> knownFor;
|
||||
|
||||
public Boolean getAdult() {
|
||||
@@ -66,6 +72,19 @@ public class PersonFind extends PersonBasic {
|
||||
return knownFor;
|
||||
}
|
||||
|
||||
@JsonTypeInfo(
|
||||
use = JsonTypeInfo.Id.NAME,
|
||||
// include = JsonTypeInfo.As.EXTERNAL_PROPERTY,
|
||||
include = JsonTypeInfo.As.PROPERTY,
|
||||
property = "media_type",
|
||||
defaultImpl = MediaBasic.class
|
||||
)
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = MovieBasic.class, name = "movie"),
|
||||
@JsonSubTypes.Type(value = TVBasic.class, name = "tv"),
|
||||
@JsonSubTypes.Type(value = TVEpisodeBasic.class, name = "episode")
|
||||
})
|
||||
@JsonSetter("known_for")
|
||||
public void setKnownFor(List<? extends MediaBasic> knownFor) {
|
||||
this.knownFor = knownFor;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class TmdbFindTest extends AbstractTests {
|
||||
*
|
||||
* @throws MovieDbException
|
||||
*/
|
||||
// @Test
|
||||
@Test
|
||||
public void testFindMoviesImdbID() throws MovieDbException {
|
||||
LOG.info("findMoviesImdbID");
|
||||
FindResults result;
|
||||
@@ -109,7 +109,7 @@ public class TmdbFindTest extends AbstractTests {
|
||||
* @throws MovieDbException
|
||||
* @throws IOException
|
||||
*/
|
||||
// @Test
|
||||
@Test
|
||||
public void testFindPersonImdbID() throws MovieDbException, IOException {
|
||||
LOG.info("findPersonImdbID");
|
||||
FindResults result;
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.omertron.themoviedbapi.AbstractTests;
|
||||
import com.omertron.themoviedbapi.MovieDbException;
|
||||
import com.omertron.themoviedbapi.TestID;
|
||||
import com.omertron.themoviedbapi.enumeration.ArtworkType;
|
||||
import com.omertron.themoviedbapi.model2.MediaBasic;
|
||||
import com.omertron.themoviedbapi.model2.artwork.Artwork;
|
||||
import com.omertron.themoviedbapi.model2.artwork.ArtworkMedia;
|
||||
import com.omertron.themoviedbapi.model2.person.CreditMovieBasic;
|
||||
@@ -30,6 +31,7 @@ import com.omertron.themoviedbapi.model2.person.CreditTVBasic;
|
||||
import com.omertron.themoviedbapi.model2.person.ExternalID;
|
||||
import com.omertron.themoviedbapi.model2.person.Person;
|
||||
import com.omertron.themoviedbapi.model2.person.PersonCredits;
|
||||
import com.omertron.themoviedbapi.model2.person.PersonFind;
|
||||
import com.omertron.themoviedbapi.results.TmdbResultsList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -53,8 +55,6 @@ import org.junit.Test;
|
||||
public class TmdbPeopleTest extends AbstractTests {
|
||||
|
||||
private static TmdbPeople instance;
|
||||
private static final int ID_BRUCE_WILLIS = 62;
|
||||
private static final int ID_SEAN_BEAN = 48;
|
||||
private static final int ID_DICK_WOLF = 117443;
|
||||
private static final List<TestID> testIDs = new ArrayList<TestID>();
|
||||
|
||||
@@ -244,12 +244,15 @@ public class TmdbPeopleTest extends AbstractTests {
|
||||
public void testGetPersonPopular() throws MovieDbException {
|
||||
LOG.info("getPersonPopular");
|
||||
Integer page = null;
|
||||
|
||||
TmdbResultsList<Person> expResult = null;
|
||||
TmdbResultsList<Person> result = instance.getPersonPopular(page);
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
TmdbResultsList<PersonFind> result = instance.getPersonPopular(page);
|
||||
assertFalse("No results", result.isEmpty());
|
||||
assertTrue("No results", result.getResults().size() > 0);
|
||||
for (PersonFind p : result.getResults()) {
|
||||
LOG.info("{} ({}) = {}", p.getName(), p.getId(), p.getKnownFor().size());
|
||||
for (MediaBasic k : p.getKnownFor()) {
|
||||
LOG.info(" {}", k.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user