|
|
|
@ -12,19 +12,25 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
package com.moviejukebox.themoviedb;
|
|
|
|
package com.moviejukebox.themoviedb;
|
|
|
|
|
|
|
|
|
|
|
|
import com.moviejukebox.themoviedb.model.Category;
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
import java.util.Map;
|
|
|
|
import static org.junit.Assert.assertFalse;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertNull;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import com.moviejukebox.themoviedb.model.Person;
|
|
|
|
|
|
|
|
import com.moviejukebox.themoviedb.model.MovieDB;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
import org.junit.After;
|
|
|
|
import org.junit.After;
|
|
|
|
import org.junit.AfterClass;
|
|
|
|
import org.junit.AfterClass;
|
|
|
|
import org.junit.Before;
|
|
|
|
import org.junit.Before;
|
|
|
|
import org.junit.BeforeClass;
|
|
|
|
import org.junit.BeforeClass;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
|
|
|
|
|
|
|
import com.moviejukebox.themoviedb.model.Category;
|
|
|
|
|
|
|
|
import com.moviejukebox.themoviedb.model.MovieDB;
|
|
|
|
|
|
|
|
import com.moviejukebox.themoviedb.model.Person;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* JUnit tests for TheMovieDb class. The tester must enter its IMDb API key for
|
|
|
|
* JUnit tests for TheMovieDb class. The tester must enter its IMDb API key for
|
|
|
|
@ -33,7 +39,7 @@ import static org.junit.Assert.*;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class TheMovieDbTest {
|
|
|
|
public class TheMovieDbTest {
|
|
|
|
|
|
|
|
|
|
|
|
private static String apikey = "";
|
|
|
|
private static String apikey = "5a1a77e2eba8984804586122754f969f";
|
|
|
|
private TheMovieDb tmdb;
|
|
|
|
private TheMovieDb tmdb;
|
|
|
|
|
|
|
|
|
|
|
|
public TheMovieDbTest() {
|
|
|
|
public TheMovieDbTest() {
|
|
|
|
@ -95,37 +101,56 @@ public class TheMovieDbTest {
|
|
|
|
//*** Start moviedbBrowse
|
|
|
|
//*** Start moviedbBrowse
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testMoviedbBrowseRatingAsc() {
|
|
|
|
public void testMoviedbBrowseRatingAsc() {
|
|
|
|
List<MovieDB> movies = tmdb.moviedbBrowse("rating", "asc", "en");
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
|
|
|
|
|
params.put("year", "2011");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<MovieDB> movies = tmdb.moviedbBrowse("rating", "asc", params, "en");
|
|
|
|
|
|
|
|
|
|
|
|
assertFalse(movies.isEmpty());
|
|
|
|
assertFalse(movies.isEmpty());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testMoviedbBrowseReleaseAsc() {
|
|
|
|
public void testMoviedbBrowseReleaseAsc() {
|
|
|
|
List<MovieDB> movies = tmdb.moviedbBrowse("release", "asc", "en");
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
|
|
|
|
|
params.put("year", "2011");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<MovieDB> movies = tmdb.moviedbBrowse("release", "asc", params, "en");
|
|
|
|
assertFalse(movies.isEmpty());
|
|
|
|
assertFalse(movies.isEmpty());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testMoviedbBrowseTitleAsc() {
|
|
|
|
public void testMoviedbBrowseTitleAsc() {
|
|
|
|
List<MovieDB> movies = tmdb.moviedbBrowse("title", "asc", "en");
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
|
|
|
|
|
params.put("year", "2011");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<MovieDB> movies = tmdb.moviedbBrowse("title", "asc", params, "en");
|
|
|
|
assertFalse(movies.isEmpty());
|
|
|
|
assertFalse(movies.isEmpty());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testMoviedbBrowseRatingDesc() {
|
|
|
|
public void testMoviedbBrowseRatingDesc() {
|
|
|
|
List<MovieDB> movies = tmdb.moviedbBrowse("rating", "desc", "en");
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
|
|
|
|
|
params.put("year", "2011");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<MovieDB> movies = tmdb.moviedbBrowse("rating", "desc", params, "en");
|
|
|
|
assertFalse(movies.isEmpty());
|
|
|
|
assertFalse(movies.isEmpty());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testMoviedbBrowseReleaseDesc() {
|
|
|
|
public void testMoviedbBrowseReleaseDesc() {
|
|
|
|
List<MovieDB> movies = tmdb.moviedbBrowse("release", "desc", "en");
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
|
|
|
|
|
params.put("year", "2011");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<MovieDB> movies = tmdb.moviedbBrowse("release", "desc", params, "en");
|
|
|
|
assertFalse(movies.isEmpty());
|
|
|
|
assertFalse(movies.isEmpty());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testMoviedbBrowseTitleDesc() {
|
|
|
|
public void testMoviedbBrowseTitleDesc() {
|
|
|
|
List<MovieDB> movies = tmdb.moviedbBrowse("title", "desc", "en");
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
|
|
|
|
|
params.put("year", "2011");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<MovieDB> movies = tmdb.moviedbBrowse("title", "desc", params, "en");
|
|
|
|
assertFalse(movies.isEmpty());
|
|
|
|
assertFalse(movies.isEmpty());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -297,7 +322,7 @@ public class TheMovieDbTest {
|
|
|
|
assertEquals("585", movies.get(0).getId());
|
|
|
|
assertEquals("585", movies.get(0).getId());
|
|
|
|
assertEquals("tt0198781", movies.get(0).getImdb());
|
|
|
|
assertEquals("tt0198781", movies.get(0).getImdb());
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals("Star Wars: Episode IV - A New Hope", movies.get(1).getTitle());
|
|
|
|
assertEquals("Star Wars: Episode IV: A New Hope", movies.get(1).getTitle());
|
|
|
|
assertEquals("11", movies.get(1).getId());
|
|
|
|
assertEquals("11", movies.get(1).getId());
|
|
|
|
assertEquals("tt0076759", movies.get(1).getImdb());
|
|
|
|
assertEquals("tt0076759", movies.get(1).getImdb());
|
|
|
|
|
|
|
|
|
|
|
|
@ -315,54 +340,70 @@ public class TheMovieDbTest {
|
|
|
|
assertTrue(movies.isEmpty());
|
|
|
|
assertTrue(movies.isEmpty());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//@Test
|
|
|
|
@Test
|
|
|
|
public void testMoviedbGetImages_String_String() {
|
|
|
|
public void testMoviedbGetImages_String_String() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//@Test
|
|
|
|
@Test
|
|
|
|
public void testMoviedbGetImages_3args() {
|
|
|
|
public void testMoviedbGetImages_3args() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testPersonSearch() {
|
|
|
|
public void testPersonSearch() {
|
|
|
|
Person person = tmdb.personSearch("Tom Cruise", "en");
|
|
|
|
ArrayList<Person> people = tmdb.personSearch("Tom Cruise", "en");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Person person = new Person();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Person foundPerson : people) {
|
|
|
|
|
|
|
|
if (foundPerson.getId().equals("500")) {
|
|
|
|
|
|
|
|
person = foundPerson;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals("Tom Cruise", person.getName());
|
|
|
|
assertEquals("Tom Cruise", person.getName());
|
|
|
|
assertEquals("500", person.getId());
|
|
|
|
assertEquals("500", person.getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testPersonSearch_withEmptyName() {
|
|
|
|
public void testPersonSearch_withEmptyName() {
|
|
|
|
Person person = tmdb.personSearch("", "en");
|
|
|
|
ArrayList<Person> people = tmdb.personSearch("", "en");
|
|
|
|
assertTrue(person.getName().equals(MovieDB.UNKNOWN));
|
|
|
|
assertTrue(people.isEmpty());
|
|
|
|
assertTrue(person.getId().equals(MovieDB.UNKNOWN));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testPersonSearch_withNullName() {
|
|
|
|
public void testPersonSearch_withNullName() {
|
|
|
|
Person person = tmdb.personSearch((String) null, "en");
|
|
|
|
ArrayList<Person> people = tmdb.personSearch((String) null, "en");
|
|
|
|
assertTrue(person.getName().equals(MovieDB.UNKNOWN));
|
|
|
|
assertTrue(people.isEmpty());
|
|
|
|
assertTrue(person.getId().equals(MovieDB.UNKNOWN));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testPersonGetInfo() {
|
|
|
|
public void testPersonGetInfo() {
|
|
|
|
Person person = tmdb.personGetInfo("260", "en");
|
|
|
|
ArrayList<Person> people = tmdb.personGetInfo("260", "en");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Person person = new Person();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Person foundPerson : people) {
|
|
|
|
|
|
|
|
if (foundPerson.getId().equals("260")) {
|
|
|
|
|
|
|
|
person = foundPerson;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
assertEquals("Marco Pérez", person.getName());
|
|
|
|
assertEquals("Marco Pérez", person.getName());
|
|
|
|
assertEquals("260", person.getId());
|
|
|
|
assertEquals("260", person.getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testPersonGetInfo_withEmptyId() {
|
|
|
|
public void testPersonGetInfo_withEmptyId() {
|
|
|
|
Person person = tmdb.personGetInfo("", "en");
|
|
|
|
ArrayList<Person> people = tmdb.personGetInfo("", "en");
|
|
|
|
assertTrue(person.getName().equals(MovieDB.UNKNOWN));
|
|
|
|
assertTrue(people.isEmpty());
|
|
|
|
assertTrue(person.getId().equals(MovieDB.UNKNOWN));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testPersonGetInfo_withNullId() {
|
|
|
|
public void testPersonGetInfo_withNullId() {
|
|
|
|
Person person = tmdb.personGetInfo((String) null, "en");
|
|
|
|
ArrayList<Person> people = tmdb.personGetInfo((String) null, "en");
|
|
|
|
assertTrue(person.getName().equals(MovieDB.UNKNOWN));
|
|
|
|
assertTrue(people.isEmpty());
|
|
|
|
assertTrue(person.getId().equals(MovieDB.UNKNOWN));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
@ -429,10 +470,10 @@ public class TheMovieDbTest {
|
|
|
|
public void testGetCategories() {
|
|
|
|
public void testGetCategories() {
|
|
|
|
List<Category> genres = tmdb.getCategories("en");
|
|
|
|
List<Category> genres = tmdb.getCategories("en");
|
|
|
|
assertFalse(genres.isEmpty());
|
|
|
|
assertFalse(genres.isEmpty());
|
|
|
|
assertEquals(30, genres.size());
|
|
|
|
assertTrue(genres.size() > 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//@Test
|
|
|
|
@Test
|
|
|
|
public void testFindMovie() {
|
|
|
|
public void testFindMovie() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -442,16 +483,16 @@ public class TheMovieDbTest {
|
|
|
|
assertTrue(TheMovieDb.compareMovies(movie, "Inception", "2010"));
|
|
|
|
assertTrue(TheMovieDb.compareMovies(movie, "Inception", "2010"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//@Test
|
|
|
|
@Test
|
|
|
|
public void testCompareMovies_sameTitleAndDifferentYear() {
|
|
|
|
public void testCompareMovies_sameTitleAndDifferentYear() {
|
|
|
|
MovieDB movie = tmdb.moviedbGetInfo("27205", "en");
|
|
|
|
MovieDB movie = tmdb.moviedbGetInfo("27205", "en");
|
|
|
|
assertTrue(TheMovieDb.compareMovies(movie, "Inception", "1999"));
|
|
|
|
assertFalse(TheMovieDb.compareMovies(movie, "Inception", "1999"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//@Test
|
|
|
|
@Test
|
|
|
|
public void testCompareMovies_differentTitleAndSameYear() {
|
|
|
|
public void testCompareMovies_differentTitleAndSameYear() {
|
|
|
|
MovieDB movie = tmdb.moviedbGetInfo("27205", "en");
|
|
|
|
MovieDB movie = tmdb.moviedbGetInfo("27205", "en");
|
|
|
|
assertTrue(TheMovieDb.compareMovies(movie, "xxx", "2010"));
|
|
|
|
assertFalse(TheMovieDb.compareMovies(movie, "xxx", "2010"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
|