Search (Partial - missing multi)

This commit is contained in:
Stuart Boston
2015-02-28 14:43:31 +00:00
parent bbc85c09c4
commit c22ac9333e
8 changed files with 373 additions and 216 deletions
@@ -21,16 +21,23 @@ package com.omertron.themoviedbapi.methods;
import com.omertron.themoviedbapi.AbstractTests;
import com.omertron.themoviedbapi.MovieDbException;
import com.omertron.themoviedbapi.enumeration.SearchType;
import com.omertron.themoviedbapi.model2.collection.Collection;
import com.omertron.themoviedbapi.model2.company.Company;
import com.omertron.themoviedbapi.model.keyword.Keyword;
import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.model.MovieList;
import com.omertron.themoviedbapi.model.person.Person;
import com.omertron.themoviedbapi.model2.list.UserList;
import com.omertron.themoviedbapi.model2.tv.TVBasic;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import org.junit.After;
import org.junit.AfterClass;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -57,27 +64,26 @@ public class TmdbSearchTest extends AbstractTests {
public static void tearDownClass() {
}
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
/**
* Test of searchMovie method, of class TheMovieDbApi.
* Test of searchCompanies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testSearchMovie() throws MovieDbException {
LOG.info("searchMovie");
// Try a movie with less than 1 page of results
TmdbResultsList<MovieDb> movieList = instance.searchMovie("Blade Runner", 0, "", true, 0);
// List<MovieDb> movieList = tmdb.searchMovie("Blade Runner", "", true);
assertTrue("No movies found, should be at least 1", movieList.getResults().size() > 0);
// Try a russian langugage movie
movieList = instance.searchMovie("О чём говорят мужчины", 0, LANGUAGE_RUSSIAN, true, 0);
assertTrue("No 'RU' movies found, should be at least 1", movieList.getResults().size() > 0);
// Try a movie with more than 20 results
movieList = instance.searchMovie("Star Wars", 0, LANGUAGE_ENGLISH, false, 0);
assertTrue("Not enough movies found, should be over 15, found " + movieList.getResults().size(), movieList.getResults().size() >= 15);
public void testSearchCompanies() throws MovieDbException {
LOG.info("searchCompanies");
TmdbResultsList<Company> result = instance.searchCompanies(COMPANY_NAME, 0);
assertNotNull("Null results", result);
assertNotNull("Null company", result.getResults());
assertFalse("Empty company", result.isEmpty());
}
/**
@@ -90,50 +96,10 @@ public class TmdbSearchTest extends AbstractTests {
LOG.info("searchCollection");
String query = "batman";
int page = 0;
TmdbResultsList<Collection> result = instance.searchCollection(query, LANGUAGE_DEFAULT, page);
assertFalse("No collections found", result == null);
assertTrue("No collections found", result.getResults().size() > 0);
}
/**
* Test of searchPeople method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testSearchPeople() throws MovieDbException {
LOG.info("searchPeople");
String personName = "Bruce Willis";
boolean includeAdult = false;
TmdbResultsList<Person> result = instance.searchPeople(personName, includeAdult, 0);
assertTrue("Couldn't find the person", result.getResults().size() > 0);
}
/**
* Test of searchList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testSearchList() throws MovieDbException {
LOG.info("searchList");
String query = "watch";
int page = 0;
TmdbResultsList<MovieList> result = instance.searchList(query, LANGUAGE_DEFAULT, page);
assertFalse("No lists found", result.getResults() == null);
assertTrue("No lists found", result.getResults().size() > 0);
}
/**
* Test of searchCompanies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testSearchCompanies() throws MovieDbException {
LOG.info("searchCompanies");
TmdbResultsList<Company> result = instance.searchCompanies(COMPANY_NAME, 0);
assertTrue("No company information found", !result.getResults().isEmpty());
TmdbResultsList<Collection> result = instance.searchCollection(query, page, LANGUAGE_DEFAULT);
assertNotNull("Null results", result);
assertNotNull("Null collection", result.getResults());
assertFalse("Empty collection", result.isEmpty());
}
/**
@@ -147,8 +113,100 @@ public class TmdbSearchTest extends AbstractTests {
String query = "action";
int page = 0;
TmdbResultsList<Keyword> result = instance.searchKeyword(query, page);
assertFalse("No keywords found", result.getResults() == null);
assertTrue("No keywords found", result.getResults().size() > 0);
assertNotNull("Null results", result);
assertNotNull("Null keyword", result.getResults());
assertFalse("Empty keyword", result.isEmpty());
}
/**
* Test of searchList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testSearchList() throws MovieDbException {
LOG.info("searchList");
String query = "watch";
int page = 0;
TmdbResultsList<UserList> result = instance.searchList(query, page, null);
assertNotNull("Null results", result);
assertNotNull("Null list", result.getResults());
assertFalse("Empty list", result.isEmpty());
}
/**
* Test of searchMovie method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testSearchMovie() throws MovieDbException {
LOG.info("searchMovie");
// Try a movie with less than 1 page of results
TmdbResultsList<MovieDb> movieList = instance.searchMovie("Blade Runner", 0, "", null, 0, 0, SearchType.PHRASE);
assertTrue("No movies found, should be at least 1", movieList.getResults().size() > 0);
// Try a russian langugage movie
movieList = instance.searchMovie("О чём говорят мужчины", 0, LANGUAGE_RUSSIAN, null, 0, 0, SearchType.PHRASE);
assertTrue("No 'RU' movies found, should be at least 1", movieList.getResults().size() > 0);
// Try a movie with more than 20 results
movieList = instance.searchMovie("Star Wars", 0, LANGUAGE_ENGLISH, null, 0, 0, SearchType.PHRASE);
assertTrue("Not enough movies found, should be over 15, found " + movieList.getResults().size(), movieList.getResults().size() >= 15);
}
/**
* Test of searchMulti method, of class TmdbSearch.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testSearchMulti() throws MovieDbException {
System.out.println("searchMulti");
String query = "j";
Integer page = null;
String language = "";
Boolean includeAdult = null;
String expResult = "";
String result = instance.searchMulti(query, page, language, includeAdult);
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 searchPeople method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testSearchPeople() throws MovieDbException {
LOG.info("searchPeople");
String personName = "Bruce Willis";
TmdbResultsList<Person> result = instance.searchPeople(personName, null, null, SearchType.PHRASE);
assertNotNull("Null results", result);
assertNotNull("Null people", result.getResults());
assertFalse("Empty people", result.isEmpty());
}
/**
* Test of searchTV method, of class TmdbSearch.
*
* @throws com.omertron.themoviedbapi.MovieDbException
*/
@Test
public void testSearchTV() throws MovieDbException {
System.out.println("searchTV");
String query = "The Walking Dead";
Integer page = null;
String language = LANGUAGE_ENGLISH;
Integer firstAirDateYear = null;
SearchType searchType = SearchType.PHRASE;
TmdbResultsList<TVBasic> result = instance.searchTV(query, page, language, firstAirDateYear, searchType);
assertNotNull("Null results", result);
assertNotNull("Null TV", result.getResults());
assertFalse("Empty TV", result.isEmpty());
}
}