diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index cbb0753b6..33b4ce09e 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -64,7 +64,7 @@ import com.omertron.themoviedbapi.model2.StatusCode; import com.omertron.themoviedbapi.model.TBD_ExternalSource; import com.omertron.themoviedbapi.model.TBD_FindResults; import com.omertron.themoviedbapi.model.TBD_Network; -import com.omertron.themoviedbapi.model.TBD_PersonCredits; +import com.omertron.themoviedbapi.model2.person.CreditInfo; import com.omertron.themoviedbapi.model2.authentication.TokenAuthorisation; import com.omertron.themoviedbapi.model2.authentication.TokenSession; import com.omertron.themoviedbapi.model.Translation; @@ -658,7 +658,7 @@ public class TheMovieDbApi { * @return * @throws MovieDbException */ - public TBD_PersonCredits getCreditInfo(String creditId, String language) throws MovieDbException { + public CreditInfo getCreditInfo(String creditId, String language) throws MovieDbException { return tmdbCredits.getCreditInfo(creditId, language); } // diff --git a/src/main/java/com/omertron/themoviedbapi/methods/TmdbCredits.java b/src/main/java/com/omertron/themoviedbapi/methods/TmdbCredits.java index 2873f028d..f37ea21ae 100644 --- a/src/main/java/com/omertron/themoviedbapi/methods/TmdbCredits.java +++ b/src/main/java/com/omertron/themoviedbapi/methods/TmdbCredits.java @@ -20,7 +20,7 @@ package com.omertron.themoviedbapi.methods; import com.omertron.themoviedbapi.MovieDbException; -import com.omertron.themoviedbapi.model.TBD_PersonCredits; +import com.omertron.themoviedbapi.model2.person.CreditInfo; import com.omertron.themoviedbapi.tools.ApiUrl; import com.omertron.themoviedbapi.tools.HttpTools; import com.omertron.themoviedbapi.tools.MethodBase; @@ -66,7 +66,7 @@ public class TmdbCredits extends AbstractMethod { * @return * @throws MovieDbException */ - public TBD_PersonCredits getCreditInfo(String creditId, String language) throws MovieDbException { + public CreditInfo getCreditInfo(String creditId, String language) throws MovieDbException { TmdbParameters parameters = new TmdbParameters(); parameters.add(Param.ID, creditId); parameters.add(Param.LANGUAGE, language); @@ -75,7 +75,7 @@ public class TmdbCredits extends AbstractMethod { String webpage = httpTools.getRequest(url); try { - return MAPPER.readValue(webpage, TBD_PersonCredits.class); + return MAPPER.readValue(webpage, CreditInfo.class); } catch (IOException ex) { throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get credit info", url, ex); } diff --git a/src/main/java/com/omertron/themoviedbapi/methods/_Method_List.txt b/src/main/java/com/omertron/themoviedbapi/methods/_Method_List.txt index bf5cb3acb..b2ff5a730 100644 --- a/src/main/java/com/omertron/themoviedbapi/methods/_Method_List.txt +++ b/src/main/java/com/omertron/themoviedbapi/methods/_Method_List.txt @@ -29,7 +29,7 @@ Collections (Done) /collection/{id} Get the basic collection information for a specific collection id. /collection/{id}/images Get all of the images for a particular collection by collection id. -Companies +Companies (Done) /company/{id} This method is used to retrieve all of the basic information about a company /company/{id}/movies Get the list of movies associated with a particular company. diff --git a/src/main/java/com/omertron/themoviedbapi/model2/person/CreditInfo.java b/src/main/java/com/omertron/themoviedbapi/model2/person/CreditInfo.java new file mode 100644 index 000000000..94b0a13b8 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model2/person/CreditInfo.java @@ -0,0 +1,104 @@ +/* + * 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.omertron.themoviedbapi.model2.AbstractJsonMapping; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model2.tv.TVCredit; + +/** + * @author stuart.boston + */ +public class CreditInfo extends AbstractJsonMapping { + + private static final long serialVersionUID = 1L; + + @JsonProperty("id") + private String id; + @JsonProperty("credit_type") + private String creditType; + @JsonProperty("department") + private String department; + @JsonProperty("job") + private String job; + @JsonProperty("media_type") + private String mediaType; + @JsonProperty("person") + private PersonBasic person; + @JsonProperty("media") + private TVCredit media; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getCreditType() { + return creditType; + } + + public void setCreditType(String creditType) { + this.creditType = creditType; + } + + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public String getJob() { + return job; + } + + public void setJob(String job) { + this.job = job; + } + + public String getMediaType() { + return mediaType; + } + + public void setMediaType(String mediaType) { + this.mediaType = mediaType; + } + + public PersonBasic getPerson() { + return person; + } + + public void setPerson(PersonBasic person) { + this.person = person; + } + + public TVCredit getMedia() { + return media; + } + + public void setMedia(TVCredit media) { + this.media = media; + } + +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/TBD_PersonCredits.java b/src/main/java/com/omertron/themoviedbapi/model2/person/PersonBasic.java similarity index 65% rename from src/main/java/com/omertron/themoviedbapi/model/TBD_PersonCredits.java rename to src/main/java/com/omertron/themoviedbapi/model2/person/PersonBasic.java index 92801a275..8accb1b18 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/TBD_PersonCredits.java +++ b/src/main/java/com/omertron/themoviedbapi/model2/person/PersonBasic.java @@ -17,29 +17,15 @@ * along with TheMovieDB API. If not, see . * */ -package com.omertron.themoviedbapi.model; +package com.omertron.themoviedbapi.model2.person; -import com.omertron.themoviedbapi.model2.AbstractJsonMapping; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; +import com.omertron.themoviedbapi.model.AbstractIdName; /** * @author stuart.boston */ -@JsonRootName("???") -public class TBD_PersonCredits extends AbstractJsonMapping { +public class PersonBasic extends AbstractIdName { 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/tv/TVCredit.java b/src/main/java/com/omertron/themoviedbapi/model2/tv/TVCredit.java new file mode 100644 index 000000000..ce8ceae39 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model2/tv/TVCredit.java @@ -0,0 +1,74 @@ +/* + * 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.tv; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.AbstractIdName; +import java.util.List; + +/** + * TV Favorite information + * + * @author stuart.boston + */ +public class TVCredit extends AbstractIdName { + + @JsonProperty("original_name") + private String originalName; + @JsonProperty("character") + private String character; + @JsonProperty("seasons") + private List seasons; + @JsonProperty("episodes") + private List episodes; + + public String getOriginalName() { + return originalName; + } + + public void setOriginalName(String originalName) { + this.originalName = originalName; + } + + public String getCharacter() { + return character; + } + + public void setCharacter(String character) { + this.character = character; + } + + public List getSeasons() { + return seasons; + } + + public void setSeasons(List seasons) { + this.seasons = seasons; + } + + public List getEpisodes() { + return episodes; + } + + public void setEpisodes(List episodes) { + this.episodes = episodes; + } + +} diff --git a/src/main/java/com/omertron/themoviedbapi/model2/tv/TVEpisodeBasic.java b/src/main/java/com/omertron/themoviedbapi/model2/tv/TVEpisodeBasic.java new file mode 100644 index 000000000..7af9f79ec --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model2/tv/TVEpisodeBasic.java @@ -0,0 +1,93 @@ +/* + * 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.tv; + +import com.omertron.themoviedbapi.model2.AbstractJsonMapping; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * TV Favorite information + * + * @author stuart.boston + */ +public class TVEpisodeBasic extends AbstractJsonMapping { + + @JsonProperty("air_date") + private String airDate; + @JsonProperty("season_number") + private int seasonNumber; + @JsonProperty("episode_number") + private int episodeNumber; + @JsonProperty("name") + private String name; + @JsonProperty("overview") + private String overview; + @JsonProperty("still_path") + private String stillPath; + + public String getAirDate() { + return airDate; + } + + public void setAirDate(String airDate) { + this.airDate = airDate; + } + + public int getSeasonNumber() { + return seasonNumber; + } + + public void setSeasonNumber(int seasonNumber) { + this.seasonNumber = seasonNumber; + } + + public int getEpisodeNumber() { + return episodeNumber; + } + + public void setEpisodeNumber(int episodeNumber) { + this.episodeNumber = episodeNumber; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getOverview() { + return overview; + } + + public void setOverview(String overview) { + this.overview = overview; + } + + public String getStillPath() { + return stillPath; + } + + public void setStillPath(String stillPath) { + this.stillPath = stillPath; + } + +} diff --git a/src/main/java/com/omertron/themoviedbapi/model2/tv/TVSeasonBasic.java b/src/main/java/com/omertron/themoviedbapi/model2/tv/TVSeasonBasic.java new file mode 100644 index 000000000..52b2c7716 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model2/tv/TVSeasonBasic.java @@ -0,0 +1,62 @@ +/* + * 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.tv; + +import com.omertron.themoviedbapi.model2.AbstractJsonMapping; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * TV Favorite information + * + * @author stuart.boston + */ +public class TVSeasonBasic extends AbstractJsonMapping { + + @JsonProperty("air_date") + private String airDate; + @JsonProperty("poster_path") + private String posterPath; + @JsonProperty("season_number") + private int seasonNumber; + + public String getAirDate() { + return airDate; + } + + public void setAirDate(String airDate) { + this.airDate = airDate; + } + + public String getPosterPath() { + return posterPath; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + + public int getSeasonNumber() { + return seasonNumber; + } + + public void setSeasonNumber(int seasonNumber) { + this.seasonNumber = seasonNumber; + } +} diff --git a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCreditsTest.java b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCreditsTest.java index 2fe107517..8508edf93 100644 --- a/src/test/java/com/omertron/themoviedbapi/methods/TmdbCreditsTest.java +++ b/src/test/java/com/omertron/themoviedbapi/methods/TmdbCreditsTest.java @@ -21,10 +21,11 @@ package com.omertron.themoviedbapi.methods; import com.omertron.themoviedbapi.AbstractTests; import com.omertron.themoviedbapi.MovieDbException; -import com.omertron.themoviedbapi.model.TBD_PersonCredits; +import com.omertron.themoviedbapi.model2.person.CreditInfo; import org.junit.After; import org.junit.AfterClass; -import static org.junit.Assert.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -33,7 +34,7 @@ import org.junit.Test; * * @author stuart.boston */ -public class TmdbCreditsTest extends AbstractTests{ +public class TmdbCreditsTest extends AbstractTests { private static TmdbCredits instance; @@ -43,7 +44,7 @@ public class TmdbCreditsTest extends AbstractTests{ @BeforeClass public static void setUpClass() throws MovieDbException { doConfiguration(); - instance = new TmdbCredits(getApiKey(),getHttpTools()); + instance = new TmdbCredits(getApiKey(), getHttpTools()); } @AfterClass @@ -66,13 +67,12 @@ public class TmdbCreditsTest extends AbstractTests{ @Test public void testGetCreditInfo() throws MovieDbException { LOG.info("getCreditInfo"); - String creditId = "525346f619c29579400d4145"; - String language = ""; - TBD_PersonCredits result = instance.getCreditInfo(creditId, language); -// assertEquals("Wrong name", "Sean Bean", result.getPerson().getName()); -// assertEquals("Wrong job", "Actor", result.getJob()); -// assertFalse("No seasons", result.getMedia().getSeasons().isEmpty()); - fail("The test case is a prototype."); + String creditId = "53392a9c9251417da10041c8"; + CreditInfo result = instance.getCreditInfo(creditId, LANGUAGE_DEFAULT); + assertEquals("Wrong name", "Josh McDermitt", result.getPerson().getName()); + assertEquals("Wrong job", "Actor", result.getJob()); + assertFalse("No seasons", result.getMedia().getSeasons().isEmpty()); + assertFalse("No episodes", result.getMedia().getEpisodes().isEmpty()); } }