@Test
 public void shouldParseUserRatingOfMovies() throws Exception {
   List<MovieDbData> result = MovieListParser.parse(makeMovieListJson(MOVIE_1, MOVIE_2));
   assertThat(result, hasSize(2));
   MovieDbData movie = result.get(1);
   assertThat(movie.userRating, is(7.7));
 }
 @Test
 public void shouldParsePosterPath() throws Exception {
   List<MovieDbData> result = MovieListParser.parse(makeMovieListJson(MOVIE_1, MOVIE_2));
   assertThat(result, hasSize(2));
   MovieDbData movie = result.get(1);
   assertThat(movie.posterPath, is("/AjbENYG3b8lhYSkdrWwlhVLRPKR.jpg"));
 }
 @Test
 public void shouldParseTitleOfMovie() throws Exception {
   List<MovieDbData> result = MovieListParser.parse(makeMovieListJson(MOVIE_1));
   assertThat(result, hasSize(1));
   MovieDbData movie = result.get(0);
   assertThat(movie.originalTitle, is("Jurassic World"));
 }
 @Test
 public void shouldParseTitleOfMovies() throws Exception {
   List<MovieDbData> result = MovieListParser.parse(makeMovieListJson(MOVIE_1, MOVIE_2));
   assertThat(result, hasSize(2));
   MovieDbData movie = result.get(1);
   assertThat(movie.originalTitle, is("The Martian"));
 }
 @Test
 public void shouldParseReleaseDateOfMovies() throws Exception {
   List<MovieDbData> result = MovieListParser.parse(makeMovieListJson(MOVIE_1, MOVIE_2));
   assertThat(result, hasSize(2));
   MovieDbData movie = result.get(1);
   assertThat(movie.releaseDate.toString(), is(createDate(2015, 10, 2)));
 }
 @Test
 public void shouldParsePlotSynopsisOfMovies() throws Exception {
   List<MovieDbData> result = MovieListParser.parse(makeMovieListJson(MOVIE_1, MOVIE_2));
   assertThat(result, hasSize(2));
   MovieDbData movie = result.get(1);
   assertThat(
       movie.plotSynopsis, startsWith("During a manned mission to Mars, Astronaut Mark Watney"));
 }
 @Test
 public void shouldHandleEntryWithoutReleaseDate() throws Exception {
   List<MovieDbData> result =
       MovieListParser.parse(
           makeMovieListJson(
               MOVIE_2.replace("\"release_date\":\"2015-10-02\",", "\"release_date\":\"null\",")));
   assertThat(result.get(0).releaseDate, is(nullValue()));
 }
 @Test
 public void shouldThrowIfMissingTitle() throws Exception {
   try {
     MovieListParser.parse(
         makeMovieListJson(MOVIE_1.replace("\"original_title\":\"Jurassic World\",", "")));
     fail("Should have thrown");
   } catch (ParseException e) {
     assertThat(e.getMessage(), containsString("Failed to parse movie result"));
   }
 }
 @Test
 public void shouldIngoreEntriesWithoutSnapshot() throws Exception {
   List<MovieDbData> result =
       MovieListParser.parse(
           makeMovieListJson(
               MOVIE_2.replace(
                   "\"poster_path\":\"/AjbENYG3b8lhYSkdrWwlhVLRPKR.jpg\"",
                   "\"poster_path\":\"null\"")));
   assertThat(result.size(), is(0));
 }
 @Test
 public void shouldThrowIfErrorMessage() throws Exception {
   try {
     MovieListParser.parse(
         "{\"status_code\":7,\"status_message\":\"Invalid API key: You must be granted a valid key.\"}");
     fail("Should have thrown");
   } catch (ParseException e) {
     assertThat(e.getMessage(), containsString("status_code"));
     assertThat(e.getMessage(), containsString("status_message"));
     assertThat(e.getMessage(), containsString("Invalid API key"));
   }
 }
 @Test
 public void shouldReturnEmptyListIfInputIsEmpty() throws Exception {
   assertThat(MovieListParser.parse(makeMovieListJson()), hasSize(0));
 }
 @Test(expected = ParseException.class)
 public void shouldThrowIfNonJsonInput() throws Exception {
   MovieListParser.parse("");
 }