use of android.app.Application in project mosby by sockeqwe.
the class PresenterManagerTest method putNullPresenterThrowsNullPointerExceptino.
@Test
public void putNullPresenterThrowsNullPointerExceptino() {
MvpPresenter presenter = Mockito.mock(MvpPresenter.class);
Activity activity = Mockito.mock(Activity.class);
Application application = Mockito.mock(Application.class);
Mockito.when(activity.getApplication()).thenReturn(application);
try {
PresenterManager.putPresenter(null, "123", presenter);
Assert.fail("Exception expected");
} catch (NullPointerException e) {
}
try {
PresenterManager.putPresenter(activity, null, presenter);
Assert.fail("Exception expected");
} catch (NullPointerException e) {
}
try {
PresenterManager.putPresenter(activity, "123", null);
Assert.fail("Exception expected");
} catch (NullPointerException e) {
}
}
use of android.app.Application in project mosby by sockeqwe.
the class PresenterManagerTest method getViewStateReturnsNull.
@Test
public void getViewStateReturnsNull() {
Activity activity = Mockito.mock(Activity.class);
Application application = Mockito.mock(Application.class);
Mockito.when(activity.getApplication()).thenReturn(application);
Assert.assertNull(PresenterManager.getViewState(activity, "viewId123"));
}
use of android.app.Application in project mosby by sockeqwe.
the class PresenterManagerTest method getActivityScopeReturnsExistingOne.
@Test
public void getActivityScopeReturnsExistingOne() {
Activity activity = Mockito.mock(Activity.class);
Application application = Mockito.mock(Application.class);
Mockito.when(activity.getApplication()).thenReturn(application);
ActivityScopedCache scope1 = PresenterManager.getOrCreateActivityScopedCache(activity);
Assert.assertNotNull(scope1);
Assert.assertEquals(scope1, PresenterManager.getActivityScope(activity));
}
use of android.app.Application in project mosby by sockeqwe.
the class ActivityMvpViewStateDelegateImplTestNew method initComponents.
@Before
public void initComponents() {
view = new MvpView() {
};
viewState = Mockito.mock(ViewState.class);
presenter = Mockito.mock(MvpPresenter.class);
callback = Mockito.spy(PartialMvpViewStateDelegateCallbackImpl.class);
activity = Mockito.mock(Activity.class);
application = Mockito.mock(Application.class);
Mockito.doCallRealMethod().when(callback).setPresenter(presenter);
Mockito.doCallRealMethod().when(callback).getPresenter();
Mockito.doCallRealMethod().when(callback).setViewState(viewState);
Mockito.doCallRealMethod().when(callback).getViewState();
Mockito.when(callback.getMvpView()).thenReturn(view);
Mockito.when(activity.getApplication()).thenReturn(application);
Mockito.when(callback.createPresenter()).thenReturn(presenter);
Mockito.when(callback.createViewState()).thenReturn(viewState);
}
use of android.app.Application in project mosby by sockeqwe.
the class ViewGroupMvpViewStateDelegateImplTest method initComponents.
@Before
public void initComponents() {
view = new MvpView() {
};
viewState = Mockito.mock(ViewState.class);
presenter = Mockito.mock(MvpPresenter.class);
callback = Mockito.mock(PartialViewGroupMvpViewStateDelegateCallbackImpl.class);
Mockito.doCallRealMethod().when(callback).setPresenter(presenter);
Mockito.doCallRealMethod().when(callback).getPresenter();
Mockito.doCallRealMethod().when(callback).setViewState(viewState);
Mockito.doCallRealMethod().when(callback).getViewState();
activity = Mockito.mock(FragmentActivity.class);
application = Mockito.mock(Application.class);
Mockito.when(callback.getMvpView()).thenReturn(view);
Mockito.when(callback.getContext()).thenReturn(activity);
Mockito.when(activity.getApplication()).thenReturn(application);
Mockito.when(callback.createPresenter()).thenReturn(presenter);
Mockito.when(callback.createViewState()).thenReturn(viewState);
delegate = new ViewGroupMvpViewStateDelegateImpl<>(callback, true);
}
Aggregations