@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 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")); } }