PresenterManager { @Nullable public static <P> P getPresenter(@NonNull Activity activity, @NonNull String viewId) { if (activity == null) { throw new NullPointerException("Activity is null"); } if (viewId == null) { throw new NullPointerException("View id is null"); } ActivityScopedCache scopedCache = getActivityScope(activity); return scopedCache == null ? null : (P) scopedCache.getPresenter(viewId); } private  PresenterManager(); @Nullable static P getPresenter(@NonNull Activity activity, @NonNull String viewId); @Nullable static VS getViewState(@NonNull Activity activity, @NonNull String viewId); @NonNull static Activity getActivity(@NonNull Context context); static void putPresenter(@NonNull Activity activity, @NonNull String viewId,
      @NonNull MvpPresenter<? extends MvpView> presenter); static void putViewState(@NonNull Activity activity, @NonNull String viewId,
      @NonNull Object viewState); static void remove(@NonNull Activity activity, @NonNull String viewId); static boolean DEBUG; static final String DEBUG_TAG; }
@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")); }
@Test public void getPresenterThrowsNullPointerException() { try { PresenterManager.getPresenter(null, "123"); Assert.fail("Exception expected"); } catch (NullPointerException e) { } try { Activity activity = Mockito.mock(Activity.class); Application application = Mockito.mock(Application.class); Mockito.when(activity.getApplication()).thenReturn(application); PresenterManager.getPresenter(activity, null); Assert.fail("Exception expected"); } catch (NullPointerException e) { } }