master
Stuart Boston 11 years ago
parent 50820a437f
commit 8522ac4171

@ -54,7 +54,7 @@ import com.omertron.themoviedbapi.model2.JobDepartment;
import com.omertron.themoviedbapi.model.keyword.Keyword; import com.omertron.themoviedbapi.model.keyword.Keyword;
import com.omertron.themoviedbapi.model.keyword.KeywordMovie; import com.omertron.themoviedbapi.model.keyword.KeywordMovie;
import com.omertron.themoviedbapi.model.MovieDb; import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.model.MovieDbList; import com.omertron.themoviedbapi.model2.list.ListItem;
import com.omertron.themoviedbapi.model.MovieList; import com.omertron.themoviedbapi.model.MovieList;
import com.omertron.themoviedbapi.model.person.Person; import com.omertron.themoviedbapi.model.person.Person;
import com.omertron.themoviedbapi.model.person.PersonCredit; import com.omertron.themoviedbapi.model.person.PersonCredit;
@ -77,7 +77,6 @@ import com.omertron.themoviedbapi.results.TmdbResultsList;
import com.omertron.themoviedbapi.results.TmdbResultsMap; import com.omertron.themoviedbapi.results.TmdbResultsMap;
import com.omertron.themoviedbapi.tools.HttpTools; import com.omertron.themoviedbapi.tools.HttpTools;
import com.omertron.themoviedbapi.tools.MethodBase; import com.omertron.themoviedbapi.tools.MethodBase;
import com.omertron.themoviedbapi.tools.MethodSub;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -806,7 +805,7 @@ public class TheMovieDbApi {
* @return The list and its items * @return The list and its items
* @throws MovieDbException * @throws MovieDbException
*/ */
public MovieDbList getList(String listId) throws MovieDbException { public ListItem<MovieDb> getList(String listId) throws MovieDbException {
return tmdbList.getList(listId); return tmdbList.getList(listId);
} }
@ -824,54 +823,59 @@ public class TheMovieDbApi {
} }
/** /**
* Check to see if a movie ID is already added to a list. * This method lets users delete a list that they created. A valid session id is required.
* *
* @param sessionId
* @param listId * @param listId
* @param movieId * @return
* @return true if the movie is on the list
* @throws MovieDbException * @throws MovieDbException
*/ */
public boolean isMovieOnList(String listId, Integer movieId) throws MovieDbException { public StatusCode deleteList(String sessionId, String listId) throws MovieDbException {
return tmdbList.isMovieOnList(listId, movieId); return tmdbList.deleteList(sessionId, listId);
} }
/** /**
* This method lets users add new movies to a list that they created. A valid session id is required. * Check to see if an item is already on a list.
* *
* @param sessionId
* @param listId * @param listId
* @param movieId * @param mediaId
* @return true if the movie is on the list * @return true if the item is on the list
* @throws MovieDbException * @throws MovieDbException
*/ */
public StatusCode addMovieToList(String sessionId, String listId, Integer movieId) throws MovieDbException { public boolean checkItemStatus(String listId, Integer mediaId) throws MovieDbException {
return tmdbList.modifyMovieList(sessionId, listId, movieId, MethodSub.ADD_ITEM); return tmdbList.checkItemStatus(listId, mediaId);
} }
/** /**
* This method lets users remove movies from a list that they created. A valid session id is required. * This method lets users add new items to a list that they created.
*
* A valid session id is required.
* *
* @param sessionId * @param sessionId
* @param listId * @param listId
* @param movieId * @param mediaId
* @return true if the movie is on the list * @return true if the movie is on the list
* @throws MovieDbException * @throws MovieDbException
*/ */
public StatusCode removeMovieFromList(String sessionId, String listId, Integer movieId) throws MovieDbException { public StatusCode addItemToList(String sessionId, String listId, Integer mediaId) throws MovieDbException {
return tmdbList.modifyMovieList(sessionId, listId, movieId, MethodSub.REMOVE_ITEM); return tmdbList.addItem(sessionId, listId, mediaId);
} }
/** /**
* This method lets users delete a list that they created. A valid session id is required. * This method lets users remove items from a list that they created.
*
* A valid session id is required.
* *
* @param sessionId * @param sessionId
* @param listId * @param listId
* @return * @param mediaId
* @return true if the movie is on the list
* @throws MovieDbException * @throws MovieDbException
*/ */
public StatusCode deleteMovieList(String sessionId, String listId) throws MovieDbException { public StatusCode removeItemFromList(String sessionId, String listId, Integer mediaId) throws MovieDbException {
return tmdbList.deleteMovieList(sessionId, listId); return tmdbList.removeItem(sessionId, listId, mediaId);
} }
//</editor-fold> //</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Movies"> //<editor-fold defaultstate="collapsed" desc="Movies">

