BundleService { public static BundleService getBundleService(Context context) { BundleServiceRunner runner = BundleServiceRunner.getBundleServiceRunner(context); if (runner == null) { throw new IllegalStateException( "You forgot to set up a " + BundleServiceRunner.class.getName() + " in your activity"); } return runner.requireBundleService(MortarScope.getScope(context)); } BundleService(BundleServiceRunner runner, MortarScope scope); static BundleService getBundleService(Context context); static BundleService getBundleService(MortarScope scope); void register(Bundler bundler);  }
@Test public void cannotGetBundleServiceForDestroyed() { MortarScope child = activityScope.buildChild().build("child"); child.destroy(); IllegalStateException caught = null; try { getBundleService(child); } catch (IllegalStateException e) { caught = e; } assertThat(caught).isNotNull(); }
@Test public void cannotGetBundleServiceFromContextOfDestroyed() { MortarScope child = activityScope.buildChild().build("child"); Context context = mockContext(child); child.destroy(); IllegalStateException caught = null; try { getBundleService(context); } catch (IllegalStateException e) { caught = e; } assertThat(caught).isNotNull(); }