Search in sources :

Example 1 with Character

use of com.karumi.rosie.sample.characters.domain.model.Character in project Rosie by Karumi.

the class MainActivityTest method givenExceptionObtainingCharacters.

private void givenExceptionObtainingCharacters() throws Exception {
    when(charactersRepository.getAll(ReadPolicy.CACHE_ONLY)).thenReturn(new ArrayList<Character>());
    when(charactersRepository.getPage(any(Page.class))).thenThrow(new MarvelApiException(ANY_EXCEPTION, null));
}
Also used : MarvelApiException(com.karumi.marvelapiclient.MarvelApiException) Character(com.karumi.rosie.sample.characters.domain.model.Character) Page(com.karumi.rosie.repository.datasource.paginated.Page)

Example 2 with Character

use of com.karumi.rosie.sample.characters.domain.model.Character in project Rosie by Karumi.

the class MainActivityTest method getCharacter.

@NonNull
private Character getCharacter(int id) {
    Character character = new Character();
    character.setKey("" + id);
    character.setName("SuperHero - " + id);
    character.setDescription("Description Super Hero - " + id);
    character.setThumbnailUrl("https://id.annihil.us/u/prod/marvel/id/mg/c/60/55b6a28ef24fa.jpg");
    return character;
}
Also used : Character(com.karumi.rosie.sample.characters.domain.model.Character) NonNull(android.support.annotation.NonNull)

Example 3 with Character

use of com.karumi.rosie.sample.characters.domain.model.Character in project Rosie by Karumi.

the class GetCharacters method getAllCharactersInCache.

public PaginatedCollection<Character> getAllCharactersInCache() {
    Collection<Character> all;
    try {
        all = charactersRepository.getAll(ReadPolicy.CACHE_ONLY);
    } catch (Exception e) {
        all = new ArrayList<>();
    }
    if (all == null) {
        all = new ArrayList<>();
    }
    Page page = Page.withOffsetAndLimit(0, all.size());
    PaginatedCollection<Character> comics = new PaginatedCollection<>(all);
    comics.setPage(page);
    comics.setHasMore(true);
    return comics;
}
Also used : Character(com.karumi.rosie.sample.characters.domain.model.Character) ArrayList(java.util.ArrayList) Page(com.karumi.rosie.repository.datasource.paginated.Page) PaginatedCollection(com.karumi.rosie.repository.PaginatedCollection)

Example 4 with Character

use of com.karumi.rosie.sample.characters.domain.model.Character in project Rosie by Karumi.

the class CharactersFakeDataSource method getScarletWitch.

@NonNull
private Character getScarletWitch() {
    Character scarlet = new Character();
    scarlet.setKey(SCARLET_KEY);
    scarlet.setName("Scarlet Witch");
    scarlet.setThumbnailUrl("https://i.annihil.us/u/prod/marvel/i/mg/9/b0/537bc2375dfb9.jpg");
    scarlet.setDescription("Born at the Wundagore base of the High Evolutionary, in proximity to the eldritch energies" + " of the Elder God Chthon; Wanda and her brother Pietro's mother, Magda, fled " + "Wundagore shortly after their birth. Although not known at the time, Chthon formed " + "a mystic bond with Wanda, who, it was later learned, was destined to serve the role " + "of Nexus Being, a living focal point for the Earth dimension's mystical energy.");
    return scarlet;
}
Also used : Character(com.karumi.rosie.sample.characters.domain.model.Character) NonNull(android.support.annotation.NonNull)

Example 5 with Character

use of com.karumi.rosie.sample.characters.domain.model.Character in project Rosie by Karumi.

the class CharactersFakeDataSource method getSpiderman.

@NonNull
private Character getSpiderman() {
    Character spiderman = new Character();
    spiderman.setKey(SPIDERMAN_KEY);
    spiderman.setName("Spiderman");
    spiderman.setThumbnailUrl("http://x.annihil.us/u/prod/marvel/i/mg/6/60/538cd3628a05e.jpg");
    spiderman.setDescription("Bitten by a radioactive spider, high school student Peter Parker gained the speed, " + "strength and powers of a spider. Adopting the name Spider-Man, Peter hoped to start" + " a career using his new abilities. Taught that with great power comes great" + " responsibility, Spidey has vowed to use his powers to help people.");
    return spiderman;
}
Also used : Character(com.karumi.rosie.sample.characters.domain.model.Character) NonNull(android.support.annotation.NonNull)

Aggregations

Character (com.karumi.rosie.sample.characters.domain.model.Character)23 NonNull (android.support.annotation.NonNull)10 Page (com.karumi.rosie.repository.datasource.paginated.Page)4 PaginatedCollection (com.karumi.rosie.repository.PaginatedCollection)3 MarvelApiException (com.karumi.marvelapiclient.MarvelApiException)2 InjectedInstrumentationTest (com.karumi.rosie.sample.InjectedInstrumentationTest)2 LinkedList (java.util.LinkedList)2 Test (org.junit.Test)2 LargeTest (android.test.suitebuilder.annotation.LargeTest)1 CharactersDto (com.karumi.marvelapiclient.model.CharactersDto)1 RosieUseCase (com.karumi.rosie.domain.usecase.RosieUseCase)1 Success (com.karumi.rosie.domain.usecase.annotation.Success)1 UseCase (com.karumi.rosie.domain.usecase.annotation.UseCase)1 OnSuccessCallback (com.karumi.rosie.domain.usecase.callback.OnSuccessCallback)1 OnErrorCallback (com.karumi.rosie.domain.usecase.error.OnErrorCallback)1 CharacterDetailViewModel (com.karumi.rosie.sample.characters.view.viewmodel.CharacterDetailViewModel)1 CharacterViewModel (com.karumi.rosie.sample.characters.view.viewmodel.CharacterViewModel)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1