@ -19,9 +19,11 @@
*/ */
package com.omertron.themoviedbapi.methods; package com.omertron.themoviedbapi.methods;
import com.fasterxml.jackson.core.type.TypeReference;
import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model.ListItemStatus; import com.omertron.themoviedbapi.model.ListItemStatus;
import com.omertron.themoviedbapi.model.MovieDbList; import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.model2.list.ListItem;
import com.omertron.themoviedbapi.model.MovieDbListStatus; import com.omertron.themoviedbapi.model.MovieDbListStatus;
import com.omertron.themoviedbapi.model2.StatusCode; import com.omertron.themoviedbapi.model2.StatusCode;
import com.omertron.themoviedbapi.tools.ApiUrl; import com.omertron.themoviedbapi.tools.ApiUrl;
@ -61,7 +63,7 @@ public class TmdbLists extends AbstractMethod {
* @return The list and its items * @return The list and its items
* @throws MovieDbException * @throws MovieDbException
*/ */
public MovieDbList getList(String listId) throws MovieDbException { public ListItem<MovieDb> getList(String listId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters(); TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, listId); parameters.add(Param.ID, listId);
@ -69,12 +71,35 @@ public class TmdbLists extends AbstractMethod {
String webpage = httpTools.getRequest(url); String webpage = httpTools.getRequest(url);
try { try {
return MAPPER.readValue(webpage, MovieDbList.class); return MAPPER.readValue(webpage, new TypeReference<ListItem<MovieDb>>(){});
} catch (IOException ex) { } catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get list", url, ex); throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get list", url, ex);
} }
} }
/**
* Check to see if an ID is already on a list.
*
* @param listId
* @param mediaId
* @return true if the movie is on the list
* @throws MovieDbException
*/
public boolean checkItemStatus(String listId, int mediaId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, listId);
parameters.add(Param.MOVIE_ID, mediaId);
URL url = new ApiUrl(apiKey, MethodBase.LIST).setSubMethod(MethodSub.ITEM_STATUS).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, ListItemStatus.class).isItemPresent();
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get item status", url, ex);
}
}
/** /**
* This method lets users create a new list. A valid session id is required. * This method lets users create a new list. A valid session id is required.
* *
@ -104,31 +129,33 @@ public class TmdbLists extends AbstractMethod {
} }
/** /**
* Check to see if a movie ID is already added to a list. * This method lets users delete a list that they created. A valid session id is required.
* *
* @param sessionId
* @param listId * @param listId
* @param movieId * @return
* @return true if the movie is on the list
* @throws MovieDbException * @throws MovieDbException
*/ */
public boolean isMovieOnList(String listId, Integer movieId) throws MovieDbException { public StatusCode deleteList(String sessionId, String listId) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters(); TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, listId); parameters.add(Param.ID, listId);
parameters.add(Param.MOVIE_ID, movieId); parameters.add(Param.SESSION, sessionId);
URL url = new ApiUrl(apiKey, MethodBase.LIST).setSubMethod(MethodSub.ITEM_STATUS).buildUrl(parameters); URL url = new ApiUrl(apiKey, MethodBase.LIST).buildUrl(parameters);
String webpage = httpTools.getRequest(url); String webpage = httpTools.deleteRequest(url);
try { try {
return MAPPER.readValue(webpage, ListItemStatus.class).isItemPresent(); return MAPPER.readValue(webpage, StatusCode.class);
} catch (IOException ex) { } catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get media status", url, ex); throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to delete list", url, ex);
} }
} }
/** /**
* Modify a list * Modify a list
* *
* This can be used to add or remove an item from the list
*
* @param sessionId * @param sessionId
* @param listId * @param listId
* @param movieId * @param movieId
@ -136,7 +163,7 @@ public class TmdbLists extends AbstractMethod {
* @return * @return
* @throws MovieDbException * @throws MovieDbException
*/ */
public StatusCode modifyMovieList(String sessionId, String listId, Integer movieId, MethodSub operation) throws MovieDbException { private StatusCode modifyMovieList(String sessionId, String listId, int movieId, MethodSub operation) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters(); TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.SESSION, sessionId); parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, listId); parameters.add(Param.ID, listId);
@ -151,31 +178,68 @@ public class TmdbLists extends AbstractMethod {
try { try {
return MAPPER.readValue(webpage, StatusCode.class); return MAPPER.readValue(webpage, StatusCode.class);
} catch (IOException ex) { } catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to remove movie from list", url, ex); throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to remove item from list", url, ex);
} }
} }
/** /**
* This method lets users delete a list that they created. A valid session * This method lets users add new items to a list that they created.
* id is required. *
* A valid session id is required.
* *
* @param sessionId * @param sessionId
* @param listId * @param listId
* @param mediaId
* @return * @return
* @throws MovieDbException * @throws MovieDbException
*/ */
public StatusCode deleteMovieList(String sessionId, String listId) throws MovieDbException { public StatusCode addItem(String sessionId, String listId, int mediaId) throws MovieDbException {
return modifyMovieList(sessionId, listId, mediaId, MethodSub.ADD_ITEM);
}
/**
* This method lets users delete items from a list that they created.
*
* A valid session id is required.
*
* @param sessionId
* @param listId
* @param mediaId
* @return
* @throws MovieDbException
*/
public StatusCode removeItem(String sessionId, String listId, int mediaId) throws MovieDbException {
return modifyMovieList(sessionId, listId, mediaId, MethodSub.REMOVE_ITEM);
}
/**
* Clear all of the items within a list.
*
* This is a irreversible action and should be treated with caution.
*
* A valid session id is required. A call without confirm=true will return status code 29.
*
* @param sessionId
* @param listId
* @param confirm
* @return
* @throws MovieDbException
*/
public StatusCode clear(String sessionId, String listId, boolean confirm) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters(); TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.ID, listId);
parameters.add(Param.SESSION, sessionId); parameters.add(Param.SESSION, sessionId);
parameters.add(Param.ID, listId);
parameters.add(Param.CONFIRM, confirm);
URL url = new ApiUrl(apiKey, MethodBase.LIST).buildUrl(parameters); URL url = new ApiUrl(apiKey, MethodBase.LIST).setSubMethod(MethodSub.CLEAR).buildUrl(parameters);
String webpage = httpTools.deleteRequest(url); String webpage = httpTools.postRequest(url, "");
try { try {
return MAPPER.readValue(webpage, StatusCode.class); return MAPPER.readValue(webpage, StatusCode.class);
} catch (IOException ex) { } catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to delete movie list", url, ex); throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to clear list", url, ex);
} }
} }
} }

