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()));
}
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);
}
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;
}
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);
}
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;
}
Aggregations