SeriesApiClient extends MarvelApiClient { 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); } SeriesApiClient(MarvelApiConfig marvelApiConfig); MarvelResponse<SeriesCollectionDto> getAll(int offset, int limit); MarvelResponse<SeriesCollectionDto> getAll(SeriesQuery seriesQuery); MarvelResponse<SeriesDto> getSeriesById(String seriesId); MarvelResponse<ComicsDto> getComicsBySeries(String seriesId, int offset, int limit); MarvelResponse<ComicsDto> getComicsBySeries(String seriesId, ComicsQuery comicsQuery);  }
@Test public void shouldSendGetComicBySeriesRequestToTheCorrectEndpoint() throws Exception { SeriesApiClient seriesApiClient = givenSeriesApiClient(); enqueueMockResponse("getComics.json"); ComicsQuery query = ComicsQuery.Builder.create() .withFormat(Format.COMIC) .withFormatType(ComicsQuery.FormatType.COLLECTION) .withNoVariants() .withDateDescriptor(ComicsQuery.DateDescriptor.LAST_WEEK) .withDateRange(getAnyDate()) .withTitle(ANY_TITLE) .withTitleStartsWith(ANY_START_TITLE) .withStartYear(ANY_START_YEAR) .withIssueNumber(ANY_ISSUE_NUMBER) .withDiamondCode(ANY_DIAMOND_CODE) .withUpc(ANY_UPC) .withIsbn(ANY_ISBN) .withEan(ANY_EAN) .withIssn(ANY_ISSN) .withHasDigitalIssue() .withLimit(ANY_LIMIT) .withOffset(ANY_OFFSET) .addCreator(ANY_CREATOR) .addCharacter(ANY_CHARACTER) .withModifiedSince(getAnyDate()) .withOrderBy(OrderBy.NAME, false) .addEvent(getAnyEvents()) .addSerie(ANY_SERIE) .addStory(ANY_STORY) .addSharedAppearance(ANY_SHARED_APPEARANCES) .addCollaborator(getAnyCollaborators()) .build(); seriesApiClient.getComicsBySeries(ANY_SERIE_ID, query); assertRequestSentToContains("series/" + ANY_SERIE_ID, "format=" + Format.COMIC.toString(), "formatType=" + ComicsQuery.FormatType.COLLECTION, "noVariants=true", "dateDescriptor=" + LAST_WEEK_REQUEST, "dateRange=" + ANY_DATE_RANGE, "startYear=" + ANY_START_YEAR, "issueNumber=" + ANY_ISSUE_NUMBER, "diamondCode=" + ANY_DIAMOND_CODE, "upc=" + ANY_UPC, "isbn=" + ANY_ISBN, "ean=" + ANY_EAN, "issn=" + ANY_ISSN, "hasDigitalIssue=true", "creators=" + ANY_CREATOR, "characters=" + ANY_CHARACTER, "offset=" + ANY_OFFSET, "appearances=" + ANY_SHARED_APPEARANCES, "collaborators=" + COLLABORATORS_REQUEST, "limit=" + ANY_LIMIT, "title=" + ANY_TITLE, "titleStartsWith=" + ANY_START_TITLE, "modifiedSince=" + ANY_MODIFIED_SINCE, "orderBy=" + ORDER_NAME_DESCEDANT_VALUE, "events=" + EVENTS_REQUEST, "series=" + ANY_SERIE, "stories=" + ANY_STORY); }
@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); }