use of android.app.Application in project mosby by sockeqwe.
the class PresenterManagerTest method returnsSameScopedCacheAndRegisterLifecycleListener.
@Test
public void returnsSameScopedCacheAndRegisterLifecycleListener() {
Activity activity = Mockito.mock(Activity.class);
Application application = Mockito.mock(Application.class);
Mockito.when(activity.getApplication()).thenReturn(application);
ActivityScopedCache scopedCache1 = PresenterManager.getOrCreateActivityScopedCache(activity);
ActivityScopedCache scopedCache2 = PresenterManager.getOrCreateActivityScopedCache(activity);
Assert.assertTrue(scopedCache1 == scopedCache2);
Mockito.verify(application, Mockito.times(1)).registerActivityLifecycleCallbacks(PresenterManager.activityLifecycleCallbacks);
}
use of android.app.Application in project mosby by sockeqwe.
the class PresenterManagerTest method putGetRemoveViewState.
@Test
public void putGetRemoveViewState() {
Activity activity = Mockito.mock(Activity.class);
Application application = Mockito.mock(Application.class);
Mockito.when(activity.getApplication()).thenReturn(application);
Object viewState = new Object();
String viewId = "123";
Assert.assertNull(PresenterManager.getViewState(activity, viewId));
PresenterManager.putViewState(activity, viewId, viewState);
Assert.assertTrue(viewState == PresenterManager.getViewState(activity, viewId));
PresenterManager.remove(activity, viewId);
Assert.assertNull(PresenterManager.getPresenter(activity, viewId));
}
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));
}
Aggregations