@ -41,24 +41,24 @@ Discover (Done)
/discover/tv Discover TV shows by different types of data like average rating, number of votes, genres, the network they aired on and air dates. /discover/tv Discover TV shows by different types of data like average rating, number of votes, genres, the network they aired on and air dates.
Find Find
/find/{id} The find method makes it easy to search for objects in our database by an external id. *** /find/{id} The find method makes it easy to search for objects in our database by an external id.
Genres (Done) Genres (Done)
/genre/movie/list Get the list of movie genres. /genre/movie/list Get the list of movie genres.
/genre/tv/list Get the list of TV genres. /genre/tv/list Get the list of TV genres.
/genre/{id}/movies Get the list of movies for a particular genre by id. /genre/{id}/movies Get the list of movies for a particular genre by id.
Guest Sessions Guest Sessions (Partial - in Account)
/guest_session/{guest_session_id}/rated_movies Get a list of rated movies for a specific guest session id. /guest_session/{guest_session_id}/rated_movies Get a list of rated movies for a specific guest session id.
Jobs (Done) Jobs (Done)
/job/list Get a list of valid jobs. /job/list Get a list of valid jobs.
Keyword Keyword (Done)
/keyword/{id} Get the basic information for a specific keyword id /keyword/{id} Get the basic information for a specific keyword id
/keyword/{id}/movies Get the list of movies for a particular keyword by id /keyword/{id}/movies Get the list of movies for a particular keyword by id
Lists Lists (Done)
/list/{id} Get a list by id. /list/{id} Get a list by id.
/list/{id}/item_status Check to see if a movie ID is already added to a list. /list/{id}/item_status Check to see if a movie ID is already added to a list.
/list This method lets users create a new list. A valid session id is required. /list This method lets users create a new list. A valid session id is required.

