// Path: base/src/main/java/com/tobi/movies/Converter.java
// public interface Converter<T, R> {
// 
//     R convert(T input);
// }
// 
// Path: app/src/main/java/com/tobi/movies/misc/Threading.java
// public enum Threading {
//     SUBSCRIBER,
//     OBSERVER
// }


import android.support.annotation.NonNull;
import com.google.common.collect.Lists;
import com.tobi.movies.Converter;
import com.tobi.movies.misc.Threading;
import java.util.HashMap;
import java.util.List;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import rx.Observable;
import rx.Scheduler;
import rx.observers.TestSubscriber;
import rx.schedulers.Schedulers;
import static org.mockito.Mockito.when;

    @Mock
    private Converter<ApiMoviePoster, MoviePoster> posterConverter;

    private PopularStreamRepository streamRepository;

    @Before
    public void setUp() throws Exception {
        HashMap<Threading, Scheduler> schedulerHashMap = new HashMap<>();
        schedulerHashMap.put(Threading.SUBSCRIBER, Schedulers.immediate());
        schedulerHashMap.put(Threading.OBSERVER, Schedulers.immediate());

        streamRepository = new PopularStreamRepository(
                apiDataSource,
                schedulerHashMap,
                posterConverter
        );
    }

    @Test
    public void shouldReturnMoviePosters() throws Exception {
        // given
        ApiMoviePoster firstPoster = createApiMoviePoster(FIRST_MOVIE_ID, FIRST_POSTER_PATH);
        ApiMoviePoster secondPoster = createApiMoviePoster(SECOND_MOVIE_ID, SECOND_POSTER_PATH);
        givenApiDataSourceReturns(firstPoster, secondPoster);
        givenConverterConvertsPosters(firstPoster, secondPoster);

        // when
        Observable<List<MoviePoster>> popularPosters = streamRepository.getPopularPosters();
        TestSubscriber<List<MoviePoster>> testSubscriber = new TestSubscriber<>();
// Path: base/src/main/java/com/tobi/movies/Converter.java
// public interface Converter<T, R> {
// 
//     R convert(T input);
// }
// 
// Path: app/src/main/java/com/tobi/movies/misc/Threading.java
// public enum Threading {
//     SUBSCRIBER,
//     OBSERVER
// }


// Path: app/src/test/java/com/tobi/movies/popularstream/PopularStreamRepositoryTest.java
import android.support.annotation.NonNull;
import com.google.common.collect.Lists;
import com.tobi.movies.Converter;
import com.tobi.movies.misc.Threading;
import java.util.HashMap;
import java.util.List;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import rx.Observable;
import rx.Scheduler;
import rx.observers.TestSubscriber;
import rx.schedulers.Schedulers;
import static org.mockito.Mockito.when;


    @Mock
    private Converter<ApiMoviePoster, MoviePoster> posterConverter;

    private PopularStreamRepository streamRepository;

    @Before
    public void setUp() throws Exception {
        HashMap<Threading, Scheduler> schedulerHashMap = new HashMap<>();
        schedulerHashMap.put(Threading.SUBSCRIBER, Schedulers.immediate());
        schedulerHashMap.put(Threading.OBSERVER, Schedulers.immediate());

        streamRepository = new PopularStreamRepository(
                apiDataSource,
                schedulerHashMap,
                posterConverter
        );
    }

    @Test
    public void shouldReturnMoviePosters() throws Exception {
        // given
        ApiMoviePoster firstPoster = createApiMoviePoster(FIRST_MOVIE_ID, FIRST_POSTER_PATH);
        ApiMoviePoster secondPoster = createApiMoviePoster(SECOND_MOVIE_ID, SECOND_POSTER_PATH);
        givenApiDataSourceReturns(firstPoster, secondPoster);
        givenConverterConvertsPosters(firstPoster, secondPoster);

        // when
        Observable<List<MoviePoster>> popularPosters = streamRepository.getPopularPosters();
        TestSubscriber<List<MoviePoster>> testSubscriber = new TestSubscriber<>();
        popularPosters.subscribe(testSubscriber);