use of com.karumi.rosie.sample.characters.domain.model.Character in project Rosie by Karumi.
the class MainActivityTest method givenConnectionExceptionObtainingCharacters.
private void givenConnectionExceptionObtainingCharacters() throws Exception {
when(charactersRepository.getAll(ReadPolicy.CACHE_ONLY)).thenReturn(new ArrayList<Character>());
when(charactersRepository.getPage(any(Page.class))).thenThrow(new MarvelApiException(ANY_EXCEPTION, new UnknownHostException()));
}
use of com.karumi.rosie.sample.characters.domain.model.Character in project Rosie by Karumi.
the class MainActivityTest method givenThereAreSomeCharacters.
private List<Character> givenThereAreSomeCharacters(int numberOfCharacters) throws Exception {
List<Character> characters = new LinkedList<>();
for (int i = 0; i < numberOfCharacters; i++) {
Character character = getCharacter(i);
characters.add(character);
when(charactersRepository.getByKey(String.valueOf(i))).thenReturn(character);
}
PaginatedCollection<Character> paginatedCollection = new PaginatedCollection<>(characters);
paginatedCollection.setPage(Page.withOffsetAndLimit(0, numberOfCharacters));
paginatedCollection.setHasMore(false);
when(charactersRepository.getPage(any(Page.class))).thenReturn(paginatedCollection);
return characters;
}
use of com.karumi.rosie.sample.characters.domain.model.Character in project Rosie by Karumi.
the class GetCharacterDetails method getCharacterDetails.
@UseCase
public void getCharacterDetails(String characterKey) throws Exception {
Character character = charactersRepository.getByKey(characterKey);
notifySuccess(character);
}
use of com.karumi.rosie.sample.characters.domain.model.Character in project Rosie by Karumi.
the class CharactersApiDataSource method getPage.
@Override
public PaginatedCollection<Character> getPage(Page page) throws MarvelApiException {
int offset = page.getOffset();
int limit = page.getLimit();
MarvelResponse<CharactersDto> charactersApiResponse = characterApiClient.getAll(offset, limit);
CharactersDto charactersDto = charactersApiResponse.getResponse();
Collection<Character> characters = mapper.reverseMap(charactersDto.getCharacters());
PaginatedCollection<Character> charactersPage = new PaginatedCollection<>(characters);
charactersPage.setPage(page);
charactersPage.setHasMore(charactersDto.getOffset() + charactersDto.getCount() < charactersDto.getTotal());
return charactersPage;
}
use of com.karumi.rosie.sample.characters.domain.model.Character in project Rosie by Karumi.
the class CharacterDetailsActivityTest method givenAValidCharacter.
private Character givenAValidCharacter() throws Exception {
Character character = getCharacter(ANY_CHARACTER_ID);
when(charactersRepository.getByKey(anyString())).thenReturn(character);
return character;
}
Aggregations