fixes issue 11

master
Omertron 14 years ago
parent 398b5b0916
commit c8385c51cc

@ -44,7 +44,6 @@ public class TheMovieDb {
*/ */
private static final String BASE_MOVIE = "movie/"; private static final String BASE_MOVIE = "movie/";
private static final String BASE_PERSON = "person/"; private static final String BASE_PERSON = "person/";
// Configuration URL // Configuration URL
private final ApiUrl tmdbConfigUrl = new ApiUrl(this, "configuration"); private final ApiUrl tmdbConfigUrl = new ApiUrl(this, "configuration");
// Search URLS // Search URLS
@ -65,17 +64,16 @@ public class TheMovieDb {
private final ApiUrl tmdbPersonInfo = new ApiUrl(this, BASE_PERSON); private final ApiUrl tmdbPersonInfo = new ApiUrl(this, BASE_PERSON);
private final ApiUrl tmdbPersonCredits = new ApiUrl(this, BASE_PERSON, "/credits"); private final ApiUrl tmdbPersonCredits = new ApiUrl(this, BASE_PERSON, "/credits");
private final ApiUrl tmdbPersonImages = new ApiUrl(this, BASE_PERSON, "/images"); private final ApiUrl tmdbPersonImages = new ApiUrl(this, BASE_PERSON, "/images");
// Misc Movie /*
// - Movie Add Rating - Issue 9 * Misc Movie - Movie Add Rating - Issue 9
// - Latest Movie */
private final ApiUrl tmdbLatestMovie = new ApiUrl(this, "latest/movie"); private final ApiUrl tmdbLatestMovie = new ApiUrl(this, "latest/movie");
// - Now Playing Movies private final ApiUrl tmdbNowPlaying = new ApiUrl(this, "movie/now-playing");
// - Populate Movie List // - Populate Movie List
// - Top Rated Movies // - Top Rated Movies
// Company Info // Company Info
// - Company Info // - Company Info
// - Company Movies // - Company Movies
/* /*
* Jackson JSON configuration * Jackson JSON configuration
*/ */
@ -566,6 +564,31 @@ public class TheMovieDb {
} }
} }
/**
* This method is used to retrieve the movies currently in theatres. This is
* a curated list that will normally contain 100 movies. The default
* response will return 20 movies.
*
* @return
* @throws MovieDbException
*/
public List<MovieDb> getNowPlayingMovies(String language) throws MovieDbException {
URL url = tmdbNowPlaying.getIdUrl("", language);
String webPage = WebBrowser.request(url);
try {
WrapperResultList resultList = mapper.readValue(webPage, WrapperResultList.class);
return resultList.getResults();
} catch (IOException ex) {
LOGGER.warn("Failed to get latest movie: " + ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage);
}
}
public List<MovieDb> getNowPlayingMovies() throws MovieDbException {
return getNowPlayingMovies("");
}
/** /**
* Compare the MovieDB object with a title & year * Compare the MovieDB object with a title & year
* *

@ -147,7 +147,7 @@ public class ApiUrl {
LOGGER.trace("URL: " + urlString.toString()); LOGGER.trace("URL: " + urlString.toString());
return new URL(urlString.toString()); return new URL(urlString.toString());
} catch (MalformedURLException ex) { } catch (MalformedURLException ex) {
LOGGER.warn("Failed to create URL " + urlString.toString()); LOGGER.warn("Failed to create URL " + urlString.toString() + " - " + ex.toString());
return null; return null;
} }
} }

@ -77,7 +77,7 @@ public class TheMovieDbTest {
* Test of searchMovie method, of class TheMovieDb. * Test of searchMovie method, of class TheMovieDb.
*/ */
@Test @Test
public void testSearchMovie() throws MovieDbException { public void testSearchMovie() throws MovieDbException {
LOGGER.info("searchMovie"); LOGGER.info("searchMovie");
// Try a movie with less than 1 page of results // Try a movie with less than 1 page of results
@ -302,9 +302,9 @@ public class TheMovieDbTest {
public void testGetLatestMovie() throws MovieDbException { public void testGetLatestMovie() throws MovieDbException {
LOGGER.info("getLatestMovie"); LOGGER.info("getLatestMovie");
MovieDb result = tmdb.getLatestMovie(); MovieDb result = tmdb.getLatestMovie();
LOGGER.info(result.toString()); assertTrue("No latest movie found", result != null);
assertTrue("No latest movie found", result.getId() > 0); assertTrue("No latest movie found", result.getId() > 0);
} }
/** /**
* Test of compareMovies method, of class TheMovieDb. * Test of compareMovies method, of class TheMovieDb.
@ -313,4 +313,30 @@ public class TheMovieDbTest {
public void testCompareMovies() { public void testCompareMovies() {
// Not required // Not required
} }
/**
* Test of setProxy method, of class TheMovieDb.
*/
@Test
public void testSetProxy() {
// Not required
}
/**
* Test of setTimeout method, of class TheMovieDb.
*/
@Test
public void testSetTimeout() {
// Not required
}
/**
* Test of getNowPlayingMovies method, of class TheMovieDb.
*/
@Test
public void testGetNowPlayingMovies() throws Exception {
LOGGER.info("getNowPlayingMovies");
List<MovieDb> results = tmdb.getNowPlayingMovies();
assertTrue("No now playing movies foind", !results.isEmpty());
}
} }

Loading…
Cancel
Save