@Test(expected = IllegalStateException.class) public void testToBinding_shouldFail_whenAddingANullBinding() { //GIVEN //WHEN new ScopeImpl("").toProvider(null); //THEN }
private void installModule(boolean isTestModule, Module module) { for (Binding binding : module.getBindingSet()) { if (binding == null) { throw new IllegalStateException("A module can't have a null binding : " + module); } Class clazz = binding.getKey(); String bindingName = binding.getName(); try { if (isTestModule || getBoundProvider(clazz, bindingName) == null) { InternalProviderImpl provider = toProvider(binding); if (binding.isCreatingInstancesInScope()) { installScopedProvider(clazz, bindingName, (ScopedProviderImpl) provider, isTestModule); } else { installBoundProvider(clazz, bindingName, provider, isTestModule); } } } catch (Exception e) { throw new IllegalBindingException(format("Binding %s couldn't be installed", bindingName), e); } } }
private void installModule(boolean isTestModule, Module module) { for (Binding binding : module.getBindingSet()) { if (binding == null) { throw new IllegalStateException("A module can't have a null binding : " + module); } Class clazz = binding.getKey(); String bindingName = binding.getName(); try { if (isTestModule || getBoundProvider(clazz, bindingName) == null) { InternalProviderImpl provider = toProvider(binding); if (binding.isCreatingInstancesInScope()) { installScopedProvider(clazz, bindingName, (ScopedProviderImpl) provider, isTestModule); } else { installBoundProvider(clazz, bindingName, provider, isTestModule); } } } catch (Exception e) { throw new IllegalBindingException(format("Binding %s couldn't be installed", bindingName), e); } } }
private void installModule(Module module) { for (Binding binding : module.getBindingSet()) { if (binding == null) { throw new IllegalStateException("A module can't have a null binding : " + module); } Class clazz = binding.getKey(); String bindingName = binding.getName(); if (!hasTestModules || getBoundProvider(clazz, bindingName) == null) { InternalProviderImpl provider = toProvider(binding); if (binding.isScoped()) { installScopedProvider(clazz, bindingName, (ScopedProviderImpl) provider); } else { installBoundProvider(clazz, bindingName, provider); } } } }