// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
//     Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
//     Observable<String> getAppNameFromPackage(String packageName);
//     Observable<AppInfo> getApplicationInfo(String packageName);
//     Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
// 
// }
// 
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
//     private String mPackageName;
//     private String mAppName;
//     private Drawable mAppIcon;
// 
//     public InstalledPackageHeader() {
// 
//     }
// 
//     public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
//         this.mPackageName = packageName;
//         this.mAppName = appName;
//         this.mAppIcon = appIcon;
//     }
// 
//     public Drawable getAppIcon() {
//         return mAppIcon;
//     }
//     public void setAppIcon(Drawable mAppIcon) {
//         this.mAppIcon = mAppIcon;
//     }
// 
//     public String getAppName() {
//         return mAppName;
//     }
//     public void setAppName(String mAppName) {
//         this.mAppName = mAppName;
//     }
// 
//     public String getPackageName() {
//         return mPackageName;
//     }
//     public void setPackageName(String mPackageName) {
//         this.mPackageName = mPackageName;
//     }
// }
// 
// Path: app/src/test/java/com/livingstoneapp/presenters/utils/RxSchedulersOverrideRule.java
// public class RxSchedulersOverrideRule implements TestRule {
// 
//     private final RxJavaSchedulersHook mRxJavaSchedulersHook = new RxJavaSchedulersHook() {
//         @Override
//         public Scheduler getIOScheduler() {
//             return Schedulers.immediate();
//         }
// 
//         @Override
//         public Scheduler getNewThreadScheduler() {
//             return Schedulers.immediate();
//         }
//     };
// 
//     private final RxAndroidSchedulersHook mRxAndroidSchedulersHook = new RxAndroidSchedulersHook() {
//         @Override
//         public Scheduler getMainThreadScheduler() {
//             return Schedulers.immediate();
//         }
//     };
// 
//     // Hack to get around RxJavaPlugins.reset() not being public
//     // See https://github.com/ReactiveX/RxJava/issues/2297
//     // Hopefully the method will be public in new releases of RxAndroid and we can remove the hack.
//     private void callResetViaReflectionIn(RxJavaPlugins rxJavaPlugins)
//             throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
//         Method method = rxJavaPlugins.getClass().getDeclaredMethod("reset");
//         method.setAccessible(true);
//         method.invoke(rxJavaPlugins);
//     }
// 
//     @Override
//     public Statement apply(final Statement base, Description description) {
//         return new Statement() {
//             @Override
//             public void evaluate() throws Throwable {
//                 RxAndroidPlugins.getInstance().reset();
//                 RxAndroidPlugins.getInstance().registerSchedulersHook(mRxAndroidSchedulersHook);
//                 callResetViaReflectionIn(RxJavaPlugins.getInstance());
//                 RxJavaPlugins.getInstance().registerSchedulersHook(mRxJavaSchedulersHook);
// 
//                 base.evaluate();
// 
//                 RxAndroidPlugins.getInstance().reset();
//                 callResetViaReflectionIn(RxJavaPlugins.getInstance());
//             }
//         };
//     }
// }
// 
// Path: app/src/main/java/com/livingstoneapp/views/IPackageListView.java
// public interface IPackageListView {
//     void init();
//     void setInstalledPackages(List<InstalledPackageHeader> items);
//     void setError(String message);
//     void startDetailActivity(InstalledPackageHeader item);
//     void setDetailFragment(InstalledPackageHeader item);
//     void showWaitDialog();
//     void hideWaitDialog();
//     void showContentView();
//     void hideContentView();
// }


import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.models.InstalledPackageHeader;
import com.livingstoneapp.presenters.utils.RxSchedulersOverrideRule;
import com.livingstoneapp.views.IPackageListView;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.never;
import static org.mockito.Matchers.anyListOf;
package com.livingstoneapp.presenters;






/**
 * Created by Renier on 2016/03/11.
 */

@RunWith(MockitoJUnitRunner.class)
public class PackageListActivityPresenterImplTest {

    @Mock
    IPackageListView mView;
    @Mock
    IPackageInteractor mPackageInteractor;

    private IPackageListActivityPresenter mPresenter;

    @Rule
    public final RxSchedulersOverrideRule mOverrideSchedulersRule = new RxSchedulersOverrideRule();

