use of android.app.Application in project mosby by sockeqwe.
the class PresenterManagerTest method putNullViewStateThrowNullPointerException.
@Test
public void putNullViewStateThrowNullPointerException() {
Object viewState = new Object();
Activity activity = Mockito.mock(Activity.class);
Application application = Mockito.mock(Application.class);
Mockito.when(activity.getApplication()).thenReturn(application);
try {
PresenterManager.putViewState(null, "123", viewState);
Assert.fail("Exception expected");
} catch (NullPointerException e) {
}
try {
PresenterManager.putViewState(activity, null, viewState);
Assert.fail("Exception expected");
} catch (NullPointerException e) {
}
try {
PresenterManager.putViewState(activity, "123", null);
Assert.fail("Exception expected");
} catch (NullPointerException e) {
}
}
use of android.app.Application in project mosby by sockeqwe.
the class ActivityMvpDelegateImplTest method initComponents.
@Before
public void initComponents() {
view = new MvpView() {
};
presenter = Mockito.mock(MvpPresenter.class);
callback = Mockito.mock(PartialMvpDelegateCallbackImpl.class);
activity = Mockito.mock(Activity.class);
application = Mockito.mock(Application.class);
Mockito.doCallRealMethod().when(callback).setPresenter(presenter);
Mockito.doCallRealMethod().when(callback).getPresenter();
Mockito.when(callback.getMvpView()).thenReturn(view);
Mockito.when(activity.getApplication()).thenReturn(application);
Mockito.when(callback.createPresenter()).thenReturn(presenter);
}
use of android.app.Application in project mosby by sockeqwe.
the class PresenterManagerTest method getPresenterReturnsNull.
@Test
public void getPresenterReturnsNull() {
Activity activity = Mockito.mock(Activity.class);
Application application = Mockito.mock(Application.class);
Mockito.when(activity.getApplication()).thenReturn(application);
Assert.assertNull(PresenterManager.getPresenter(activity, "viewId123"));
}
use of android.app.Application in project mosby by sockeqwe.
the class FragmentMvpViewStateDelegateImplTest method initComponents.
@Before
public void initComponents() {
view = new MvpView() {
};
viewState = Mockito.mock(ViewState.class);
presenter = Mockito.mock(MvpPresenter.class);
callback = Mockito.spy(PartialMvpViewStateDelegateCallbackImpl.class);
Mockito.doCallRealMethod().when(callback).setPresenter(presenter);
Mockito.doCallRealMethod().when(callback).getPresenter();
Mockito.doCallRealMethod().when(callback).setViewState(viewState);
Mockito.doCallRealMethod().when(callback).getViewState();
fragment = PowerMockito.mock(Fragment.class);
activity = Mockito.mock(FragmentActivity.class);
application = Mockito.mock(Application.class);
Mockito.when(callback.getMvpView()).thenReturn(view);
Mockito.when(fragment.getActivity()).thenReturn(activity);
Mockito.when(activity.getApplication()).thenReturn(application);
Mockito.when(callback.createPresenter()).thenReturn(presenter);
Mockito.when(callback.createViewState()).thenReturn(viewState);
delegate = new FragmentMvpViewStateDelegateImpl<>(fragment, callback, true, true);
}
use of android.app.Application in project android by JetBrains.
the class LibUnitTest method mockFinalMethod.
@Test
public void mockFinalMethod() {
Activity activity = mock(Activity.class);
Application app = mock(Application.class);
when(activity.getApplication()).thenReturn(app);
assertSame(app, activity.getApplication());
verify(activity).getApplication();
verifyNoMoreInteractions(activity);
}
Aggregations