// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/AssignErrorState.java
// public class AssignErrorState<T> implements FlowableTransformer<T, T> {
// 
//     private ErrorStateView view;
//     private Scheduler uiScheduler;
// 
//     public AssignErrorState(ErrorStateView view, Scheduler uiScheduler) {
//         this.view = view;
//         this.uiScheduler = uiScheduler;
//     }
// 
//     @Override public Publisher<T> apply(Flowable<T> upstream) {
//         HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
//                 view.hideErrorState(),
//                 view.showErrorState(),
//                 error -> !(error instanceof ContentNotFoundError),
//                 uiScheduler
//         );
// 
//         return upstream.compose(delegate);
//     }
// 
// }
// 
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
// 
//     Action showErrorState();
// 
//     Action hideErrorState();
// 
// }
// 
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
//     return VerificationModeFactory.times(1);
// }


import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.AssignErrorState;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
package br.ufs.demos.rxmvp.playground.core;




/**
 * Created by bira on 6/30/17.
 */

@RunWith(MockitoJUnitRunner.class)
public class AssignErrorStateTests {

    Scheduler uiScheduler = Schedulers.trampoline();
    AssignErrorState<String> assignErrorState;

    @Mock Action show;
    @Mock Action hide;

    @Before public void beforeEachTest() {
        MockitoAnnotations.initMocks(this);

        ErrorStateView view = new ErrorStateView() {
            @Override public Action showErrorState() {
                return show;
            }

            @Override public Action hideErrorState() {
                return hide;
            }
        };

// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/AssignErrorState.java
// public class AssignErrorState<T> implements FlowableTransformer<T, T> {
// 
//     private ErrorStateView view;
//     private Scheduler uiScheduler;
// 
//     public AssignErrorState(ErrorStateView view, Scheduler uiScheduler) {
//         this.view = view;
//         this.uiScheduler = uiScheduler;
//     }
// 
//     @Override public Publisher<T> apply(Flowable<T> upstream) {
//         HideAtStartShowAtError<T> delegate = new HideAtStartShowAtError<>(
//                 view.hideErrorState(),
//                 view.showErrorState(),
//                 error -> !(error instanceof ContentNotFoundError),
//                 uiScheduler
//         );
// 
//         return upstream.compose(delegate);
//     }
// 
// }
// 
// Path: app/src/main/java/br/ufs/demos/rxmvp/playground/core/behaviours/errorstate/ErrorStateView.java
// public interface ErrorStateView {
// 
//     Action showErrorState();
// 
//     Action hideErrorState();
// 
// }
// 
// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/util/MockitoHelpers.java
// public static VerificationMode oneTimeOnly() {
//     return VerificationModeFactory.times(1);
// }


// Path: app/src/test/java/br/ufs/demos/rxmvp/playground/core/AssignErrorStateTests.java
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.AssignErrorState;
import br.ufs.demos.rxmvp.playground.core.behaviours.errorstate.ErrorStateView;
import io.reactivex.Flowable;
import io.reactivex.Scheduler;
import io.reactivex.functions.Action;
import io.reactivex.schedulers.Schedulers;
import static br.ufs.demos.rxmvp.playground.util.MockitoHelpers.oneTimeOnly;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;

package br.ufs.demos.rxmvp.playground.core;




/**
 * Created by bira on 6/30/17.
 */

@RunWith(MockitoJUnitRunner.class)
public class AssignErrorStateTests {

    Scheduler uiScheduler = Schedulers.trampoline();
    AssignErrorState<String> assignErrorState;

    @Mock Action show;
    @Mock Action hide;

    @Before public void beforeEachTest() {
        MockitoAnnotations.initMocks(this);

        ErrorStateView view = new ErrorStateView() {
            @Override public Action showErrorState() {
                return show;
            }

            @Override public Action hideErrorState() {
                return hide;
            }
        };

        assignErrorState = new AssignErrorState<>(view, uiScheduler);