@Test(expected = IllegalArgumentException.class) public void shouldNotAcceptEmptyComicIds() throws Exception { ComicApiClient comicApiClient = givenComicApiClient(); comicApiClient.getComic(INVALID_COMIC_ID); }
} else if (operation.equals("getComic")) { ComicApiClient comicApiClient = new ComicApiClient(marvelApiConfig); MarvelResponse<ComicDto> comic = comicApiClient.getComic("42882"); System.out.println(comic.toString()); } else if (operation.equals("getSeries")) {
@Test public void shouldSendGetComicRequestToTheCorrectEndpoint() throws Exception { ComicApiClient comicApiClient = givenComicApiClient(); enqueueMockResponse("getComic.json"); comicApiClient.getComic(ANY_COMIC_ID); assertRequestSentToContains("comics/" + ANY_COMIC_ID); }
@Test public void shouldParseGetComicResponse() throws Exception { ComicApiClient comicApiClient = givenComicApiClient(); enqueueMockResponse("getComic.json"); MarvelResponse<ComicDto> comic = comicApiClient.getComic(ANY_COMIC_ID); assertBasicMarvelResponse(comic); ComicDto response = comic.getResponse(); assertIsLornaTheJungleGirl6(response); }
@Test(expected = MarvelApiException.class) public void shouldReturnMarvelExceptionWhenTheIdDoesNotExist() throws Exception { ComicApiClient comicApiClient = givenComicApiClient(); enqueueMockResponse(404, "{\"code\":404,\"status\":\"We couldn't find that comic\"}"); try { comicApiClient.getComic(ANY_NOT_FOUND_ID); } catch (MarvelApiException e) { assertEquals("404", e.getMarvelCode()); assertEquals("We couldn't find that comic", e.getMessage()); throw e; } }