    @Before
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);

        mPresenter = new PackageListActivityPresenterImpl(mPackageInteractor);
        mPresenter.setView(mView);
    }

    @After
    public void tearDown() throws Exception {

    }

    @Test
    public void testInit() {
        mPresenter.init();

        verify(mView, times(1)).init();
    }

    @Test
    public void testLoadPackages() {
// Path: app/src/main/java/com/livingstoneapp/interactors/IPackageInteractor.java
// public interface IPackageInteractor {
//     Observable<ArrayList<InstalledPackageHeader>> getInstalledPackages(boolean refresh);
//     Observable<String> getAppNameFromPackage(String packageName);
//     Observable<AppInfo> getApplicationInfo(String packageName);
//     Observable<ArrayList<FeatureInfoInternal>> getRequestedFeatures(String packageName);
// 
// }
// 
// Path: app/src/main/java/com/livingstoneapp/models/InstalledPackageHeader.java
// public class InstalledPackageHeader {
//     private String mPackageName;
//     private String mAppName;
//     private Drawable mAppIcon;
// 
//     public InstalledPackageHeader() {
// 
//     }
// 
//     public InstalledPackageHeader(String packageName, String appName, Drawable appIcon) {
//         this.mPackageName = packageName;
//         this.mAppName = appName;
//         this.mAppIcon = appIcon;
//     }
// 
//     public Drawable getAppIcon() {
//         return mAppIcon;
//     }
//     public void setAppIcon(Drawable mAppIcon) {
//         this.mAppIcon = mAppIcon;
//     }
// 
//     public String getAppName() {
//         return mAppName;
//     }
//     public void setAppName(String mAppName) {
//         this.mAppName = mAppName;
//     }
// 
//     public String getPackageName() {
//         return mPackageName;
//     }
//     public void setPackageName(String mPackageName) {
//         this.mPackageName = mPackageName;
//     }
// }
// 
// Path: app/src/test/java/com/livingstoneapp/presenters/utils/RxSchedulersOverrideRule.java
// public class RxSchedulersOverrideRule implements TestRule {
// 
//     private final RxJavaSchedulersHook mRxJavaSchedulersHook = new RxJavaSchedulersHook() {
//         @Override
//         public Scheduler getIOScheduler() {
//             return Schedulers.immediate();
//         }
// 
//         @Override
//         public Scheduler getNewThreadScheduler() {
//             return Schedulers.immediate();
//         }
//     };
// 
//     private final RxAndroidSchedulersHook mRxAndroidSchedulersHook = new RxAndroidSchedulersHook() {
//         @Override
//         public Scheduler getMainThreadScheduler() {
//             return Schedulers.immediate();
//         }
//     };
// 
//     // Hack to get around RxJavaPlugins.reset() not being public
//     // See https://github.com/ReactiveX/RxJava/issues/2297
//     // Hopefully the method will be public in new releases of RxAndroid and we can remove the hack.
//     private void callResetViaReflectionIn(RxJavaPlugins rxJavaPlugins)
//             throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
//         Method method = rxJavaPlugins.getClass().getDeclaredMethod("reset");
//         method.setAccessible(true);
//         method.invoke(rxJavaPlugins);
//     }
// 
//     @Override
//     public Statement apply(final Statement base, Description description) {
//         return new Statement() {
//             @Override
//             public void evaluate() throws Throwable {
//                 RxAndroidPlugins.getInstance().reset();
//                 RxAndroidPlugins.getInstance().registerSchedulersHook(mRxAndroidSchedulersHook);
//                 callResetViaReflectionIn(RxJavaPlugins.getInstance());
//                 RxJavaPlugins.getInstance().registerSchedulersHook(mRxJavaSchedulersHook);
// 
//                 base.evaluate();
// 
//                 RxAndroidPlugins.getInstance().reset();
//                 callResetViaReflectionIn(RxJavaPlugins.getInstance());
//             }
//         };
//     }
// }
// 
// Path: app/src/main/java/com/livingstoneapp/views/IPackageListView.java
// public interface IPackageListView {
//     void init();
//     void setInstalledPackages(List<InstalledPackageHeader> items);
//     void setError(String message);
//     void startDetailActivity(InstalledPackageHeader item);
//     void setDetailFragment(InstalledPackageHeader item);
//     void showWaitDialog();
//     void hideWaitDialog();
//     void showContentView();
//     void hideContentView();
// }


// Path: app/src/test/java/com/livingstoneapp/presenters/PackageListActivityPresenterImplTest.java
import com.livingstoneapp.interactors.IPackageInteractor;
import com.livingstoneapp.models.InstalledPackageHeader;
import com.livingstoneapp.presenters.utils.RxSchedulersOverrideRule;
import com.livingstoneapp.views.IPackageListView;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.never;
import static org.mockito.Matchers.anyListOf;

package com.livingstoneapp.presenters;






/**
 * Created by Renier on 2016/03/11.
 */

@RunWith(MockitoJUnitRunner.class)
public class PackageListActivityPresenterImplTest {

    @Mock
    IPackageListView mView;
    @Mock
    IPackageInteractor mPackageInteractor;

    private IPackageListActivityPresenter mPresenter;

    @Rule
    public final RxSchedulersOverrideRule mOverrideSchedulersRule = new RxSchedulersOverrideRule();

    @Before
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);

        mPresenter = new PackageListActivityPresenterImpl(mPackageInteractor);
        mPresenter.setView(mView);
    }

    @After
    public void tearDown() throws Exception {

    }

    @Test
    public void testInit() {
        mPresenter.init();

        verify(mView, times(1)).init();
    }

    @Test
    public void testLoadPackages() {
        ArrayList<InstalledPackageHeader> toReturn = new ArrayList<>();