@Override public List<Comic> getComicBySeries(int key) throws Exception { MarvelResponse<ComicsDto> comicsBySeries = seriesApiClient.getComicsBySeries(Integer.toString(key), 0, MAX_COMICS_BY_SERIES); ComicsDto comicsDto = comicsBySeries.getResponse(); List<Comic> comics = new ArrayList<>(); for (ComicDto comicDto : comicsDto.getComics()) { Comic comic = new Comic(); comic.setKey(comicDto.getId()); comic.setName(comicDto.getTitle()); comic.setThumbnailUrl(comicDto.getThumbnail().getImageUrl(MarvelImage.Size.PORTRAIT_UNCANNY)); comics.add(comic); } return comics; }
public MarvelResponse<ComicsDto> getComicsBySeries(String seriesId, int offset, int limit) throws MarvelApiException { ComicsQuery query = ComicsQuery.Builder.create().withOffset(offset).withLimit(limit).build(); return getComicsBySeries(seriesId, query); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionWhenCallGetComicBySerieAndLimitIsZero() throws Exception { SeriesApiClient seriesApiClient = givenSeriesApiClient(); enqueueMockResponse(); seriesApiClient.getComicsBySeries(ANY_SERIE_ID, ANY_OFFSET, INVALID_LIMIT); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionWhenCallGetComicBySerieAndSerieIdIsEmpty() throws Exception { SeriesApiClient seriesApiClient = givenSeriesApiClient(); enqueueMockResponse(); seriesApiClient.getComicsBySeries("", ANY_OFFSET, INVALID_LIMIT); }
.build(); seriesApiClient.getComicsBySeries(ANY_SERIE_ID, query);