Search in sources :

Example 6 with ComicSeries

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

the class MainActivityTest method shouldOpenComicSeriesDetailActivityOnRecyclerViewItemClicked.

@Test
public void shouldOpenComicSeriesDetailActivityOnRecyclerViewItemClicked() throws Exception {
    givenThereAreSomeCharacters(ANY_NUMBER_OF_CHARACTERS);
    List<ComicSeries> comicSeries = givenThereAreSomeComicSeries(ANY_NUMBER_OF_COMIC_SERIES);
    givenAnyComicSeriesDetail();
    int comicSeriesIndex = 0;
    Activity activity = startActivity();
    registerIdlingResources(new ViewPagerIdlingResource((ViewPager) activity.findViewById(R.id.vp_main)));
    onView(withId(R.id.vp_main)).perform(swipeLeft());
    onView(withId(R.id.rv_comics)).perform(RecyclerViewActions.actionOnItemAtPosition(comicSeriesIndex, click()));
    ComicSeries comicSeriesSelected = comicSeries.get(comicSeriesIndex);
    intended(hasComponent(ComicSeriesDetailsActivity.class.getCanonicalName()));
    intended(hasExtra("ComicSeriesDetailsActivity.ComicSeriesKey", comicSeriesSelected.getKey().intValue()));
}
Also used : ViewPagerIdlingResource(com.karumi.rosie.sample.idlingresources.ViewPagerIdlingResource) ComicSeries(com.karumi.rosie.sample.comics.domain.model.ComicSeries) CharacterDetailsActivity(com.karumi.rosie.sample.characters.view.activity.CharacterDetailsActivity) ComicSeriesDetailsActivity(com.karumi.rosie.sample.comics.view.activity.ComicSeriesDetailsActivity) Activity(android.app.Activity) ViewPager(android.support.v4.view.ViewPager) LargeTest(android.test.suitebuilder.annotation.LargeTest) InjectedInstrumentationTest(com.karumi.rosie.sample.InjectedInstrumentationTest) Test(org.junit.Test)

Example 7 with ComicSeries

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

the class MainActivityTest method givenAnyComicSeriesDetail.

private void givenAnyComicSeriesDetail() throws Exception {
    ComicSeries comicSeries = new ComicSeries();
    comicSeries.setKey(0);
    comicSeries.setDescription("desc - " + 0);
    comicSeries.setName("name - " + 0);
    comicSeries.setComplete(true);
    comicSeries.setComics(new ArrayList<Comic>());
    comicSeries.setCoverUrl("https://i.annihil.us/u/prod/marvel/i/mg/c/60/55b6a28ef24fa.jpg");
    when(comicSeriesRepository.getComicSeriesDetail(any(Integer.class))).thenReturn(comicSeries);
}
Also used : ComicSeries(com.karumi.rosie.sample.comics.domain.model.ComicSeries) Comic(com.karumi.rosie.sample.comics.domain.model.Comic)

Example 8 with ComicSeries

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

the class MainActivityTest method givenThereAreSomeComicSeries.

private List<ComicSeries> givenThereAreSomeComicSeries(int numberOfComicSeries) throws Exception {
    List<ComicSeries> comics = new LinkedList<>();
    for (int i = 0; i < numberOfComicSeries; i++) {
        ComicSeries comic = getComicSeries(i);
        comics.add(comic);
    }
    PaginatedCollection<ComicSeries> paginatedCollection = new PaginatedCollection<>(comics);
    paginatedCollection.setPage(Page.withOffsetAndLimit(0, numberOfComicSeries));
    paginatedCollection.setHasMore(false);
    when(comicSeriesRepository.getPage(any(Page.class))).thenReturn(paginatedCollection);
    return comics;
}
Also used : ComicSeries(com.karumi.rosie.sample.comics.domain.model.ComicSeries) Page(com.karumi.rosie.repository.datasource.paginated.Page) LinkedList(java.util.LinkedList) PaginatedCollection(com.karumi.rosie.repository.PaginatedCollection)

Example 9 with ComicSeries

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

the class GetComicSeriesDetails method getComicSeriesDetails.

@UseCase
public void getComicSeriesDetails(int comicSeriesKey) throws Exception {
    ComicSeries comicSeries = repository.getComicSeriesDetail(comicSeriesKey);
    notifySuccess(comicSeries);
}
Also used : ComicSeries(com.karumi.rosie.sample.comics.domain.model.ComicSeries) RosieUseCase(com.karumi.rosie.domain.usecase.RosieUseCase) UseCase(com.karumi.rosie.domain.usecase.annotation.UseCase)

Example 10 with ComicSeries

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

the class ComicSeriesRepository method getComicSeriesDetail.

public ComicSeries getComicSeriesDetail(Integer key) throws Exception {
    ComicSeries comicSeries = getByKey(key);
    if (!comicSeries.isComplete()) {
        List<Comic> comicBySeries = apiDataSource.getComicBySeries(key);
        comicSeries.setComics(comicBySeries);
        comicSeries.setComplete(true);
    }
    return comicSeries;
}
Also used : ComicSeries(com.karumi.rosie.sample.comics.domain.model.ComicSeries) Comic(com.karumi.rosie.sample.comics.domain.model.Comic)

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