diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java
index 8257c73f3..e5c14be42 100644
--- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java
+++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java
@@ -61,8 +61,8 @@ import com.omertron.themoviedbapi.model.person.PersonCredit;
import com.omertron.themoviedbapi.model.ReleaseInfo;
import com.omertron.themoviedbapi.model.Reviews;
import com.omertron.themoviedbapi.model2.StatusCode;
-import com.omertron.themoviedbapi.model.TBD_ExternalSource;
-import com.omertron.themoviedbapi.model.TBD_FindResults;
+import com.omertron.themoviedbapi.enumeration.ExternalSource;
+import com.omertron.themoviedbapi.model2.FindResults;
import com.omertron.themoviedbapi.model.TBD_Network;
import com.omertron.themoviedbapi.model2.person.CreditInfo;
import com.omertron.themoviedbapi.model2.authentication.TokenAuthorisation;
@@ -709,7 +709,7 @@ public class TheMovieDbApi {
* @return
* @throws MovieDbException
*/
- public TBD_FindResults find(String id, TBD_ExternalSource externalSource, String language) throws MovieDbException {
+ public FindResults find(String id, ExternalSource externalSource, String language) throws MovieDbException {
return tmdbFind.find(id, externalSource, language);
}
//
diff --git a/src/main/java/com/omertron/themoviedbapi/model/TBD_FindResults.java b/src/main/java/com/omertron/themoviedbapi/enumeration/ExternalSource.java
similarity index 60%
rename from src/main/java/com/omertron/themoviedbapi/model/TBD_FindResults.java
rename to src/main/java/com/omertron/themoviedbapi/enumeration/ExternalSource.java
index feeefa39c..772e7255b 100644
--- a/src/main/java/com/omertron/themoviedbapi/model/TBD_FindResults.java
+++ b/src/main/java/com/omertron/themoviedbapi/enumeration/ExternalSource.java
@@ -17,29 +17,22 @@
* along with TheMovieDB API. If not, see .
*
*/
-package com.omertron.themoviedbapi.model;
-
-import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
+package com.omertron.themoviedbapi.enumeration;
/**
- * @author stuart.boston
+ *
+ * @author Stuart
*/
-@JsonRootName("???")
-public class TBD_FindResults extends AbstractJsonMapping {
+public enum ExternalSource {
- private static final long serialVersionUID = 1L;
+ FREEBASE_ID,
+ FREEBASE_MID,
+ IMDB_ID,
+ TVDB_ID,
+ TVRAGE_ID;
- // Properties
- @JsonProperty("id")
- private int id;
-
- public int getId() {
- return id;
+ public String getPropertyString() {
+ return this.name().toLowerCase();
}
- public void setId(int id) {
- this.id = id;
- }
}
diff --git a/src/main/java/com/omertron/themoviedbapi/methods/TmdbFind.java b/src/main/java/com/omertron/themoviedbapi/methods/TmdbFind.java
index 26a9ba28e..2bd8b936c 100644
--- a/src/main/java/com/omertron/themoviedbapi/methods/TmdbFind.java
+++ b/src/main/java/com/omertron/themoviedbapi/methods/TmdbFind.java
@@ -20,9 +20,15 @@
package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.MovieDbException;
-import com.omertron.themoviedbapi.model.TBD_ExternalSource;
-import com.omertron.themoviedbapi.model.TBD_FindResults;
+import com.omertron.themoviedbapi.enumeration.ExternalSource;
+import com.omertron.themoviedbapi.model2.FindResults;
+import com.omertron.themoviedbapi.tools.ApiUrl;
import com.omertron.themoviedbapi.tools.HttpTools;
+import com.omertron.themoviedbapi.tools.MethodBase;
+import com.omertron.themoviedbapi.tools.Param;
+import com.omertron.themoviedbapi.tools.TmdbParameters;
+import java.io.IOException;
+import java.net.URL;
import org.yamj.api.common.exception.ApiExceptionType;
/**
@@ -43,18 +49,16 @@ public class TmdbFind extends AbstractMethod {
}
/**
- * You con use this method to find movies, tv series or persons using
- * external ids.
+ * You con use this method to find movies, tv series or persons using external ids.
*
* Supported query ids are
*
* - Movies: imdb_id
* - People: imdb_id, freebase_mid, freebase_id, tvrage_id
- * - TV Series: imdb_id, freebase_mid, freebase_id, tvdb_id,
- * tvrage_id
+ * - TV Series: imdb_id, freebase_mid, freebase_id, tvdb_id, tvrage_id
* - TV Seasons: freebase_mid, freebase_id, tvdb_id, tvrage_id
- * - TV Episodes: imdb_id, freebase_mid, freebase_id, tvdb_id,
- * tvrage_idimdb_id, freebase_mid, freebase_id, tvrage_id, tvdb_id.
+ *
- TV Episodes: imdb_id, freebase_mid, freebase_id, tvdb_id, tvrage_idimdb_id, freebase_mid, freebase_id, tvrage_id,
+ * tvdb_id.
*
*
* For details see http://docs.themoviedb.apiary.io/#find
@@ -65,7 +69,20 @@ public class TmdbFind extends AbstractMethod {
* @return
* @throws MovieDbException
*/
- public TBD_FindResults find(String id, TBD_ExternalSource externalSource, String language) throws MovieDbException {
- throw new MovieDbException(ApiExceptionType.UNKNOWN_CAUSE, "not implemented yet");
+ public FindResults find(String id, ExternalSource externalSource, String language) throws MovieDbException {
+ TmdbParameters parameters = new TmdbParameters();
+ parameters.add(Param.ID, id);
+ parameters.add(Param.LANGUAGE, language);
+ parameters.add(Param.EXTERNAL_SOURCE, externalSource.getPropertyString());
+
+ URL url = new ApiUrl(apiKey, MethodBase.FIND).buildUrl(parameters);
+ String webpage = httpTools.getRequest(url);
+
+ try {
+ return MAPPER.readValue(webpage, FindResults.class);
+ } catch (IOException ex) {
+ LOG.info("{}",ex.getMessage(),ex);
+ throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get find results", url, ex);
+ }
}
}
diff --git a/src/main/java/com/omertron/themoviedbapi/model/TBD_ExternalSource.java b/src/main/java/com/omertron/themoviedbapi/model/TBD_ExternalSource.java
deleted file mode 100644
index fb52a06e2..000000000
--- a/src/main/java/com/omertron/themoviedbapi/model/TBD_ExternalSource.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2004-2015 Stuart Boston
- *
- * This file is part of TheMovieDB API.
- *
- * TheMovieDB API is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * any later version.
- *
- * TheMovieDB API is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with TheMovieDB API. If not, see .
- *
- */
-package com.omertron.themoviedbapi.model;
-
-import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-
-/**
- * @author stuart.boston
- */
-@JsonRootName("???")
-public class TBD_ExternalSource extends AbstractJsonMapping {
-
- private static final long serialVersionUID = 1L;
-
- // Properties
- @JsonProperty("id")
- private int id;
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-}
diff --git a/src/main/java/com/omertron/themoviedbapi/model2/FindResults.java b/src/main/java/com/omertron/themoviedbapi/model2/FindResults.java
new file mode 100644
index 000000000..88c1b3027
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model2/FindResults.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model2;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.omertron.themoviedbapi.model2.movie.MovieBasic;
+import com.omertron.themoviedbapi.model2.person.PersonFind;
+import com.omertron.themoviedbapi.model2.tv.TVBasic;
+import com.omertron.themoviedbapi.model2.tv.TVEpisodeBasic;
+import com.omertron.themoviedbapi.model2.tv.TVSeasonBasic;
+import java.util.List;
+
+/**
+ * @author stuart.boston
+ */
+public class FindResults extends AbstractJsonMapping {
+
+ private static final long serialVersionUID = 1L;
+
+ @JsonProperty("movie_results")
+ private List movieResults;
+ @JsonProperty("person_results")
+ private List personResults;
+ @JsonProperty("tv_results")
+ private List tvResults;
+ @JsonProperty("tv_season_results")
+ private List tvSeasonResults;
+ @JsonProperty("tv_episode_results")
+ private List tvEpisodeResults;
+
+ public List getMovieResults() {
+ return movieResults;
+ }
+
+ public void setMovieResults(List movieResults) {
+ this.movieResults = movieResults;
+ }
+
+ public List getPersonResults() {
+ return personResults;
+ }
+
+ public void setPersonResults(List personResults) {
+ this.personResults = personResults;
+ }
+
+ public List getTvResults() {
+ return tvResults;
+ }
+
+ public void setTvResults(List tvResults) {
+ this.tvResults = tvResults;
+ }
+
+ public List getTvSeasonResults() {
+ return tvSeasonResults;
+ }
+
+ public void setTvSeasonResults(List tvSeasonResults) {
+ this.tvSeasonResults = tvSeasonResults;
+ }
+
+ public List getTvEpisodeResults() {
+ return tvEpisodeResults;
+ }
+
+ public void setTvEpisodeResults(List tvEpisodeResults) {
+ this.tvEpisodeResults = tvEpisodeResults;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model2/MediaBasic.java b/src/main/java/com/omertron/themoviedbapi/model2/MediaBasic.java
new file mode 100644
index 000000000..cbf8c2f4d
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model2/MediaBasic.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model2;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonSubTypes;
+import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.omertron.themoviedbapi.model2.movie.MovieBasic;
+import com.omertron.themoviedbapi.model2.tv.TVBasic;
+
+/**
+ * Basic media information
+ *
+ * @author stuart.boston
+ */
+@JsonTypeInfo(
+ use = JsonTypeInfo.Id.NAME,
+ include = JsonTypeInfo.As.EXTERNAL_PROPERTY,
+ property = "media_type",
+ defaultImpl = MovieBasic.class
+)
+@JsonSubTypes({
+ @Type(value = MovieBasic.class, name = "movie"),
+ @Type(value = TVBasic.class, name = "tv")
+})
+public class MediaBasic extends AbstractJsonMapping {
+
+ @JsonProperty("id")
+ private int id;
+ @JsonProperty("media_type")
+ private String mediaType;
+ @JsonProperty("backdrop_path")
+ private String backdropPath;
+ @JsonProperty("poster_path")
+ private String posterPath;
+ @JsonProperty("popularity")
+ private float popularity;
+ @JsonProperty("vote_average")
+ private float voteAverage;
+ @JsonProperty("vote_count")
+ private int voteCount;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getMediaType() {
+ return mediaType;
+ }
+
+ public void setMediaType(String mediaType) {
+ this.mediaType = mediaType;
+ }
+
+ public String getBackdropPath() {
+ return backdropPath;
+ }
+
+ public void setBackdropPath(String backdropPath) {
+ this.backdropPath = backdropPath;
+ }
+
+ public String getPosterPath() {
+ return posterPath;
+ }
+
+ public void setPosterPath(String posterPath) {
+ this.posterPath = posterPath;
+ }
+
+ public float getPopularity() {
+ return popularity;
+ }
+
+ public void setPopularity(float popularity) {
+ this.popularity = popularity;
+ }
+
+ public float getVoteAverage() {
+ return voteAverage;
+ }
+
+ public void setVoteAverage(float voteAverage) {
+ this.voteAverage = voteAverage;
+ }
+
+ public int getVoteCount() {
+ return voteCount;
+ }
+
+ public void setVoteCount(int voteCount) {
+ this.voteCount = voteCount;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model2/MediaTypeMixIn.java b/src/main/java/com/omertron/themoviedbapi/model2/MediaTypeMixIn.java
new file mode 100644
index 000000000..62c5b5c00
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model2/MediaTypeMixIn.java
@@ -0,0 +1,5 @@
+package com.omertron.themoviedbapi.model2;
+
+public class MediaTypeMixIn {
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model2/movie/MovieBasic.java b/src/main/java/com/omertron/themoviedbapi/model2/movie/MovieBasic.java
index 55357bdba..b6a7456a3 100644
--- a/src/main/java/com/omertron/themoviedbapi/model2/movie/MovieBasic.java
+++ b/src/main/java/com/omertron/themoviedbapi/model2/movie/MovieBasic.java
@@ -19,50 +19,29 @@
*/
package com.omertron.themoviedbapi.model2.movie;
-import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
-import com.omertron.themoviedbapi.model.*;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.omertron.themoviedbapi.model2.MediaBasic;
/**
- * Movie Favorite information
+ * Basic Movie information
*
* @author stuart.boston
*/
-public class MovieBasic extends AbstractJsonMapping {
+public class MovieBasic extends MediaBasic {
- @JsonProperty("id")
- private int id;
@JsonProperty("adult")
private boolean adult;
- @JsonProperty("backdrop_path")
- private String backdropPath;
@JsonProperty("original_title")
private String originalTitle;
@JsonProperty("release_date")
private String releaseDate;
- @JsonProperty("poster_path")
- private String posterPath;
- @JsonProperty("popularity")
- private float popularity;
@JsonProperty("title")
private String title;
@JsonProperty("video")
private boolean video;
- @JsonProperty("vote_average")
- private float voteAverage;
- @JsonProperty("vote_count")
- private int voteCount;
@JsonProperty("rating")
private float rating = -1f;
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
public boolean isAdult() {
return adult;
}
@@ -71,14 +50,6 @@ public class MovieBasic extends AbstractJsonMapping {
this.adult = adult;
}
- public String getBackdropPath() {
- return backdropPath;
- }
-
- public void setBackdropPath(String backdropPath) {
- this.backdropPath = backdropPath;
- }
-
public String getOriginalTitle() {
return originalTitle;
}
@@ -95,22 +66,6 @@ public class MovieBasic extends AbstractJsonMapping {
this.releaseDate = releaseDate;
}
- public String getPosterPath() {
- return posterPath;
- }
-
- public void setPosterPath(String posterPath) {
- this.posterPath = posterPath;
- }
-
- public float getPopularity() {
- return popularity;
- }
-
- public void setPopularity(float popularity) {
- this.popularity = popularity;
- }
-
public String getTitle() {
return title;
}
@@ -127,22 +82,6 @@ public class MovieBasic extends AbstractJsonMapping {
this.video = video;
}
- public float getVoteAverage() {
- return voteAverage;
- }
-
- public void setVoteAverage(float voteAverage) {
- this.voteAverage = voteAverage;
- }
-
- public int getVoteCount() {
- return voteCount;
- }
-
- public void setVoteCount(int voteCount) {
- this.voteCount = voteCount;
- }
-
public float getRating() {
return rating;
}
diff --git a/src/main/java/com/omertron/themoviedbapi/model2/person/PersonBasic.java b/src/main/java/com/omertron/themoviedbapi/model2/person/PersonBasic.java
index 8accb1b18..3de122563 100644
--- a/src/main/java/com/omertron/themoviedbapi/model2/person/PersonBasic.java
+++ b/src/main/java/com/omertron/themoviedbapi/model2/person/PersonBasic.java
@@ -27,5 +27,4 @@ import com.omertron.themoviedbapi.model.AbstractIdName;
public class PersonBasic extends AbstractIdName {
private static final long serialVersionUID = 1L;
-
}
diff --git a/src/main/java/com/omertron/themoviedbapi/model2/person/PersonFind.java b/src/main/java/com/omertron/themoviedbapi/model2/person/PersonFind.java
new file mode 100644
index 000000000..506a972c0
--- /dev/null
+++ b/src/main/java/com/omertron/themoviedbapi/model2/person/PersonFind.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi.model2.person;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.omertron.themoviedbapi.model2.MediaBasic;
+import java.util.List;
+
+/**
+ * @author stuart.boston
+ */
+public class PersonFind extends PersonBasic {
+
+ private static final long serialVersionUID = 1L;
+ @JsonProperty("adult")
+ private Boolean adult;
+ @JsonProperty("popularity")
+ private Float popularity;
+ @JsonProperty("profile_path")
+ private String profilePath;
+ @JsonProperty("known_for")
+ private List extends MediaBasic> knownFor;
+
+ public Boolean getAdult() {
+ return adult;
+ }
+
+ public void setAdult(Boolean adult) {
+ this.adult = adult;
+ }
+
+ public Float getPopularity() {
+ return popularity;
+ }
+
+ public void setPopularity(Float popularity) {
+ this.popularity = popularity;
+ }
+
+ public String getProfilePath() {
+ return profilePath;
+ }
+
+ public void setProfilePath(String profilePath) {
+ this.profilePath = profilePath;
+ }
+
+ public List extends MediaBasic> getKnownFor() {
+ return knownFor;
+ }
+
+ public void setKnownFor(List extends MediaBasic> knownFor) {
+ this.knownFor = knownFor;
+ }
+
+}
diff --git a/src/main/java/com/omertron/themoviedbapi/model2/tv/TVBasic.java b/src/main/java/com/omertron/themoviedbapi/model2/tv/TVBasic.java
index 85399f3a5..3df890205 100644
--- a/src/main/java/com/omertron/themoviedbapi/model2/tv/TVBasic.java
+++ b/src/main/java/com/omertron/themoviedbapi/model2/tv/TVBasic.java
@@ -19,49 +19,28 @@
*/
package com.omertron.themoviedbapi.model2.tv;
-import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
-import com.omertron.themoviedbapi.model.*;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.omertron.themoviedbapi.model2.MediaBasic;
import java.util.List;
/**
- * TV Favorite information
+ * Basic TV information
*
* @author stuart.boston
*/
-public class TVBasic extends AbstractJsonMapping {
+public class TVBasic extends MediaBasic {
- @JsonProperty("id")
- private int id;
@JsonProperty("name")
private String name;
@JsonProperty("original_name")
private String originalName;
- @JsonProperty("backdrop_path")
- private String backdropPath;
- @JsonProperty("poster_path")
- private String posterPath;
- @JsonProperty("vote_average")
- private float voteAverage;
- @JsonProperty("vote_count")
- private int voteCount;
@JsonProperty("first_air_date")
private String firstAirDate;
- @JsonProperty("popularity")
- private float popularity;
@JsonProperty("origin_country")
private List originCountry;
@JsonProperty("rating")
private float rating = -1f;
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
public String getName() {
return name;
}
@@ -78,38 +57,6 @@ public class TVBasic extends AbstractJsonMapping {
this.originalName = originalName;
}
- public String getBackdropPath() {
- return backdropPath;
- }
-
- public void setBackdropPath(String backdropPath) {
- this.backdropPath = backdropPath;
- }
-
- public String getPosterPath() {
- return posterPath;
- }
-
- public void setPosterPath(String posterPath) {
- this.posterPath = posterPath;
- }
-
- public float getVoteAverage() {
- return voteAverage;
- }
-
- public void setVoteAverage(float voteAverage) {
- this.voteAverage = voteAverage;
- }
-
- public int getVoteCount() {
- return voteCount;
- }
-
- public void setVoteCount(int voteCount) {
- this.voteCount = voteCount;
- }
-
public String getFirstAirDate() {
return firstAirDate;
}
@@ -118,14 +65,6 @@ public class TVBasic extends AbstractJsonMapping {
this.firstAirDate = firstAirDate;
}
- public float getPopularity() {
- return popularity;
- }
-
- public void setPopularity(float popularity) {
- this.popularity = popularity;
- }
-
public List getOriginCountry() {
return originCountry;
}
diff --git a/src/main/java/com/omertron/themoviedbapi/tools/MethodBase.java b/src/main/java/com/omertron/themoviedbapi/tools/MethodBase.java
index a1f7a27a3..c3894b7c2 100644
--- a/src/main/java/com/omertron/themoviedbapi/tools/MethodBase.java
+++ b/src/main/java/com/omertron/themoviedbapi/tools/MethodBase.java
@@ -32,6 +32,7 @@ public enum MethodBase {
CONFIGURATION("configuration"),
CREDIT("credit"),
DISCOVER("discover"),
+ FIND("find"),
GENRE("genre"),
JOB("job"),
KEYWORD("keyword"),
diff --git a/src/main/java/com/omertron/themoviedbapi/tools/Param.java b/src/main/java/com/omertron/themoviedbapi/tools/Param.java
index 6c6b7b729..b84683035 100644
--- a/src/main/java/com/omertron/themoviedbapi/tools/Param.java
+++ b/src/main/java/com/omertron/themoviedbapi/tools/Param.java
@@ -34,6 +34,7 @@ public enum Param {
APPEND("append_to_response="),
COUNTRY("country="),
END_DATE("end_date="),
+ EXTERNAL_SOURCE("external_source="),
FAVORITE("favorite="),
ID("id="),
INCLUDE_ALL_MOVIES("include_all_movies="),
diff --git a/src/test/java/com/omertron/themoviedbapi/TestID.java b/src/test/java/com/omertron/themoviedbapi/TestID.java
new file mode 100644
index 000000000..1c30381a0
--- /dev/null
+++ b/src/test/java/com/omertron/themoviedbapi/TestID.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2004-2015 Stuart Boston
+ *
+ * This file is part of TheMovieDB API.
+ *
+ * TheMovieDB API is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * any later version.
+ *
+ * TheMovieDB API is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TheMovieDB API. If not, see .
+ *
+ */
+package com.omertron.themoviedbapi;
+
+public class TestID {
+
+ private String name;
+ private String imdb;
+ private int tmdb;
+ private String other = null;
+
+ public TestID() {
+ }
+
+ public TestID(String name, String imdb, int tmdb) {
+ this.name = name;
+ this.imdb = imdb;
+ this.tmdb = tmdb;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getImdb() {
+ return imdb;
+ }
+
+ public void setImdb(String imdb) {
+ this.imdb = imdb;
+ }
+
+ public int getTmdb() {
+ return tmdb;
+ }
+
+ public void setTmdb(int tmdb) {
+ this.tmdb = tmdb;
+ }
+
+ public String getOther() {
+ return other;
+ }
+
+ public void setOther(String other) {
+ this.other = other;
+ }
+
+}
diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbFindTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbFindTest.java
index f4215fde0..ccb4f8e20 100644
--- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbFindTest.java
+++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbFindTest.java
@@ -21,9 +21,18 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
+import com.omertron.themoviedbapi.TestID;
+import com.omertron.themoviedbapi.enumeration.ExternalSource;
+import com.omertron.themoviedbapi.model2.FindResults;
+import com.omertron.themoviedbapi.model2.movie.MovieBasic;
+import com.omertron.themoviedbapi.model2.person.PersonFind;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
import org.junit.After;
import org.junit.AfterClass;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -36,6 +45,9 @@ import org.junit.Test;
public class TmdbFindTest extends AbstractTests {
private static TmdbFind instance;
+ private static final List PERSON_IDS = new ArrayList();
+ private static final List FILM_IDS = new ArrayList();
+ private static final List TV_IDS = new ArrayList();
public TmdbFindTest() {
}
@@ -44,6 +56,15 @@ public class TmdbFindTest extends AbstractTests {
public static void setUpClass() throws MovieDbException {
doConfiguration();
instance = new TmdbFind(getApiKey(), getHttpTools());
+
+ PERSON_IDS.add(new TestID("Mila Kunis", "nm0005109", 18973));
+ PERSON_IDS.add(new TestID("Andrew Lincoln", "nm0511088", 7062));
+
+ FILM_IDS.add(new TestID("Jupiter Ascending", "tt1617661", 76757));
+ FILM_IDS.add(new TestID("Lucy", "tt2872732", 240832));
+
+ TV_IDS.add(new TestID("The Walking Dead", "tt1520211", 1402));
+ TV_IDS.add(new TestID("Supernatural", "tt0460681", 1622));
}
@AfterClass
@@ -59,32 +80,76 @@ public class TmdbFindTest extends AbstractTests {
}
/**
- * Test of getMovieChangesList method, of class TmdbFindTest.
+ * Test of Find Movie
+ *
+ * @throws MovieDbException
+ */
+// @Test
+ public void testFindMoviesImdbID() throws MovieDbException {
+ LOG.info("findMoviesImdbID");
+ FindResults result;
+
+ for (TestID test : FILM_IDS) {
+ result = instance.find(test.getImdb(), ExternalSource.IMDB_ID, LANGUAGE_DEFAULT);
+ assertFalse("No movie for ID " + test.getName(), result.getMovieResults().isEmpty());
+ boolean found = false;
+ for (MovieBasic m : result.getMovieResults()) {
+ if (m.getId() == test.getTmdb()) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue("No movie found: " + test.getName(), found);
+ }
+ }
+
+ /**
+ * Test of Find Person
+ *
+ * @throws MovieDbException
+ * @throws IOException
+ */
+// @Test
+ public void testFindPersonImdbID() throws MovieDbException, IOException {
+ LOG.info("findPersonImdbID");
+ FindResults result;
+
+ for (TestID test : PERSON_IDS) {
+ result = instance.find(test.getImdb(), ExternalSource.IMDB_ID, LANGUAGE_DEFAULT);
+ assertFalse("No person for ID: " + test.getName(), result.getPersonResults().isEmpty());
+ boolean found = false;
+ for (PersonFind p : result.getPersonResults()) {
+ if (p.getId() == test.getTmdb()) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue("No person found for ID: " + test.getName(), found);
+ }
+ }
+
+ /**
+ * Test of Find TV
*
* @throws MovieDbException
*/
- @Test
- public void testFindMoviesImdbID() throws MovieDbException {
- LOG.info("findMoviesImdbID");
-// TBD_FindResults result = instance.find("tt0196229", TBD_ExternalSource.imdb_id, "it");
-// assertFalse("No movie for id.", result.getMovieResults().isEmpty());
- fail("The test case is a prototype.");
- }
-
@Test
public void testFindTvSeriesImdbID() throws MovieDbException {
LOG.info("findTvSeriesImdbID");
-// TBD_FindResults result = instance.find("tt1219024", TBD_ExternalSource.imdb_id, "it");
-// assertFalse("No tv for id.", result.getTvResults().isEmpty());
- fail("The test case is a prototype.");
- }
+ FindResults result;
- @Test
- public void testFindPersonImdbID() throws MovieDbException {
- LOG.info("findPersonImdbID");
-// TBD_FindResults result = instance.find("nm0001774", TBD_ExternalSource.imdb_id, "it");
-// assertFalse("No person for id.", result.getPersonResults().isEmpty());
- fail("The test case is a prototype.");
+ for (TestID test : TV_IDS) {
+ result = instance.find(test.getImdb(), ExternalSource.IMDB_ID, LANGUAGE_DEFAULT);
+ assertFalse("No TV Show for ID: " + test.getName(), result.getPersonResults().isEmpty());
+ boolean found = false;
+ for (PersonFind p : result.getPersonResults()) {
+ if (p.getId() == test.getTmdb()) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue("No TV Show found for ID: " + test.getName(), found);
+ }
}
}