@Test public void managed_binds_work() { final Managed managed = mock(Managed.class); final Class<TestManaged> managedClass = TestManaged.class; Injector injector = Guice.createInjector(new AbstractPlugin() { @Override protected void configure() { bindManaged(managed); bindManaged(managedClass); } }); Set<Managed> managedSet = injector.getInstance(Keys.ManagedObjects); Set<Class<? extends Managed>> managedClassSet = injector.getInstance(Keys.ManagedObjectClasses); assertThat(managedSet, hasSize(1)); assertThat(managedSet, hasItem(managed)); assertThat(managedClassSet, hasSize(1)); assertThat(managedClassSet, hasItem(TestManaged.class)); }
protected void bindManaged(Managed managed) { Preconditions.checkNotNull(managed, "Managed Object cannot be null."); buildBinders(); managedBinder.addBinding().toInstance(managed); }
AbstractPlugin extends AbstractModule implements Plugin { protected void bindManaged(Managed managed) { Preconditions.checkNotNull(managed, "Managed Object cannot be null."); buildBinders(); managedBinder.addBinding().toInstance(managed); } }
AbstractPlugin extends AbstractModule implements Plugin { protected void bindManaged(Managed managed) { Preconditions.checkNotNull(managed, "Managed Object cannot be null."); buildBinders(); managedBinder.addBinding().toInstance(managed); }  }
AbstractPlugin extends AbstractModule implements Plugin { protected void bindManaged(Managed managed) { Preconditions.checkNotNull(managed, "Managed Object cannot be null."); buildBinders(); managedBinder.addBinding().toInstance(managed); }   }
AbstractPlugin extends AbstractModule implements Plugin { protected void bindManaged(Managed managed) { Preconditions.checkNotNull(managed, "Managed Object cannot be null."); buildBinders(); managedBinder.addBinding().toInstance(managed); }    }