diff --git a/src/main/java/com/omertron/themoviedbapi/model/Company.java b/src/main/java/com/omertron/themoviedbapi/model/Company.java index 9098c30b5..62a86ba64 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Company.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Company.java @@ -1,135 +1,143 @@ -/* - * Copyright (c) 2004-2013 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.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Company information - * - * @author Stuart - */ -public class Company implements Serializable { - - private static final long serialVersionUID = 1L; - // Logger - private static final Logger LOG = LoggerFactory.getLogger(Company.class); - private static final String DEFAULT_STRING = ""; - // Properties - @JsonProperty("id") - private int companyId = 0; - @JsonProperty("name") - private String name = DEFAULT_STRING; - @JsonProperty("description") - private String description = DEFAULT_STRING; - @JsonProperty("headquarters") - private String headquarters = DEFAULT_STRING; - @JsonProperty("homepage") - private String homepage = DEFAULT_STRING; - @JsonProperty("logo_path") - private String logoPath = DEFAULT_STRING; - @JsonProperty("parent_company") - private String parentCompany = DEFAULT_STRING; - - // - public int getCompanyId() { - return companyId; - } - - public String getDescription() { - return description; - } - - public String getHeadquarters() { - return headquarters; - } - - public String getHomepage() { - return homepage; - } - - public String getLogoPath() { - return logoPath; - } - - public String getName() { - return name; - } - - public String getParentCompany() { - return parentCompany; - } - // - - // - public void setCompanyId(int companyId) { - this.companyId = companyId; - } - - public void setDescription(String description) { - this.description = description; - } - - public void setHeadquarters(String headquarters) { - this.headquarters = headquarters; - } - - public void setHomepage(String homepage) { - this.homepage = homepage; - } - - public void setLogoPath(String logoPath) { - this.logoPath = logoPath; - } - - public void setName(String name) { - this.name = name; - } - - public void setParentCompany(String parentCompany) { - this.parentCompany = parentCompany; - } - // - - /** - * 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("'"); - LOG.trace(sb.toString()); - } - - @Override - public String toString() { - return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE); - } -} +/* + * Copyright (c) 2004-2013 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.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Company information + * + * @author Stuart + */ +public class Company implements Serializable { + + private static final long serialVersionUID = 1L; + // Logger + private static final Logger LOG = LoggerFactory.getLogger(Company.class); + private static final String DEFAULT_STRING = ""; + // Properties + @JsonProperty("id") + private int companyId = 0; + @JsonProperty("name") + private String name = DEFAULT_STRING; + @JsonProperty("description") + private String description = DEFAULT_STRING; + @JsonProperty("headquarters") + private String headquarters = DEFAULT_STRING; + @JsonProperty("homepage") + private String homepage = DEFAULT_STRING; + @JsonProperty("logo_path") + private String logoPath = DEFAULT_STRING; + @JsonProperty("parent_company") + private Company parentCompany = null; + + // + public int getCompanyId() { + return companyId; + } + + public String getDescription() { + return description; + } + + public String getHeadquarters() { + return headquarters; + } + + public String getHomepage() { + return homepage; + } + + public String getLogoPath() { + return logoPath; + } + + public String getName() { + return name; + } + + public Company getParentCompany() { + return parentCompany; + } + // + + // + public void setCompanyId(int companyId) { + this.companyId = companyId; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setHeadquarters(String headquarters) { + this.headquarters = headquarters; + } + + public void setHomepage(String homepage) { + this.homepage = homepage; + } + + public void setLogoPath(String logoPath) { + this.logoPath = logoPath; + } + + public void setName(String name) { + this.name = name; + } + + public void setParentCompany(Company parentCompany) { + this.parentCompany = parentCompany; + } + + public void setParentCompany(int id, String name, String logoPath) { + Company parent = new Company(); + parent.setCompanyId(companyId); + parent.setName(name); + parent.setLogoPath(logoPath); + this.parentCompany = parent; + } + // + + /** + * 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("'"); + LOG.trace(sb.toString()); + } + + @Override + public String toString() { + return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE); + } +} diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index 8d3c207a8..bdbb531ca 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -69,7 +69,7 @@ public class TheMovieDbApiTest { private static final int ID_MOVIE_THE_AVENGERS = 24428; private static final int ID_COLLECTION_STAR_WARS = 10; private static final int ID_PERSON_BRUCE_WILLIS = 62; - private static final int ID_COMPANY_LUCASFILM = 1; + private static final int ID_COMPANY = 2; private static final String COMPANY_NAME = "Marvel Studios"; private static final int ID_GENRE_ACTION = 28; private static final String ID_KEYWORD = "1721"; @@ -413,8 +413,9 @@ public class TheMovieDbApiTest { @Test public void testGetCompanyInfo() throws MovieDbException { LOG.info("getCompanyInfo"); - Company company = tmdb.getCompanyInfo(ID_COMPANY_LUCASFILM); + Company company = tmdb.getCompanyInfo(ID_COMPANY); assertTrue("No company information found", company.getCompanyId() > 0); + assertNotNull("No parent company found", company.getParentCompany()); } /** @@ -423,7 +424,7 @@ public class TheMovieDbApiTest { @Test public void testGetCompanyMovies() throws MovieDbException { LOG.info("getCompanyMovies"); - TmdbResultsList result = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, LANGUAGE_DEFAULT, 0); + TmdbResultsList result = tmdb.getCompanyMovies(ID_COMPANY, LANGUAGE_DEFAULT, 0); assertTrue("No company movies found", !result.getResults().isEmpty()); }