@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(); }
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 { 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 { 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); }
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); }
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);  }