Fixed People Combined Search
This commit is contained in:
@@ -24,6 +24,7 @@ import com.omertron.themoviedbapi.MovieDbException;
|
||||
import com.omertron.themoviedbapi.enumeration.ArtworkType;
|
||||
import com.omertron.themoviedbapi.model2.artwork.Artwork;
|
||||
import com.omertron.themoviedbapi.model2.artwork.ArtworkMedia;
|
||||
import com.omertron.themoviedbapi.model2.person.CreditBasic;
|
||||
import com.omertron.themoviedbapi.model2.person.CreditMovieBasic;
|
||||
import com.omertron.themoviedbapi.model2.person.CreditTVBasic;
|
||||
import com.omertron.themoviedbapi.model2.person.ExternalID;
|
||||
@@ -167,7 +168,7 @@ public class TmdbPeople extends AbstractMethod {
|
||||
String webpage = httpTools.getRequest(url);
|
||||
|
||||
try {
|
||||
return MAPPER.readValue(webpage, new TypeReference<PersonCredits<CreditTVBasic>>() {
|
||||
return MAPPER.readValue(webpage, new TypeReference<PersonCredits<? extends CreditBasic>>() {
|
||||
});
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person movie credits", url, ex);
|
||||
|
||||
@@ -41,7 +41,6 @@ import com.omertron.themoviedbapi.wrapper.WrapperGenericList;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperMultiSearch;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import org.yamj.api.common.exception.ApiExceptionType;
|
||||
|
||||
/**
|
||||
@@ -215,7 +214,6 @@ public class TmdbSearch extends AbstractMethod {
|
||||
try {
|
||||
WrapperMultiSearch wrapper = MAPPER.readValue(webpage, WrapperMultiSearch.class);
|
||||
TmdbResultsList<MediaBasic> results = new TmdbResultsList<MediaBasic>(null);
|
||||
List<? extends MediaBasic> x = wrapper.getResults();
|
||||
results.getResults().addAll(wrapper.getResults());
|
||||
results.copyWrapper(wrapper);
|
||||
return results;
|
||||
|
||||
@@ -20,11 +20,16 @@
|
||||
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.AbstractJsonMapping;
|
||||
import com.omertron.themoviedbapi.model2.MediaBasic;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author stuart.boston
|
||||
* @param <T>
|
||||
*/
|
||||
public class PersonCredits<T> extends AbstractJsonMapping {
|
||||
|
||||
@@ -32,9 +37,9 @@ public class PersonCredits<T> extends AbstractJsonMapping {
|
||||
|
||||
@JsonProperty("id")
|
||||
private int id;
|
||||
@JsonProperty("cast")
|
||||
// @JsonProperty("cast")
|
||||
private List<T> cast;
|
||||
@JsonProperty("crew")
|
||||
// @JsonProperty("crew")
|
||||
private List<T> crew;
|
||||
|
||||
public int getId() {
|
||||
@@ -49,6 +54,17 @@ public class PersonCredits<T> extends AbstractJsonMapping {
|
||||
return cast;
|
||||
}
|
||||
|
||||
@JsonTypeInfo(
|
||||
use = JsonTypeInfo.Id.NAME,
|
||||
include = JsonTypeInfo.As.PROPERTY,
|
||||
property = "media_type",
|
||||
defaultImpl = MediaBasic.class
|
||||
)
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = CreditMovieBasic.class, name = "movie"),
|
||||
@JsonSubTypes.Type(value = CreditTVBasic.class, name = "tv")
|
||||
})
|
||||
@JsonSetter("cast")
|
||||
public void setCast(List<T> cast) {
|
||||
this.cast = cast;
|
||||
}
|
||||
@@ -57,6 +73,17 @@ public class PersonCredits<T> extends AbstractJsonMapping {
|
||||
return crew;
|
||||
}
|
||||
|
||||
@JsonTypeInfo(
|
||||
use = JsonTypeInfo.Id.NAME,
|
||||
include = JsonTypeInfo.As.PROPERTY,
|
||||
property = "media_type",
|
||||
defaultImpl = MediaBasic.class
|
||||
)
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = CreditMovieBasic.class, name = "movie"),
|
||||
@JsonSubTypes.Type(value = CreditTVBasic.class, name = "tv")
|
||||
})
|
||||
@JsonSetter("crew")
|
||||
public void setCrew(List<T> crew) {
|
||||
this.crew = crew;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.omertron.themoviedbapi.model2.artwork.Artwork;
|
||||
import com.omertron.themoviedbapi.model2.artwork.ArtworkMedia;
|
||||
import com.omertron.themoviedbapi.model2.change.ChangeKeyItem;
|
||||
import com.omertron.themoviedbapi.model2.change.ChangeListItem;
|
||||
import com.omertron.themoviedbapi.model2.person.CreditBasic;
|
||||
import com.omertron.themoviedbapi.model2.person.CreditMovieBasic;
|
||||
import com.omertron.themoviedbapi.model2.person.CreditTVBasic;
|
||||
import com.omertron.themoviedbapi.model2.person.ExternalID;
|
||||
@@ -48,7 +49,6 @@ 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;
|
||||
@@ -161,13 +161,12 @@ public class TmdbPeopleTest extends AbstractTests {
|
||||
String[] appendToResponse = null;
|
||||
|
||||
for (TestID test : testIDs) {
|
||||
PersonCredits<CreditTVBasic> result = instance.getPersonCombinedCredits(test.getTmdb(), language, appendToResponse);
|
||||
PersonCredits<? extends CreditBasic> result = instance.getPersonCombinedCredits(test.getTmdb(), language, appendToResponse);
|
||||
LOG.info("ID: {}, # Cast: {}, # Crew: {}", result.getId(), result.getCast().size(), result.getCrew().size());
|
||||
assertEquals("Incorrect ID", test.getTmdb(), result.getId());
|
||||
assertFalse("No cast", result.getCast().isEmpty());
|
||||
assertFalse("No crew", result.getCrew().isEmpty());
|
||||
}
|
||||
fail("Not working");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,7 +243,7 @@ public class TmdbPeopleTest extends AbstractTests {
|
||||
for (ChangeListItem item : changeList) {
|
||||
result = instance.getPersonChanges(item.getId(), startDate, endDate);
|
||||
for (ChangeKeyItem ci : result.getChangedItems()) {
|
||||
assertNotNull("Null changes",ci);
|
||||
assertNotNull("Null changes", ci);
|
||||
}
|
||||
|
||||
if (count++ > maxCheck) {
|
||||
|
||||
Reference in New Issue
Block a user