2009-11-02 18:25:04 -05:00
|
|
|
|
|
|
|
package net.sourceforge.filebot.web;
|
|
|
|
|
|
|
|
|
|
|
|
import static net.sourceforge.filebot.Settings.*;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
|
|
|
import java.util.List;
|
2011-08-10 01:05:11 -04:00
|
|
|
import java.util.Locale;
|
2009-11-02 18:25:04 -05:00
|
|
|
|
2012-07-24 13:44:54 -04:00
|
|
|
import net.sourceforge.filebot.web.TMDbClient.Artwork;
|
2011-12-25 06:18:55 -05:00
|
|
|
import net.sourceforge.filebot.web.TMDbClient.MovieInfo;
|
|
|
|
|
2012-07-24 13:44:54 -04:00
|
|
|
import org.junit.Test;
|
|
|
|
|
2009-11-02 18:25:04 -05:00
|
|
|
|
|
|
|
public class TMDbClientTest {
|
|
|
|
|
|
|
|
private final TMDbClient tmdb = new TMDbClient(getApplicationProperty("themoviedb.apikey"));
|
|
|
|
|
2011-12-25 06:18:55 -05:00
|
|
|
|
2009-11-02 18:25:04 -05:00
|
|
|
@Test
|
|
|
|
public void searchByName() throws Exception {
|
2011-09-22 08:55:04 -04:00
|
|
|
List<Movie> result = tmdb.searchMovie("Serenity", Locale.CHINESE);
|
|
|
|
Movie movie = result.get(0);
|
2009-11-02 18:25:04 -05:00
|
|
|
|
2012-02-09 08:42:14 -05:00
|
|
|
assertEquals("冲出宁静号", movie.getName());
|
2011-01-07 06:02:11 -05:00
|
|
|
assertEquals(2005, movie.getYear());
|
2012-07-24 13:44:54 -04:00
|
|
|
assertEquals(-1, movie.getImdbId());
|
|
|
|
assertEquals(16320, movie.getTmdbId());
|
2009-11-02 18:25:04 -05:00
|
|
|
}
|
|
|
|
|
2011-12-25 06:18:55 -05:00
|
|
|
|
2009-11-21 20:27:05 -05:00
|
|
|
@Test
|
|
|
|
public void searchByIMDB() throws Exception {
|
2011-09-22 08:55:04 -04:00
|
|
|
Movie movie = tmdb.getMovieDescriptor(418279, Locale.ENGLISH);
|
2009-11-21 20:27:05 -05:00
|
|
|
|
|
|
|
assertEquals("Transformers", movie.getName());
|
2011-12-25 06:18:55 -05:00
|
|
|
assertEquals(2007, movie.getYear(), 0);
|
|
|
|
assertEquals(418279, movie.getImdbId(), 0);
|
2012-07-24 13:44:54 -04:00
|
|
|
assertEquals(1858, movie.getTmdbId(), 0);
|
2009-11-21 20:27:05 -05:00
|
|
|
}
|
|
|
|
|
2011-12-25 06:18:55 -05:00
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getMovieInfo() throws Exception {
|
2012-07-24 13:44:54 -04:00
|
|
|
MovieInfo movie = tmdb.getMovieInfo(new Movie(null, 0, 418279, -1), Locale.ENGLISH);
|
2011-12-25 06:18:55 -05:00
|
|
|
|
|
|
|
assertEquals("Transformers", movie.getName());
|
2013-03-18 01:23:41 -04:00
|
|
|
assertEquals("2007-07-02", movie.getReleased().toString());
|
2012-07-24 13:44:54 -04:00
|
|
|
assertEquals("PG-13", movie.getCertification());
|
|
|
|
assertEquals("[en]", movie.getSpokenLanguages().toString());
|
|
|
|
assertEquals("Shia LaBeouf", movie.getActors().get(0));
|
|
|
|
assertEquals("Michael Bay", movie.getDirector());
|
|
|
|
assertEquals("Editor", movie.getCast().get(30).getJob());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getArtwork() throws Exception {
|
|
|
|
List<Artwork> artwork = tmdb.getArtwork("tt0418279");
|
|
|
|
assertEquals("backdrops", artwork.get(0).getCategory());
|
2013-03-18 01:23:41 -04:00
|
|
|
assertEquals("http://d3gtl9l2a4fn1j.cloudfront.net/t/p/original/jC4bQLEEcpM8N7BjpkMtP0zPakJ.jpg", artwork.get(0).getUrl().toString());
|
2011-12-25 06:18:55 -05:00
|
|
|
}
|
2012-04-08 04:41:48 -04:00
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void floodLimit() throws Exception {
|
|
|
|
for (Locale it : Locale.getAvailableLocales()) {
|
|
|
|
List<Movie> results = tmdb.searchMovie("Serenity", it);
|
2012-07-24 13:44:54 -04:00
|
|
|
assertEquals(16320, results.get(0).getTmdbId());
|
2012-04-08 04:41:48 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-02 18:25:04 -05:00
|
|
|
}
|