@ -17,19 +17,20 @@
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model2.list;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model2.AbstractJsonMapping;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
* Wrapper for the MovieDbList function * Wrapper for the ListItem function
* *
* @author stuart.boston * @author stuart.boston
* @param <T> Type of list
*/ */
public class MovieDbList extends AbstractJsonMapping { public class ListItem<T> extends AbstractJsonMapping {
@JsonProperty("id") @JsonProperty("id")
private String id; private String id;
@ -40,7 +41,7 @@ public class MovieDbList extends AbstractJsonMapping {
@JsonProperty("favorite_count") @JsonProperty("favorite_count")
private int favoriteCount; private int favoriteCount;
@JsonProperty("items") @JsonProperty("items")
private List<MovieDb> items = Collections.emptyList(); private List<T> items = Collections.emptyList();
@JsonProperty("item_count") @JsonProperty("item_count")
private int itemCount; private int itemCount;
@JsonProperty("iso_639_1") @JsonProperty("iso_639_1")
@ -70,7 +71,7 @@ public class MovieDbList extends AbstractJsonMapping {
return favoriteCount; return favoriteCount;
} }
public List<MovieDb> getItems() { public List<T> getItems() {
return items; return items;
} }
@ -114,7 +115,7 @@ public class MovieDbList extends AbstractJsonMapping {
this.favoriteCount = favoriteCount; this.favoriteCount = favoriteCount;
} }
public void setItems(List<MovieDb> items) { public void setItems(List<T> items) {
this.items = items; this.items = items;
} }

@ -40,6 +40,7 @@ public class ApiUrl {
private static final Logger LOG = LoggerFactory.getLogger(ApiUrl.class); private static final Logger LOG = LoggerFactory.getLogger(ApiUrl.class);
// TheMovieDbApi API Base URL // TheMovieDbApi API Base URL
private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/"; private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/";
// private static final String TMDB_API_BASE = "http://private-639f-themoviedb.apiary-proxy.com/3/";
// Parameter configuration // Parameter configuration
private static final String DELIMITER_FIRST = "?"; private static final String DELIMITER_FIRST = "?";
private static final String DELIMITER_SUBSEQUENT = "&"; private static final String DELIMITER_SUBSEQUENT = "&";

@ -28,6 +28,7 @@ public enum MethodSub {
ALT_TITLES("alternative_titles"), ALT_TITLES("alternative_titles"),
CASTS("casts"), CASTS("casts"),
CHANGES("changes"), CHANGES("changes"),
CLEAR("clear"),
COLLECTION("collection"), COLLECTION("collection"),
COMPANY("company"), COMPANY("company"),
CREDITS("credits"), CREDITS("credits"),

@ -32,6 +32,7 @@ public enum Param {
ADULT("include_adult="), ADULT("include_adult="),
API_KEY("api_key="), API_KEY("api_key="),
APPEND("append_to_response="), APPEND("append_to_response="),
CONFIRM("confirm="),
COUNTRY("country="), COUNTRY("country="),
END_DATE("end_date="), END_DATE("end_date="),
EXTERNAL_SOURCE("external_source="), EXTERNAL_SOURCE("external_source="),

@ -20,20 +20,20 @@
package com.omertron.themoviedbapi.wrapper; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.MovieDbList; import com.omertron.themoviedbapi.model2.list.ListItem;
import java.util.List; import java.util.List;
public class WrapperMovieDbList extends AbstractWrapperAll { public class WrapperMovieDbList extends AbstractWrapperAll {
@JsonProperty("results") @JsonProperty("results")
private List<MovieDbList> lists; private List<ListItem> lists;
public List<MovieDbList> getLists() { public List<ListItem> getLists() {
return lists; return lists;
} }
public void setLists(List<MovieDbList> lists) { public void setLists(List<ListItem> lists) {
this.lists = lists; this.lists = lists;
} }
} }

@ -21,25 +21,33 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests; import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.model.MovieDbList;
import com.omertron.themoviedbapi.model2.StatusCode; import com.omertron.themoviedbapi.model2.StatusCode;
import com.omertron.themoviedbapi.tools.MethodSub; import com.omertron.themoviedbapi.model2.list.ListItem;
import java.util.Random;
import org.apache.commons.lang3.StringUtils;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail; import static org.junit.Assert.assertTrue;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.FixMethodOrder; import org.junit.Rule;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runners.MethodSorters; import org.junit.rules.ExpectedException;
@FixMethodOrder(MethodSorters.NAME_ASCENDING) //@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TmdbListsTest extends AbstractTests { public class TmdbListsTest extends AbstractTests {
private static TmdbLists instance; private static TmdbLists instance;
private static final int ID_JUPITER_ASCENDING = 76757;
private static final int ID_BIG_HERO_6 = 177572;
// Status codes
private static final int SC_SUCCESS_UPD = 12;
private static final int SC_SUCCESS_DEL = 13;
// Expected exception
@Rule
public ExpectedException exception = ExpectedException.none();
public TmdbListsTest() { public TmdbListsTest() {
} }
@ -62,100 +70,120 @@ public class TmdbListsTest extends AbstractTests {
public void tearDown() { public void tearDown() {
} }
@Test
public void testSuite() throws MovieDbException {
// Test the list creation
String listId = testCreateList();
// Add two items to the list
testAddItem(listId, ID_JUPITER_ASCENDING);
testAddItem(listId, ID_BIG_HERO_6);
// Get information on the list
testGetList(listId);
// Check item status on the list
testCheckItemStatus(listId, ID_JUPITER_ASCENDING);
// Delete an item from the list
testRemoveItem(listId, ID_BIG_HERO_6);
// Clear the list
testClear(listId);
// Delete the list
testDeleteList(listId);
}
/** /**
* Test of createList method, of class TmdbList. * Test of getList method, of class TmdbLists.
* *
* @throws com.omertron.themoviedbapi.MovieDbException * @throws com.omertron.themoviedbapi.MovieDbException
*/ */
@Ignore("Not working") private void testGetList(String listId) throws MovieDbException {
public void test1CreateList() throws MovieDbException { LOG.info("getList");
ListItem result = instance.getList(listId);
LOG.info("Found {} movies on list", result.getItems().size());
assertFalse("No movies in list", result.getItems().isEmpty());
}
/**
* Test of createList method, of class TmdbLists.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
private String testCreateList() throws MovieDbException {
LOG.info("createList"); LOG.info("createList");
String name = "My Totally Awesome List"; int r = new Random().nextInt();
String description = "This list was created to share all of the totally awesome movies I've seen.";
String name = "Random list name #" + r;
String description = "This is random list number " + r + " used for testing purposes";
String result = instance.createList(getSessionId(), name, description); String result = instance.createList(getSessionId(), name, description);
LOG.info(result); assertTrue("No list ID returned", StringUtils.isNotBlank(result));
// TODO review the generated test code and remove the default call to fail. return result;
fail("The test case is a prototype.");
} }
/** /**
* Test of getList method, of class TheMovieDbApi. * Test of checkItemStatus method, of class TmdbLists.
* *
* @throws MovieDbException * @throws com.omertron.themoviedbapi.MovieDbException
*/ */
@Test private void testCheckItemStatus(String listId, int mediaId) throws MovieDbException {
public void test2GetList() throws MovieDbException { LOG.info("checkItemStatus");
LOG.info("getList"); boolean expResult = true;
String listId = "509ec17b19c2950a0600050d"; boolean result = instance.checkItemStatus(listId, mediaId);
MovieDbList result = instance.getList(listId); assertEquals("Item is not on list!", expResult, result);
assertFalse("List not found", result.getItems().isEmpty());
} }
/** /**
* Test of addMovieToList method, of class TmdbList. * Test of deleteList method, of class TmdbLists.
* *
* @throws com.omertron.themoviedbapi.MovieDbException * @throws com.omertron.themoviedbapi.MovieDbException
*/ */
@Ignore("Not working") private void testDeleteList(String listId) throws MovieDbException {
public void test3AddMovieToList() throws MovieDbException { LOG.info("deleteList");
LOG.info("addMovieToList"); StatusCode result = instance.deleteList(getSessionId(), listId);
String listId = ""; LOG.info("Result: {}", result);
Integer movieId = null;
StatusCode expResult = null; // We expect there to be an exception thrown here
StatusCode result = instance.modifyMovieList(getSessionId(), listId, movieId, MethodSub.MOVIE); exception.expect(MovieDbException.class);
assertEquals(expResult, result); ListItem result2 = instance.getList(listId);
// TODO review the generated test code and remove the default call to fail. LOG.info("Result: {}", result2);
fail("The test case is a prototype.");
} }
/** /**
* Test of isMovieOnList method, of class TmdbList. * Test of addItem method, of class TmdbLists.
* *
* @throws com.omertron.themoviedbapi.MovieDbException * @throws com.omertron.themoviedbapi.MovieDbException
*/ */
@Ignore("Not working") private void testAddItem(String listId, int mediaId) throws MovieDbException {
public void test4IsMovieOnList() throws MovieDbException { LOG.info("addItem");
LOG.info("isMovieOnList"); StatusCode result = instance.addItem(getSessionId(), listId, mediaId);
String listId = ""; assertEquals("Invalid response: " + result.toString(), SC_SUCCESS_UPD, result.getStatusCode());
Integer movieId = null;
boolean expResult = false;
boolean result = instance.isMovieOnList(listId, movieId);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
} }
/** /**
* Test of removeMovieFromList method, of class TmdbList. * Test of removeItem method, of class TmdbLists.
* *
* @throws com.omertron.themoviedbapi.MovieDbException * @throws com.omertron.themoviedbapi.MovieDbException
*/ */
@Ignore("Not working") private void testRemoveItem(String listId, int mediaId) throws MovieDbException {
public void test5RemoveMovieFromList() throws MovieDbException { LOG.info("removeItem");
LOG.info("removeMovieFromList"); StatusCode result = instance.removeItem(getSessionId(), listId, mediaId);
String listId = ""; assertEquals("Invalid response: " + result.toString(), SC_SUCCESS_DEL, result.getStatusCode());
Integer movieId = null;
StatusCode expResult = null;
StatusCode result = instance.modifyMovieList(getSessionId(), listId, movieId, MethodSub.MOVIE);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
} }
/** /**
* Test of deleteMovieList method, of class TmdbList. * Test of clear method, of class TmdbLists.
* *
* @throws com.omertron.themoviedbapi.MovieDbException * @throws com.omertron.themoviedbapi.MovieDbException
*/ */
@Ignore("Not working") private void testClear(String listId) throws MovieDbException {
public void test6DeleteMovieList() throws MovieDbException { LOG.info("clear");
LOG.info("deleteMovieList"); StatusCode result = instance.clear(getSessionId(), listId, true);
String listId = ""; assertEquals("Invalid response: " + result.toString(), SC_SUCCESS_UPD, result.getStatusCode());
StatusCode expResult = null;
StatusCode result = instance.deleteMovieList(getSessionId(), listId);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
} }
} }

Loading…
Cancel
Save