// Path: app/src/androidTest/java/com/jonathanpetitfrere/mvvm/TestApplication.java
// public class TestApplication extends MvvmApplication {
// 
//     public void setAppGraph(AppGraph appGraph) {
//         this.component = appGraph;
//     }
// 
// }
// 
// Path: app/src/main/java/com/jonathanpetitfrere/mvvm/repository/UserRepository.java
// @Singleton
// public class UserRepository {
// 
//     @Inject
//     UserApi userApi;
// 
//     @Inject
//     UserDao userDao;
// 
//     @Inject
//     UserMapper mapper;
// 
//     @Inject
//     Transformers transformers;
// 
//     @Inject
//     UserRepository() {}
// 
//     public LiveData<User> getUser(String email) {
//         MutableLiveData<User> liveData = new MutableLiveData<>();
// 
//         userDao.loadUser(email)
//                 .compose(transformers.applySchedulersToFlowable())
//                 .subscribe(liveData::setValue, Timber::d);
// 
//         userApi.getUser(email)
//                 .compose(transformers.applySchedulersToFlowable())
//                 .map(mapper::toEntity)
//                 .subscribe(userDao::saveUser, Timber::d);
// 
//         return liveData;
//     }
// 
//     public LiveData<List<User>> getUsers() {
//         MutableLiveData<List<User>> liveData = new MutableLiveData<>();
// 
//         userDao.loadUsers()
//                 .compose(transformers.applySchedulersToFlowable())
//                 .subscribe(liveData::setValue, Timber::d);
// 
//         userApi.getUsers()
//                 .compose(transformers.applySchedulersToFlowable())
//                 .flatMapIterable(users -> users)
//                 .map(mapper::toEntity)
//                 .subscribe(userDao::saveUser, Timber::d);
// 
//         return liveData;
//     }
// 
//     public LiveData<Boolean> saveUser(User user) {
//         MutableLiveData<Boolean> liveData = new MutableLiveData<>();
// 
//         Completable.fromAction(() -> userDao.saveUser(user))
//                 .compose(transformers.applySchedulersToCompletable())
//                 .subscribe(() -> liveData.setValue(true), throwable -> {
//                     Timber.d(throwable);
//                     liveData.setValue(false);
//                 });
// 
// 
//         return liveData;
//     }
// }


import android.arch.core.executor.testing.InstantTaskExecutorRule;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.jonathanpetitfrere.mvvm.TestApplication;
import com.jonathanpetitfrere.mvvm.repository.UserRepository;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.only;
import static org.mockito.Mockito.verify;
package com.jonathanpetitfrere.mvvm.ui.main;





/**
 * @author jpetit
 */

@RunWith(AndroidJUnit4.class)
public class MainViewModelTest {

    @Rule
    public MockitoRule rule = MockitoJUnit.rule();

    @Rule
    public InstantTaskExecutorRule instantExecutorRule = new InstantTaskExecutorRule();

    @Mock
    public UserRepository userRepository;

    private MainViewModel viewModel;

    @Before
    public void setup() {
// Path: app/src/androidTest/java/com/jonathanpetitfrere/mvvm/TestApplication.java
// public class TestApplication extends MvvmApplication {
// 
//     public void setAppGraph(AppGraph appGraph) {
//         this.component = appGraph;
//     }
// 
// }
// 
// Path: app/src/main/java/com/jonathanpetitfrere/mvvm/repository/UserRepository.java
// @Singleton
// public class UserRepository {
// 
//     @Inject
//     UserApi userApi;
// 
//     @Inject
//     UserDao userDao;
// 
//     @Inject
//     UserMapper mapper;
// 
//     @Inject
//     Transformers transformers;
// 
//     @Inject
//     UserRepository() {}
// 
//     public LiveData<User> getUser(String email) {
//         MutableLiveData<User> liveData = new MutableLiveData<>();
// 
//         userDao.loadUser(email)
//                 .compose(transformers.applySchedulersToFlowable())
//                 .subscribe(liveData::setValue, Timber::d);
// 
//         userApi.getUser(email)
//                 .compose(transformers.applySchedulersToFlowable())
//                 .map(mapper::toEntity)
//                 .subscribe(userDao::saveUser, Timber::d);
// 
//         return liveData;
//     }
// 
//     public LiveData<List<User>> getUsers() {
//         MutableLiveData<List<User>> liveData = new MutableLiveData<>();
// 
//         userDao.loadUsers()
//                 .compose(transformers.applySchedulersToFlowable())
//                 .subscribe(liveData::setValue, Timber::d);
// 
//         userApi.getUsers()
//                 .compose(transformers.applySchedulersToFlowable())
//                 .flatMapIterable(users -> users)
//                 .map(mapper::toEntity)
//                 .subscribe(userDao::saveUser, Timber::d);
// 
//         return liveData;
//     }
// 
//     public LiveData<Boolean> saveUser(User user) {
//         MutableLiveData<Boolean> liveData = new MutableLiveData<>();
// 
//         Completable.fromAction(() -> userDao.saveUser(user))
//                 .compose(transformers.applySchedulersToCompletable())
//                 .subscribe(() -> liveData.setValue(true), throwable -> {
//                     Timber.d(throwable);
//                     liveData.setValue(false);
//                 });
// 
// 
//         return liveData;
//     }
// }


// Path: app/src/androidTest/java/com/jonathanpetitfrere/mvvm/ui/main/MainViewModelTest.java
import android.arch.core.executor.testing.InstantTaskExecutorRule;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.jonathanpetitfrere.mvvm.TestApplication;
import com.jonathanpetitfrere.mvvm.repository.UserRepository;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.only;
import static org.mockito.Mockito.verify;

package com.jonathanpetitfrere.mvvm.ui.main;





/**
 * @author jpetit
 */

@RunWith(AndroidJUnit4.class)
public class MainViewModelTest {

    @Rule
    public MockitoRule rule = MockitoJUnit.rule();

    @Rule
    public InstantTaskExecutorRule instantExecutorRule = new InstantTaskExecutorRule();

    @Mock
    public UserRepository userRepository;

    private MainViewModel viewModel;

    @Before
    public void setup() {
        TestApplication application = ((TestApplication) InstrumentationRegistry.getTargetContext().getApplicationContext());