content: package <%= appPackage %>.ui.login;
  
  import <%= appPackage %>.data.network.model.LoginRequest;
  import <%= appPackage %>.data.network.model.LoginResponse;
  import <%= appPackage %>.utils.rx.TestSchedulerProvider;
  
  import org.junit.After;
  import org.junit.Before;
  import org.junit.BeforeClass;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.mockito.Mock;
  import org.mockito.junit.MockitoJUnitRunner;
  
  import io.reactivex.Observable;
  import io.reactivex.disposables.CompositeDisposable;
  import io.reactivex.schedulers.TestScheduler;
  
  import static org.mockito.Mockito.doReturn;
  import static org.mockito.Mockito.verify;
  
  /**
   * Created by janisharali on 21/07/17.
   */
  
  @RunWith(MockitoJUnitRunner.class)
  public class LoginPresenterTest {
  
      @Mock
      LoginMvpView mMockLoginMvpView;
      @Mock
      LoginMvpInteractor mMockLoginMvpInteractor;
  
      private LoginPresenter<LoginMvpView, LoginMvpInteractor> mLoginPresenter;
      private TestScheduler mTestScheduler;
  
      @BeforeClass
      public static void onlyOnce() throws Exception {
      }
  
      @Before
      public void setUp() throws Exception {
          CompositeDisposable compositeDisposable = new CompositeDisposable();
          mTestScheduler = new TestScheduler();
          TestSchedulerProvider testSchedulerProvider = new TestSchedulerProvider(mTestScheduler);
          mLoginPresenter = new LoginPresenter<>(
                  mMockLoginMvpInteractor,
                  testSchedulerProvider,
                  compositeDisposable);
          mLoginPresenter.onAttach(mMockLoginMvpView);
      }
  
      @Test
      public void testServerLoginSuccess() {
  
          String email = "dummy@gmail.com";
          String password = "password";
  
          LoginResponse loginResponse = new LoginResponse();
  
          doReturn(Observable.just(loginResponse))
                  .when(mMockLoginMvpInteractor)
                  .doServerLoginApiCall(new LoginRequest
                          .ServerLoginRequest(email, password));
  
          mLoginPresenter.onServerLoginClick(email, password);
  
          mTestScheduler.triggerActions();
  
          verify(mMockLoginMvpView).showLoading();
          verify(mMockLoginMvpView).hideLoading();
          verify(mMockLoginMvpView).openMainActivity();
      }
  
  
      @After
      public void tearDown() throws Exception {
          mLoginPresenter.onDetach();
      }
  }
  