### Question:
ActivityLifebus extends BaseLifebus<Activity, ActivityEvent> { @NonNull public static Lifebus<ActivityEvent> create(@NonNull Activity activity) { final Application application = activity.getApplication(); if (application == null) { throw new IllegalStateException("Provided activity '" + activity.getClass().getName() + "' " + "has no Application information. Consider moving this call to after Activity#onCreate " + "or use #create(Application, Activity) factory method"); } return new Impl(application, activity); } ActivityLifebus(@NonNull Activity owner, @NonNull Class<ActivityEvent> event, @NonNull ActivityEvent disposeEvent); @NonNull static Lifebus<ActivityEvent> create(@NonNull Activity activity); @NonNull static Lifebus<ActivityEvent> create(@NonNull Application application, @NonNull Activity activity);  }### Answer:
@Test public void create_activity_no_application() { final Activity activity = mock(Activity.class); when(activity.getApplication()).thenReturn(null); try { ActivityLifebus.create(activity); fail(); } catch (IllegalStateException e) { assertTrue(e.getMessage(), e.getMessage().startsWith("Provided activity ")); } }
@Test public void create_with_application_registers_activity_lifecycle_callbacks() { final Activity activity = mock(Activity.class); final Application application = mock(Application.class); ActivityLifebus.create(application, activity); verify(application, times(1)) .registerActivityLifecycleCallbacks(any(Application.ActivityLifecycleCallbacks.class)); }