### Question:
NotificationActivityLifecycleListener implements Application.ActivityLifecycleCallbacks { @Override public void onActivityStopped(final Activity activity) { try { activity.unregisterReceiver(foregroundNotificationReceiver); } catch (final IllegalArgumentException e) { Log.w(getClass().getSimpleName(), " failed to unregister foreground notification receiver"); } } NotificationActivityLifecycleListener(@NonNull final NotificationPressedInterceptorCounter counter); @Override void onActivityCreated(Activity activity, Bundle savedInstanceState); @Override void onActivityStarted(final Activity activity); @Override void onActivityResumed(Activity activity); @Override void onActivityPaused(Activity activity); @Override void onActivityStopped(final Activity activity); @Override void onActivitySaveInstanceState(Activity activity, Bundle outState); @Override void onActivityDestroyed(Activity activity);  }### Answer:
@Test public void onActivityStopped() throws Exception { final Activity mockActivity = mock(Activity.class); notificationActivityLifecycleListener.onActivityStopped(mockActivity); verify(mockActivity).unregisterReceiver(any(NotificationMessageReceiver.class)); }