Search in sources :

Example 16 with ComicSeries

use of com.karumi.rosie.sample.comics.domain.model.ComicSeries in project Rosie by Karumi.

the class ComicSeriesApiDataSource method getPage.

@Override
public PaginatedCollection<ComicSeries> getPage(Page page) throws MarvelApiException {
    int offset = page.getOffset();
    int limit = page.getLimit();
    MarvelResponse<SeriesCollectionDto> seriesApiResponse = seriesApiClient.getAll(offset, limit);
    SeriesCollectionDto seriesCollectionDto = seriesApiResponse.getResponse();
    Collection<ComicSeries> comicSeries = mapper.reverseMap(seriesCollectionDto.getSeries());
    PaginatedCollection<ComicSeries> comicSeriesPage = new PaginatedCollection<>(comicSeries);
    comicSeriesPage.setPage(page);
    comicSeriesPage.setHasMore(seriesCollectionDto.getOffset() + seriesCollectionDto.getCount() < seriesCollectionDto.getTotal());
    return comicSeriesPage;
}
Also used : ComicSeries(com.karumi.rosie.sample.comics.domain.model.ComicSeries) SeriesCollectionDto(com.karumi.marvelapiclient.model.SeriesCollectionDto) PaginatedCollection(com.karumi.rosie.repository.PaginatedCollection)

Example 17 with ComicSeries

use of com.karumi.rosie.sample.comics.domain.model.ComicSeries in project Rosie by Karumi.

the class ComicSeriesFakeDataSource method getRedWolf.

@NonNull
private ComicSeries getRedWolf() {
    ComicSeries redWolf = new ComicSeries();
    redWolf.setKey(RED_WOLF_KEY);
    redWolf.setName("Red Wolf # 2");
    redWolf.setCoverUrl("http://x.annihil.us/u/prod/marvel/i/mg/4/10/5655d353959ad/detail.jpg");
    redWolf.setDescription("WHO ARE THE GUARDIANS 1000?! Defending the galaxy is a good gig, but Drax isn’t thrilled" + " with the combat hours (not enough of them) and Rocket isn’t thrilled with the" + " compensation (not enough of it). They’re off on an adventure to supplement both," + " and Groot is happy to come along. But instead of the perks they want, they’re about" + " to get more trouble than they can handle. Good thing the Guardians 3000 are on hand" + " to help! But what about…THE GUARDIANS 1000??!! Also in this issue, Latour and" + " Cheung tell a one-off story of Ben Grimm and Rocket Raccoon, stuck on a planet" + " where culture is based on Earth-style professional wrestling…but the stakes are" + " life and death! THIS AIN’T KAYFABE, BROTHER! ");
    redWolf.setReleaseYear(2015);
    redWolf.setRating("Explicit Content");
    redWolf.setComics(getComics(redWolf.getName()));
    return redWolf;
}
Also used : ComicSeries(com.karumi.rosie.sample.comics.domain.model.ComicSeries) NonNull(android.support.annotation.NonNull)

Example 18 with ComicSeries

use of com.karumi.rosie.sample.comics.domain.model.ComicSeries in project Rosie by Karumi.

the class MainActivityTest method getComicSeries.

@NonNull
private ComicSeries getComicSeries(int id) {
    ComicSeries comicSeries = new ComicSeries();
    comicSeries.setKey(id);
    comicSeries.setName("ComicSeries - " + id);
    comicSeries.setDescription("Description Comic Serie - " + id);
    return comicSeries;
}
Also used : ComicSeries(com.karumi.rosie.sample.comics.domain.model.ComicSeries) NonNull(android.support.annotation.NonNull)

Example 19 with ComicSeries

use of com.karumi.rosie.sample.comics.domain.model.ComicSeries in project Rosie by Karumi.

the class ComicSeriesDetailsActivityTest method givenValidComicSeries.

private ComicSeries givenValidComicSeries() throws Exception {
    ComicSeries comicSeries = getComicSeries(ANY_COMIC_SERIES_ID);
    when(comicSeriesRepository.getComicSeriesDetail(anyInt())).thenReturn(comicSeries);
    return comicSeries;
}
Also used : ComicSeries(com.karumi.rosie.sample.comics.domain.model.ComicSeries)

Example 20 with ComicSeries

use of com.karumi.rosie.sample.comics.domain.model.ComicSeries in project Rosie by Karumi.

the class ComicSeriesDetailsActivityTest method shouldShowComicIfComicSeriesHaveComics.

@Test
public void shouldShowComicIfComicSeriesHaveComics() throws Exception {
    ComicSeries comicSeries = givenValidComicSeries();
    List<ComicSeriesDetailViewModel> comics = givenComicData(comicSeries);
    startActivity();
    onView(withId(R.id.rv_comics)).perform(RecyclerViewActions.scrollToPosition(1));
    assertRecyclerViewShowComics(comics);
}
Also used : ComicSeries(com.karumi.rosie.sample.comics.domain.model.ComicSeries) ComicSeriesDetailViewModel(com.karumi.rosie.sample.comics.view.viewmodel.ComicSeriesDetailViewModel) InjectedInstrumentationTest(com.karumi.rosie.sample.InjectedInstrumentationTest) Test(org.junit.Test)

Aggregations

ComicSeries (com.karumi.rosie.sample.comics.domain.model.ComicSeries)22 NonNull (android.support.annotation.NonNull)7 PaginatedCollection (com.karumi.rosie.repository.PaginatedCollection)3 InjectedInstrumentationTest (com.karumi.rosie.sample.InjectedInstrumentationTest)3 Comic (com.karumi.rosie.sample.comics.domain.model.Comic)3 Test (org.junit.Test)3 Page (com.karumi.rosie.repository.datasource.paginated.Page)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 Activity (android.app.Activity)1 ViewPager (android.support.v4.view.ViewPager)1 LargeTest (android.test.suitebuilder.annotation.LargeTest)1 SeriesCollectionDto (com.karumi.marvelapiclient.model.SeriesCollectionDto)1 SeriesDto (com.karumi.marvelapiclient.model.SeriesDto)1 RosieUseCase (com.karumi.rosie.domain.usecase.RosieUseCase)1 UseCase (com.karumi.rosie.domain.usecase.annotation.UseCase)1 CharacterDetailsActivity (com.karumi.rosie.sample.characters.view.activity.CharacterDetailsActivity)1 ComicSeriesDetailsActivity (com.karumi.rosie.sample.comics.view.activity.ComicSeriesDetailsActivity)1 ComicSeriesDetailViewModel (com.karumi.rosie.sample.comics.view.viewmodel.ComicSeriesDetailViewModel)1 ComicSeriesViewModel (com.karumi.rosie.sample.comics.view.viewmodel.ComicSeriesViewModel)1