Added Last Movie test

This commit is contained in:
Omertron
2012-01-30 12:10:29 +00:00
parent 9c7b339761
commit 20422642d0
6 changed files with 1531 additions and 1521 deletions
File diff suppressed because it is too large Load Diff
@@ -1,173 +1,167 @@
/*
* Copyright (c) 2004-2012 YAMJ Members
* http://code.google.com/p/moviejukebox/people/list
*
* Web: http://code.google.com/p/moviejukebox/
*
* This software is licensed under a Creative Commons License
* See this page: http://code.google.com/p/moviejukebox/wiki/License
*
* For any reuse or distribution, you must make clear to others the
* license terms of this work.
*/
package com.moviejukebox.themoviedb.model;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.codehaus.jackson.annotate.JsonAnySetter;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonRootName;
/**
*
* @author stuart.boston
*/
@JsonRootName("collection")
public class Collection {
/*
* Logger
*/
private static final Logger LOGGER = Logger.getLogger(Collection.class);
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("title")
private String title;
@JsonProperty("name")
private String name;
@JsonProperty("poster_path")
private String posterPath;
@JsonProperty("backdrop_path")
private String backdropPath;
@JsonProperty("release_date")
private String releaseDate;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getBackdropPath() {
return backdropPath;
}
public int getId() {
return id;
}
public String getPosterPath() {
return posterPath;
}
public String getReleaseDate() {
return releaseDate;
}
public String getTitle() {
if (StringUtils.isBlank(title)) {
return name;
}
return title;
}
public String getName() {
if (StringUtils.isBlank(name)) {
return title;
}
return name;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath;
}
public void setId(int id) {
this.id = id;
}
public void setPosterPath(String posterPath) {
this.posterPath = posterPath;
}
public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate;
}
public void setTitle(String title) {
this.title = title;
}
public void setName(String name) {
this.name = name;
}
//</editor-fold>
/**
* Handle unknown properties and print a message
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOGGER.warn(sb.toString());
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Collection other = (Collection) obj;
if ((this.backdropPath == null) ? (other.backdropPath != null) : !this.backdropPath.equals(other.backdropPath)) {
return false;
}
if (this.id != other.id) {
return false;
}
if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
if ((this.posterPath == null) ? (other.posterPath != null) : !this.posterPath.equals(other.posterPath)) {
return false;
}
if ((this.releaseDate == null) ? (other.releaseDate != null) : !this.releaseDate.equals(other.releaseDate)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 19 * hash + (this.backdropPath != null ? this.backdropPath.hashCode() : 0);
hash = 19 * hash + this.id;
hash = 19 * hash + (this.title != null ? this.title.hashCode() : 0);
hash = 19 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 19 * hash + (this.posterPath != null ? this.posterPath.hashCode() : 0);
hash = 19 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0);
return hash;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Collection=");
sb.append("[id=").append(id);
sb.append("],[title=").append(title);
sb.append("],[name=").append(name);
sb.append("],[posterPath=").append(posterPath);
sb.append("],[backdropPath=").append(backdropPath);
sb.append("],[releaseDate=").append(releaseDate);
sb.append("]]");
return sb.toString();
}
}
/*
* Copyright (c) 2004-2012 YAMJ Members
* http://code.google.com/p/moviejukebox/people/list
*
* Web: http://code.google.com/p/moviejukebox/
*
* This software is licensed under a Creative Commons License
* See this page: http://code.google.com/p/moviejukebox/wiki/License
*
* For any reuse or distribution, you must make clear to others the
* license terms of this work.
*/
package com.moviejukebox.themoviedb.model;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.codehaus.jackson.annotate.JsonAnySetter;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonRootName;
/**
*
* @author stuart.boston
*/
@JsonRootName("collection")
public class Collection {
/*
* Logger
*/
private static final Logger LOGGER = Logger.getLogger(Collection.class);
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("title")
private String title;
@JsonProperty("name")
private String name;
@JsonProperty("poster_path")
private String posterPath;
@JsonProperty("backdrop_path")
private String backdropPath;
@JsonProperty("release_date")
private String releaseDate;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getBackdropPath() {
return backdropPath;
}
public int getId() {
return id;
}
public String getPosterPath() {
return posterPath;
}
public String getReleaseDate() {
return releaseDate;
}
public String getTitle() {
if (StringUtils.isBlank(title)) {
return name;
}
return title;
}
public String getName() {
if (StringUtils.isBlank(name)) {
return title;
}
return name;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath;
}
public void setId(int id) {
this.id = id;
}
public void setPosterPath(String posterPath) {
this.posterPath = posterPath;
}
public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate;
}
public void setTitle(String title) {
this.title = title;
}
public void setName(String name) {
this.name = name;
}
//</editor-fold>
/**
* Handle unknown properties and print a message
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOGGER.warn(sb.toString());
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Collection other = (Collection) obj;
if ((this.backdropPath == null) ? (other.backdropPath != null) : !this.backdropPath.equals(other.backdropPath)) {
return false;
}
if (this.id != other.id) {
return false;
}
if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 19 * hash + (this.backdropPath != null ? this.backdropPath.hashCode() : 0);
hash = 19 * hash + this.id;
hash = 19 * hash + (this.title != null ? this.title.hashCode() : 0);
hash = 19 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 19 * hash + (this.posterPath != null ? this.posterPath.hashCode() : 0);
hash = 19 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0);
return hash;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Collection=");
sb.append("[id=").append(id);
sb.append("],[title=").append(title);
sb.append("],[name=").append(name);
sb.append("],[posterPath=").append(posterPath);
sb.append("],[backdropPath=").append(backdropPath);
sb.append("],[releaseDate=").append(releaseDate);
sb.append("]]");
return sb.toString();
}
}
@@ -1,149 +1,146 @@
/*
* Copyright (c) 2004-2012 YAMJ Members
* http://code.google.com/p/moviejukebox/people/list
*
* Web: http://code.google.com/p/moviejukebox/
*
* This software is licensed under a Creative Commons License
* See this page: http://code.google.com/p/moviejukebox/wiki/License
*
* For any reuse or distribution, you must make clear to others the
* license terms of this work.
*/
package com.moviejukebox.themoviedb.model;
import org.apache.log4j.Logger;
import org.codehaus.jackson.annotate.JsonAnySetter;
import org.codehaus.jackson.annotate.JsonProperty;
/**
*
* @author Stuart
*/
public class PersonCrew {
/*
* Logger
*/
private static final Logger LOGGER = Logger.getLogger(PersonCrew.class);
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("department")
private String department;
@JsonProperty("job")
private String job;
@JsonProperty("name")
private String name;
@JsonProperty("profile_path")
private String profilePath;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getDepartment() {
return department;
}
public int getId() {
return id;
}
public String getJob() {
return job;
}
public String getName() {
return name;
}
public String getProfilePath() {
return profilePath;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setDepartment(String department) {
this.department = department;
}
public void setId(int id) {
this.id = id;
}
public void setJob(String job) {
this.job = job;
}
public void setName(String name) {
this.name = name;
}
public void setProfilePath(String profilePath) {
this.profilePath = profilePath;
}
//</editor-fold>
/**
* Handle unknown properties and print a message
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOGGER.warn(sb.toString());
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final PersonCrew other = (PersonCrew) obj;
if (this.id != other.id) {
return false;
}
if ((this.department == null) ? (other.department != null) : !this.department.equals(other.department)) {
return false;
}
if ((this.job == null) ? (other.job != null) : !this.job.equals(other.job)) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 59 * hash + this.id;
hash = 59 * hash + (this.department != null ? this.department.hashCode() : 0);
hash = 59 * hash + (this.job != null ? this.job.hashCode() : 0);
hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 59 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
return hash;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[PersonCrew=");
sb.append("id=").append(id);
sb.append("],[department=").append(department);
sb.append("],[job=").append(job);
sb.append("],[name=").append(name);
sb.append("],[profilePath=").append(profilePath);
sb.append("]]");
return sb.toString();
}
}
/*
* Copyright (c) 2004-2012 YAMJ Members
* http://code.google.com/p/moviejukebox/people/list
*
* Web: http://code.google.com/p/moviejukebox/
*
* This software is licensed under a Creative Commons License
* See this page: http://code.google.com/p/moviejukebox/wiki/License
*
* For any reuse or distribution, you must make clear to others the
* license terms of this work.
*/
package com.moviejukebox.themoviedb.model;
import org.apache.log4j.Logger;
import org.codehaus.jackson.annotate.JsonAnySetter;
import org.codehaus.jackson.annotate.JsonProperty;
/**
*
* @author Stuart
*/
public class PersonCrew {
/*
* Logger
*/
private static final Logger LOGGER = Logger.getLogger(PersonCrew.class);
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("department")
private String department;
@JsonProperty("job")
private String job;
@JsonProperty("name")
private String name;
@JsonProperty("profile_path")
private String profilePath;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getDepartment() {
return department;
}
public int getId() {
return id;
}
public String getJob() {
return job;
}
public String getName() {
return name;
}
public String getProfilePath() {
return profilePath;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setDepartment(String department) {
this.department = department;
}
public void setId(int id) {
this.id = id;
}
public void setJob(String job) {
this.job = job;
}
public void setName(String name) {
this.name = name;
}
public void setProfilePath(String profilePath) {
this.profilePath = profilePath;
}
//</editor-fold>
/**
* Handle unknown properties and print a message
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOGGER.warn(sb.toString());
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final PersonCrew other = (PersonCrew) obj;
if (this.id != other.id) {
return false;
}
if ((this.department == null) ? (other.department != null) : !this.department.equals(other.department)) {
return false;
}
if ((this.job == null) ? (other.job != null) : !this.job.equals(other.job)) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 59 * hash + this.id;
hash = 59 * hash + (this.department != null ? this.department.hashCode() : 0);
hash = 59 * hash + (this.job != null ? this.job.hashCode() : 0);
hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 59 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
return hash;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[PersonCrew=");
sb.append("id=").append(id);
sb.append("],[department=").append(department);
sb.append("],[job=").append(job);
sb.append("],[name=").append(name);
sb.append("],[profilePath=").append(profilePath);
sb.append("]]");
return sb.toString();
}
}
@@ -1,134 +1,131 @@
/*
* Copyright (c) 2004-2012 YAMJ Members
* http://code.google.com/p/moviejukebox/people/list
*
* Web: http://code.google.com/p/moviejukebox/
*
* This software is licensed under a Creative Commons License
* See this page: http://code.google.com/p/moviejukebox/wiki/License
*
* For any reuse or distribution, you must make clear to others the
* license terms of this work.
*/
package com.moviejukebox.themoviedb.model;
import org.apache.log4j.Logger;
import org.codehaus.jackson.annotate.JsonAnySetter;
/**
*
* @author Stuart
*/
public class Trailer {
/*
* Logger
*/
private static final Logger LOGGER = Logger.getLogger(Trailer.class);
/*
* Website sources
*/
public static final String WEBSITE_YOUTUBE = "youtube";
public static final String WEBSITE_QUICKTIME = "quicktime";
/*
* Properties
*/
private String name;
private String size;
private String source;
private String website; // The website of the trailer
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getName() {
return name;
}
public String getSize() {
return size;
}
public String getSource() {
return source;
}
public String getWebsite() {
return website;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setName(String name) {
this.name = name;
}
public void setSize(String size) {
this.size = size;
}
public void setSource(String source) {
this.source = source;
}
public void setWebsite(String website) {
this.website = website;
}
//</editor-fold>
/**
* Handle unknown properties and print a message
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOGGER.warn(sb.toString());
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Trailer other = (Trailer) obj;
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
if ((this.size == null) ? (other.size != null) : !this.size.equals(other.size)) {
return false;
}
if ((this.source == null) ? (other.source != null) : !this.source.equals(other.source)) {
return false;
}
if ((this.website == null) ? (other.website != null) : !this.website.equals(other.website)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 61 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 61 * hash + (this.size != null ? this.size.hashCode() : 0);
hash = 61 * hash + (this.source != null ? this.source.hashCode() : 0);
hash = 61 * hash + (this.website != null ? this.website.hashCode() : 0);
return hash;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Trailer=");
sb.append("name=").append(name);
sb.append("],[size=").append(size);
sb.append("],[source=").append(source);
sb.append("],[website=").append(website);
sb.append("]]");
return sb.toString();
}
}
/*
* Copyright (c) 2004-2012 YAMJ Members
* http://code.google.com/p/moviejukebox/people/list
*
* Web: http://code.google.com/p/moviejukebox/
*
* This software is licensed under a Creative Commons License
* See this page: http://code.google.com/p/moviejukebox/wiki/License
*
* For any reuse or distribution, you must make clear to others the
* license terms of this work.
*/
package com.moviejukebox.themoviedb.model;
import org.apache.log4j.Logger;
import org.codehaus.jackson.annotate.JsonAnySetter;
/**
*
* @author Stuart
*/
public class Trailer {
/*
* Logger
*/
private static final Logger LOGGER = Logger.getLogger(Trailer.class);
/*
* Website sources
*/
public static final String WEBSITE_YOUTUBE = "youtube";
public static final String WEBSITE_QUICKTIME = "quicktime";
/*
* Properties
*/
private String name;
private String size;
private String source;
private String website; // The website of the trailer
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getName() {
return name;
}
public String getSize() {
return size;
}
public String getSource() {
return source;
}
public String getWebsite() {
return website;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setName(String name) {
this.name = name;
}
public void setSize(String size) {
this.size = size;
}
public void setSource(String source) {
this.source = source;
}
public void setWebsite(String website) {
this.website = website;
}
//</editor-fold>
/**
* Handle unknown properties and print a message
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOGGER.warn(sb.toString());
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Trailer other = (Trailer) obj;
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
if ((this.size == null) ? (other.size != null) : !this.size.equals(other.size)) {
return false;
}
if ((this.source == null) ? (other.source != null) : !this.source.equals(other.source)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 61 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 61 * hash + (this.size != null ? this.size.hashCode() : 0);
hash = 61 * hash + (this.source != null ? this.source.hashCode() : 0);
hash = 61 * hash + (this.website != null ? this.website.hashCode() : 0);
return hash;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Trailer=");
sb.append("name=").append(name);
sb.append("],[size=").append(size);
sb.append("],[source=").append(source);
sb.append("],[website=").append(website);
sb.append("]]");
return sb.toString();
}
}
@@ -1,248 +1,248 @@
/*
* Copyright (c) 2004-2012 YAMJ Members
* http://code.google.com/p/moviejukebox/people/list
*
* Web: http://code.google.com/p/moviejukebox/
*
* This software is licensed under a Creative Commons License
* See this page: http://code.google.com/p/moviejukebox/wiki/License
*
* For any reuse or distribution, you must make clear to others the
* license terms of this work.
*/
package com.moviejukebox.themoviedb.tools;
import com.moviejukebox.themoviedb.TheMovieDb;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
/**
* The API URL that is used to construct the API call
*
* @author Stuart
*/
public class ApiUrl {
/*
* Logger
*/
private static final Logger LOGGER = Logger.getLogger(ApiUrl.class);
/*
* TheMovieDb API Base URL
*/
private final String TMDB_API_BASE = "http://api.themoviedb.org/3/";
/*
* Parameter configuration
*/
private static final String DELIMITER_FIRST = "?";
private static final String DELIMITER_SUBSEQUENT = "&";
private static final String PARAMETER_API_KEY = "api_key="; // The API Key is always needed and always first
private static final String PARAMETER_QUERY = "query=";
private static final String PARAMETER_LANGUAGE = DELIMITER_SUBSEQUENT + "language=";
private static final String PARAMETER_COUNTRY = DELIMITER_SUBSEQUENT + "country=";
private static final String PARAMETER_PAGE = DELIMITER_SUBSEQUENT + "page=";
private static final String DEFAULT_STRING = "";
private static final int DEFAULT_INT = -1;
/*
* Properties
*/
private String method;
private String submethod;
private TheMovieDb TMDb;
//<editor-fold defaultstate="collapsed" desc="Constructor Methods">
/**
* Constructor for the simple API URL method without a sub-method
* @param method
*/
public ApiUrl(TheMovieDb TMDb, String method) {
this.TMDb = TMDb;
this.method = method;
this.submethod = DEFAULT_STRING;
}
/**
* Constructor for the API URL with a sub-method
* @param method
* @param submethod
*/
public ApiUrl(TheMovieDb TMDb, String method, String submethod) {
this.TMDb = TMDb;
this.method = method;
this.submethod = submethod;
}
//</editor-fold>
/**
* Create the full URL with the API.
*
* @param query
* @param tmdbId
* @param language
* @param country
* @param page
* @return
*/
private URL getFullUrl(String query, String movieId, String language, String country, int page) {
StringBuilder urlString = new StringBuilder(TMDB_API_BASE);
// Get the start of the URL
urlString.append(method);
// Append the search term if required
if (StringUtils.isNotBlank(query)) {
urlString.append(DELIMITER_FIRST);
urlString.append(PARAMETER_QUERY);
try {
urlString.append(URLEncoder.encode(query, "UTF-8"));
} catch (UnsupportedEncodingException ex) {
// If we can't encode it, try it raw
urlString.append(query);
}
}
// Append the ID if provided
if (StringUtils.isNotBlank(movieId)) {
urlString.append(movieId);
}
// Append the suffix of the API URL
urlString.append(submethod);
// Append the key information
if (StringUtils.isBlank(query)) {
// This is the first parameter
urlString.append(DELIMITER_FIRST);
} else {
// The first parameter was the query
urlString.append(DELIMITER_SUBSEQUENT);
}
urlString.append(PARAMETER_API_KEY);
urlString.append(TMDb.getApiKey());
// Append the language to the URL
if (StringUtils.isNotBlank(language)) {
urlString.append(PARAMETER_LANGUAGE);
urlString.append(language);
}
// Append the country to the URL
if (StringUtils.isNotBlank(country)) {
urlString.append(PARAMETER_COUNTRY);
urlString.append(country);
}
// Append the page to the URL
if (page > DEFAULT_INT) {
urlString.append(PARAMETER_PAGE);
urlString.append(page);
}
try {
LOGGER.trace("URL: " + urlString.toString());
return new URL(urlString.toString());
} catch (MalformedURLException ex) {
LOGGER.warn("Failed to create URL " + urlString.toString());
return null;
}
}
/**
* Create an URL using the query (string), language and page
*
* @param query
* @param language
* @param page
* @return
*/
public URL getQueryUrl(String query, String language, int page) {
return getFullUrl(query, DEFAULT_STRING, language, null, page);
}
/**
* Create an URL using the query (string)
* @param query
* @return
*/
public URL getQueryUrl(String query) {
return getQueryUrl(query, DEFAULT_STRING, DEFAULT_INT);
}
/**
* Create an URL using the query (string) and language
* @param query
* @param language
* @return
*/
public URL getQueryUrl(String query, String language) {
return getQueryUrl(query, language, DEFAULT_INT);
}
/**
* Create an URL using the movie ID, language and country code
*
* @param movieId
* @param language
* @param country
* @return
*/
public URL getIdUrl(String movieId, String language, String country) {
return getFullUrl(DEFAULT_STRING, movieId, language, country, DEFAULT_INT);
}
/**
* Create an URL using the movie ID and language
* @param movieId
* @param language
* @return
*/
public URL getIdUrl(String movieId, String language) {
return getIdUrl(movieId, language, DEFAULT_STRING);
}
/**
* Create an URL using the movie ID
* @param movieId
* @return
*/
public URL getIdUrl(String movieId) {
return getIdUrl(movieId, DEFAULT_STRING, DEFAULT_STRING);
}
/**
* Create an URL using the movie ID, language and country code
*
* @param movieId
* @param language
* @param country
* @return
*/
public URL getIdUrl(int movieId, String language, String country) {
return getIdUrl(String.valueOf(movieId), language, country);
}
/**
* Create an URL using the movie ID and language
* @param movieId
* @param language
* @return
*/
public URL getIdUrl(int movieId, String language) {
return getIdUrl(String.valueOf(movieId), language, DEFAULT_STRING);
}
/**
* Create an URL using the movie ID
* @param movieId
* @return
*/
public URL getIdUrl(int movieId) {
return getIdUrl(String.valueOf(movieId), DEFAULT_STRING, DEFAULT_STRING);
}
}
/*
* Copyright (c) 2004-2012 YAMJ Members
* http://code.google.com/p/moviejukebox/people/list
*
* Web: http://code.google.com/p/moviejukebox/
*
* This software is licensed under a Creative Commons License
* See this page: http://code.google.com/p/moviejukebox/wiki/License
*
* For any reuse or distribution, you must make clear to others the
* license terms of this work.
*/
package com.moviejukebox.themoviedb.tools;
import com.moviejukebox.themoviedb.TheMovieDb;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
/**
* The API URL that is used to construct the API call
*
* @author Stuart
*/
public class ApiUrl {
/*
* Logger
*/
private static final Logger LOGGER = Logger.getLogger(ApiUrl.class);
/*
* TheMovieDb API Base URL
*/
private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/";
/*
* Parameter configuration
*/
private static final String DELIMITER_FIRST = "?";
private static final String DELIMITER_SUBSEQUENT = "&";
private static final String PARAMETER_API_KEY = "api_key="; // The API Key is always needed and always first
private static final String PARAMETER_QUERY = "query=";
private static final String PARAMETER_LANGUAGE = DELIMITER_SUBSEQUENT + "language=";
private static final String PARAMETER_COUNTRY = DELIMITER_SUBSEQUENT + "country=";
private static final String PARAMETER_PAGE = DELIMITER_SUBSEQUENT + "page=";
private static final String DEFAULT_STRING = "";
private static final int DEFAULT_INT = -1;
/*
* Properties
*/
private String method;
private String submethod;
private TheMovieDb tmdb;
//<editor-fold defaultstate="collapsed" desc="Constructor Methods">
/**
* Constructor for the simple API URL method without a sub-method
* @param method
*/
public ApiUrl(TheMovieDb tmdb, String method) {
this.tmdb = tmdb;
this.method = method;
this.submethod = DEFAULT_STRING;
}
/**
* Constructor for the API URL with a sub-method
* @param method
* @param submethod
*/
public ApiUrl(TheMovieDb tmdb, String method, String submethod) {
this.tmdb = tmdb;
this.method = method;
this.submethod = submethod;
}
//</editor-fold>
/**
* Create the full URL with the API.
*
* @param query
* @param tmdbId
* @param language
* @param country
* @param page
* @return
*/
private URL getFullUrl(String query, String movieId, String language, String country, int page) {
StringBuilder urlString = new StringBuilder(TMDB_API_BASE);
// Get the start of the URL
urlString.append(method);
// Append the search term if required
if (StringUtils.isNotBlank(query)) {
urlString.append(DELIMITER_FIRST);
urlString.append(PARAMETER_QUERY);
try {
urlString.append(URLEncoder.encode(query, "UTF-8"));
} catch (UnsupportedEncodingException ex) {
// If we can't encode it, try it raw
urlString.append(query);
}
}
// Append the ID if provided
if (StringUtils.isNotBlank(movieId)) {
urlString.append(movieId);
}
// Append the suffix of the API URL
urlString.append(submethod);
// Append the key information
if (StringUtils.isBlank(query)) {
// This is the first parameter
urlString.append(DELIMITER_FIRST);
} else {
// The first parameter was the query
urlString.append(DELIMITER_SUBSEQUENT);
}
urlString.append(PARAMETER_API_KEY);
urlString.append(tmdb.getApiKey());
// Append the language to the URL
if (StringUtils.isNotBlank(language)) {
urlString.append(PARAMETER_LANGUAGE);
urlString.append(language);
}
// Append the country to the URL
if (StringUtils.isNotBlank(country)) {
urlString.append(PARAMETER_COUNTRY);
urlString.append(country);
}
// Append the page to the URL
if (page > DEFAULT_INT) {
urlString.append(PARAMETER_PAGE);
urlString.append(page);
}
try {
LOGGER.trace("URL: " + urlString.toString());
return new URL(urlString.toString());
} catch (MalformedURLException ex) {
LOGGER.warn("Failed to create URL " + urlString.toString());
return null;
}
}
/**
* Create an URL using the query (string), language and page
*
* @param query
* @param language
* @param page
* @return
*/
public URL getQueryUrl(String query, String language, int page) {
return getFullUrl(query, DEFAULT_STRING, language, null, page);
}
/**
* Create an URL using the query (string)
* @param query
* @return
*/
public URL getQueryUrl(String query) {
return getQueryUrl(query, DEFAULT_STRING, DEFAULT_INT);
}
/**
* Create an URL using the query (string) and language
* @param query
* @param language
* @return
*/
public URL getQueryUrl(String query, String language) {
return getQueryUrl(query, language, DEFAULT_INT);
}
/**
* Create an URL using the movie ID, language and country code
*
* @param movieId
* @param language
* @param country
* @return
*/
public URL getIdUrl(String movieId, String language, String country) {
return getFullUrl(DEFAULT_STRING, movieId, language, country, DEFAULT_INT);
}
/**
* Create an URL using the movie ID and language
* @param movieId
* @param language
* @return
*/
public URL getIdUrl(String movieId, String language) {
return getIdUrl(movieId, language, DEFAULT_STRING);
}
/**
* Create an URL using the movie ID
* @param movieId
* @return
*/
public URL getIdUrl(String movieId) {
return getIdUrl(movieId, DEFAULT_STRING, DEFAULT_STRING);
}
/**
* Create an URL using the movie ID, language and country code
*
* @param movieId
* @param language
* @param country
* @return
*/
public URL getIdUrl(int movieId, String language, String country) {
return getIdUrl(String.valueOf(movieId), language, country);
}
/**
* Create an URL using the movie ID and language
* @param movieId
* @param language
* @return
*/
public URL getIdUrl(int movieId, String language) {
return getIdUrl(String.valueOf(movieId), language, DEFAULT_STRING);
}
/**
* Create an URL using the movie ID
* @param movieId
* @return
*/
public URL getIdUrl(int movieId) {
return getIdUrl(String.valueOf(movieId), DEFAULT_STRING, DEFAULT_STRING);
}
}
@@ -1,299 +1,317 @@
/*
* Copyright (c) 2004-2012 YAMJ Members
* http://code.google.com/p/moviejukebox/people/list
*
* Web: http://code.google.com/p/moviejukebox/
*
* This software is licensed under a Creative Commons License
* See this page: http://code.google.com/p/moviejukebox/wiki/License
*
* For any reuse or distribution, you must make clear to others the
* license terms of this work.
*/
package com.moviejukebox.themoviedb;
import com.moviejukebox.themoviedb.model.*;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import static org.junit.Assert.*;
import org.junit.*;
/**
* Test cases for TheMovieDb API
*
* @author stuart.boston
*/
public class TheMovieDbTest {
private static final Logger LOGGER = Logger.getLogger(TheMovieDbTest.class);
private static final String API_KEY = "5a1a77e2eba8984804586122754f969f";
private static TheMovieDb tmdb;
/*
* Test data
*/
private static final int ID_BLADE_RUNNER = 78;
private static final int ID_STAR_WARS_COLLECTION = 10;
private static final int ID_BRUCE_WILLIS = 62;
public TheMovieDbTest() throws IOException {
tmdb = new TheMovieDb(API_KEY);
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of getConfiguration method, of class TheMovieDb.
*/
@Test
public void testConfiguration() throws IOException {
LOGGER.info("Test Configuration");
TmdbConfiguration tmdbConfig = tmdb.getConfiguration();
assertNotNull("Configuration failed", tmdbConfig);
assertTrue("No base URL", StringUtils.isNotBlank(tmdbConfig.getBaseUrl()));
assertTrue("No backdrop sizes", tmdbConfig.getBackdropSizes().size() > 0);
assertTrue("No poster sizes", tmdbConfig.getPosterSizes().size() > 0);
assertTrue("No profile sizes", tmdbConfig.getProfileSizes().size() > 0);
LOGGER.info(tmdbConfig.toString());
}
/**
* Test of searchMovie method, of class TheMovieDb.
*/
@Test
public void testSearchMovie() throws UnsupportedEncodingException {
LOGGER.info("searchMovie");
// Try a movie with less than 1 page of results
List<MovieDb> movieList = tmdb.searchMovie("Blade Runner", "", true);
assertTrue("No movies found, should be at least 1", movieList.size() > 0);
// Try a russian langugage movie
movieList = tmdb.searchMovie("О чём говорят мужчины", "ru", true);
assertTrue("No movies found, should be at least 1", movieList.size() > 0);
// Try a movie with more than 20 results
movieList = tmdb.searchMovie("Star Wars", "en", false);
assertTrue("Not enough movies found, should be 20", movieList.size() == 20);
}
/**
* Test of getMovieInfo method, of class TheMovieDb.
*/
@Test
public void testGetMovieInfo() {
LOGGER.info("getMovieInfo");
String language = "en";
MovieDb result = tmdb.getMovieInfo(ID_BLADE_RUNNER, language);
assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle());
}
/**
* Test of getMovieAlternativeTitles method, of class TheMovieDb.
*/
@Test
public void testGetMovieAlternativeTitles() {
LOGGER.info("getMovieAlternativeTitles");
String country = "";
List<AlternativeTitle> results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country);
assertTrue("No alternative titles found", results.size() > 0);
country = "US";
results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country);
assertTrue("No alternative titles found", results.size() > 0);
}
/**
* Test of getMovieCasts method, of class TheMovieDb.
*/
@Test
public void testGetMovieCasts() {
LOGGER.info("getMovieCasts");
List<Person> people = tmdb.getMovieCasts(ID_BLADE_RUNNER);
assertTrue("No cast information", people.size() > 0);
String name1 = "Harrison Ford";
String name2 = "Charles Knode";
boolean foundName1 = Boolean.FALSE;
boolean foundName2 = Boolean.FALSE;
for (Person person : people) {
if (!foundName1 && person.getName().equalsIgnoreCase(name1)) {
foundName1 = Boolean.TRUE;
}
if (!foundName2 && person.getName().equalsIgnoreCase(name2)) {
foundName2 = Boolean.TRUE;
}
}
assertTrue("Couldn't find " + name1, foundName1);
assertTrue("Couldn't find " + name2, foundName2);
}
/**
* Test of getMovieImages method, of class TheMovieDb.
*/
@Test
public void testGetMovieImages() {
LOGGER.info("getMovieImages");
String language = "";
List<Artwork> result = tmdb.getMovieImages(ID_BLADE_RUNNER, language);
assertFalse("No artwork found", result.isEmpty());
}
/**
* Test of getMovieKeywords method, of class TheMovieDb.
*/
@Test
public void testGetMovieKeywords() {
LOGGER.info("getMovieKeywords");
List<Keyword> result = tmdb.getMovieKeywords(ID_BLADE_RUNNER);
assertFalse("No keywords found", result.isEmpty());
}
/**
* Test of getMovieReleaseInfo method, of class TheMovieDb.
*/
@Test
public void testGetMovieReleaseInfo() {
LOGGER.info("getMovieReleaseInfo");
List<ReleaseInfo> result = tmdb.getMovieReleaseInfo(ID_BLADE_RUNNER, "");
assertFalse("Release information missing", result.isEmpty());
}
/**
* Test of getMovieTrailers method, of class TheMovieDb.
*/
@Test
public void testGetMovieTrailers() {
LOGGER.info("getMovieTrailers");
List<Trailer> result = tmdb.getMovieTrailers(ID_BLADE_RUNNER, "");
assertFalse("Movie trailers missing", result.isEmpty());
}
/**
* Test of getMovieTranslations method, of class TheMovieDb.
*/
@Test
public void testGetMovieTranslations() {
LOGGER.info("getMovieTranslations");
List<Translation> result = tmdb.getMovieTranslations(ID_BLADE_RUNNER);
assertFalse("No translations found", result.isEmpty());
}
/**
* Test of getCollectionInfo method, of class TheMovieDb.
*/
@Test
public void testGetCollectionInfo() {
LOGGER.info("getCollectionInfo");
String language = "";
CollectionInfo result = tmdb.getCollectionInfo(ID_STAR_WARS_COLLECTION, language);
assertFalse("No collection information", result.getParts().isEmpty());
}
@Test
public void testCreateImageUrl() {
LOGGER.info("createImageUrl");
MovieDb movie = tmdb.getMovieInfo(ID_BLADE_RUNNER, "");
String result = tmdb.createImageUrl(movie.getPosterPath(), "original").toString();
assertTrue("Error compiling image URL", !result.isEmpty());
}
/**
* Test of getMovieInfoImdb method, of class TheMovieDb.
*/
@Test
public void testGetMovieInfoImdb() {
LOGGER.info("getMovieInfoImdb");
MovieDb result = tmdb.getMovieInfoImdb("tt0076759", "en-US");
assertTrue("Error getting the movie from IMDB ID", result.getId() == 11);
}
/**
* Test of getApiKey method, of class TheMovieDb.
*/
@Test
public void testGetApiKey() {
// Not required
}
/**
* Test of getApiBase method, of class TheMovieDb.
*/
@Test
public void testGetApiBase() {
// Not required
}
/**
* Test of getConfiguration method, of class TheMovieDb.
*/
@Test
public void testGetConfiguration() {
// Not required
}
/**
* Test of searchPeople method, of class TheMovieDb.
*/
@Test
public void testSearchPeople() {
LOGGER.info("searchPeople");
String personName = "Bruce Willis";
boolean allResults = false;
List<Person> result = tmdb.searchPeople(personName, allResults);
assertTrue("Couldn't find the person", result.size() > 0);
}
/**
* Test of getPersonInfo method, of class TheMovieDb.
*/
@Test
public void testGetPersonInfo() {
LOGGER.info("getPersonInfo");
Person result = tmdb.getPersonInfo(ID_BRUCE_WILLIS);
assertTrue("Wrong actor returned", result.getId() == ID_BRUCE_WILLIS);
}
/**
* Test of getPersonCredits method, of class TheMovieDb.
*/
@Test
public void testGetPersonCredits() {
LOGGER.info("getPersonCredits");
List<PersonCredit> people = tmdb.getPersonCredits(ID_BRUCE_WILLIS);
assertTrue("No cast information", people.size() > 0);
}
/**
* Test of getPersonImages method, of class TheMovieDb.
*/
@Test
public void testGetPersonImages() {
LOGGER.info("getPersonImages");
List<Artwork> artwork = tmdb.getPersonImages(ID_BRUCE_WILLIS);
assertTrue("No cast information", artwork.size() > 0);
}
}
/*
* Copyright (c) 2004-2012 YAMJ Members
* http://code.google.com/p/moviejukebox/people/list
*
* Web: http://code.google.com/p/moviejukebox/
*
* This software is licensed under a Creative Commons License
* See this page: http://code.google.com/p/moviejukebox/wiki/License
*
* For any reuse or distribution, you must make clear to others the
* license terms of this work.
*/
package com.moviejukebox.themoviedb;
import com.moviejukebox.themoviedb.model.*;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import static org.junit.Assert.*;
import org.junit.*;
/**
* Test cases for TheMovieDb API
*
* @author stuart.boston
*/
public class TheMovieDbTest {
private static final Logger LOGGER = Logger.getLogger(TheMovieDbTest.class);
private static final String API_KEY = "5a1a77e2eba8984804586122754f969f";
private static TheMovieDb tmdb;
/*
* Test data
*/
private static final int ID_BLADE_RUNNER = 78;
private static final int ID_STAR_WARS_COLLECTION = 10;
private static final int ID_BRUCE_WILLIS = 62;
public TheMovieDbTest() throws IOException {
tmdb = new TheMovieDb(API_KEY);
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of getConfiguration method, of class TheMovieDb.
*/
@Test
public void testConfiguration() throws IOException {
LOGGER.info("Test Configuration");
TmdbConfiguration tmdbConfig = tmdb.getConfiguration();
assertNotNull("Configuration failed", tmdbConfig);
assertTrue("No base URL", StringUtils.isNotBlank(tmdbConfig.getBaseUrl()));
assertTrue("No backdrop sizes", tmdbConfig.getBackdropSizes().size() > 0);
assertTrue("No poster sizes", tmdbConfig.getPosterSizes().size() > 0);
assertTrue("No profile sizes", tmdbConfig.getProfileSizes().size() > 0);
LOGGER.info(tmdbConfig.toString());
}
/**
* Test of searchMovie method, of class TheMovieDb.
*/
@Test
public void testSearchMovie() throws UnsupportedEncodingException {
LOGGER.info("searchMovie");
// Try a movie with less than 1 page of results
List<MovieDb> movieList = tmdb.searchMovie("Blade Runner", "", true);
assertTrue("No movies found, should be at least 1", movieList.size() > 0);
// Try a russian langugage movie
movieList = tmdb.searchMovie("О чём говорят мужчины", "ru", true);
assertTrue("No movies found, should be at least 1", movieList.size() > 0);
// Try a movie with more than 20 results
movieList = tmdb.searchMovie("Star Wars", "en", false);
assertTrue("Not enough movies found, should be 20", movieList.size() == 20);
}
/**
* Test of getMovieInfo method, of class TheMovieDb.
*/
@Test
public void testGetMovieInfo() {
LOGGER.info("getMovieInfo");
String language = "en";
MovieDb result = tmdb.getMovieInfo(ID_BLADE_RUNNER, language);
assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle());
}
/**
* Test of getMovieAlternativeTitles method, of class TheMovieDb.
*/
@Test
public void testGetMovieAlternativeTitles() {
LOGGER.info("getMovieAlternativeTitles");
String country = "";
List<AlternativeTitle> results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country);
assertTrue("No alternative titles found", results.size() > 0);
country = "US";
results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country);
assertTrue("No alternative titles found", results.size() > 0);
}
/**
* Test of getMovieCasts method, of class TheMovieDb.
*/
@Test
public void testGetMovieCasts() {
LOGGER.info("getMovieCasts");
List<Person> people = tmdb.getMovieCasts(ID_BLADE_RUNNER);
assertTrue("No cast information", people.size() > 0);
String name1 = "Harrison Ford";
String name2 = "Charles Knode";
boolean foundName1 = Boolean.FALSE;
boolean foundName2 = Boolean.FALSE;
for (Person person : people) {
if (!foundName1 && person.getName().equalsIgnoreCase(name1)) {
foundName1 = Boolean.TRUE;
}
if (!foundName2 && person.getName().equalsIgnoreCase(name2)) {
foundName2 = Boolean.TRUE;
}
}
assertTrue("Couldn't find " + name1, foundName1);
assertTrue("Couldn't find " + name2, foundName2);
}
/**
* Test of getMovieImages method, of class TheMovieDb.
*/
@Test
public void testGetMovieImages() {
LOGGER.info("getMovieImages");
String language = "";
List<Artwork> result = tmdb.getMovieImages(ID_BLADE_RUNNER, language);
assertFalse("No artwork found", result.isEmpty());
}
/**
* Test of getMovieKeywords method, of class TheMovieDb.
*/
@Test
public void testGetMovieKeywords() {
LOGGER.info("getMovieKeywords");
List<Keyword> result = tmdb.getMovieKeywords(ID_BLADE_RUNNER);
assertFalse("No keywords found", result.isEmpty());
}
/**
* Test of getMovieReleaseInfo method, of class TheMovieDb.
*/
@Test
public void testGetMovieReleaseInfo() {
LOGGER.info("getMovieReleaseInfo");
List<ReleaseInfo> result = tmdb.getMovieReleaseInfo(ID_BLADE_RUNNER, "");
assertFalse("Release information missing", result.isEmpty());
}
/**
* Test of getMovieTrailers method, of class TheMovieDb.
*/
@Test
public void testGetMovieTrailers() {
LOGGER.info("getMovieTrailers");
List<Trailer> result = tmdb.getMovieTrailers(ID_BLADE_RUNNER, "");
assertFalse("Movie trailers missing", result.isEmpty());
}
/**
* Test of getMovieTranslations method, of class TheMovieDb.
*/
@Test
public void testGetMovieTranslations() {
LOGGER.info("getMovieTranslations");
List<Translation> result = tmdb.getMovieTranslations(ID_BLADE_RUNNER);
assertFalse("No translations found", result.isEmpty());
}
/**
* Test of getCollectionInfo method, of class TheMovieDb.
*/
@Test
public void testGetCollectionInfo() {
LOGGER.info("getCollectionInfo");
String language = "";
CollectionInfo result = tmdb.getCollectionInfo(ID_STAR_WARS_COLLECTION, language);
assertFalse("No collection information", result.getParts().isEmpty());
}
@Test
public void testCreateImageUrl() {
LOGGER.info("createImageUrl");
MovieDb movie = tmdb.getMovieInfo(ID_BLADE_RUNNER, "");
String result = tmdb.createImageUrl(movie.getPosterPath(), "original").toString();
assertTrue("Error compiling image URL", !result.isEmpty());
}
/**
* Test of getMovieInfoImdb method, of class TheMovieDb.
*/
@Test
public void testGetMovieInfoImdb() {
LOGGER.info("getMovieInfoImdb");
MovieDb result = tmdb.getMovieInfoImdb("tt0076759", "en-US");
assertTrue("Error getting the movie from IMDB ID", result.getId() == 11);
}
/**
* Test of getApiKey method, of class TheMovieDb.
*/
@Test
public void testGetApiKey() {
// Not required
}
/**
* Test of getApiBase method, of class TheMovieDb.
*/
@Test
public void testGetApiBase() {
// Not required
}
/**
* Test of getConfiguration method, of class TheMovieDb.
*/
@Test
public void testGetConfiguration() {
// Not required
}
/**
* Test of searchPeople method, of class TheMovieDb.
*/
@Test
public void testSearchPeople() {
LOGGER.info("searchPeople");
String personName = "Bruce Willis";
boolean allResults = false;
List<Person> result = tmdb.searchPeople(personName, allResults);
assertTrue("Couldn't find the person", result.size() > 0);
}
/**
* Test of getPersonInfo method, of class TheMovieDb.
*/
@Test
public void testGetPersonInfo() {
LOGGER.info("getPersonInfo");
Person result = tmdb.getPersonInfo(ID_BRUCE_WILLIS);
assertTrue("Wrong actor returned", result.getId() == ID_BRUCE_WILLIS);
}
/**
* Test of getPersonCredits method, of class TheMovieDb.
*/
@Test
public void testGetPersonCredits() {
LOGGER.info("getPersonCredits");
List<PersonCredit> people = tmdb.getPersonCredits(ID_BRUCE_WILLIS);
assertTrue("No cast information", people.size() > 0);
}
/**
* Test of getPersonImages method, of class TheMovieDb.
*/
@Test
public void testGetPersonImages() {
LOGGER.info("getPersonImages");
List<Artwork> artwork = tmdb.getPersonImages(ID_BRUCE_WILLIS);
assertTrue("No cast information", artwork.size() > 0);
}
/**
* Test of getLatestMovie method, of class TheMovieDb.
*/
@Test
public void testGetLatestMovie() {
LOGGER.info("getLatestMovie");
MovieDb result = tmdb.getLatestMovie();
LOGGER.info(result.toString());
assertTrue("No latest movie found", result.getId() > 0);
}
/**
* Test of compareMovies method, of class TheMovieDb.
*/
@Test
public void testCompareMovies() {
// Not required
}
}