BundleService { public void register(Bundler bundler) { if (bundler == null) throw new NullPointerException("Cannot register null bundler."); if (runner.state == BundleServiceRunner.State.SAVING) { throw new IllegalStateException("Cannot register during onSave"); } if (bundlers.add(bundler)) bundler.onEnterScope(scope); String mortarBundleKey = bundler.getMortarBundleKey(); if (mortarBundleKey == null || mortarBundleKey.trim().equals("")) { throw new IllegalArgumentException(format("%s has null or empty bundle key", bundler)); } switch (runner.state) { case IDLE: toBeLoaded.add(bundler); runner.servicesToBeLoaded.add(this); runner.finishLoading(); break; case LOADING: if (!toBeLoaded.contains(bundler)) { toBeLoaded.add(bundler); runner.servicesToBeLoaded.add(this); } break; default: throw new AssertionError("Unexpected state " + runner.state); } } BundleService(BundleServiceRunner runner, MortarScope scope); static BundleService getBundleService(Context context); static BundleService getBundleService(MortarScope scope); void register(Bundler bundler);  }
@Test public void onRegisteredIsDebounced() { activityScope.register(scoped); activityScope.register(scoped); verify(scoped, times(1)).onEnterScope(activityScope); }