@Test public void testConstructor_shouldCreateCause_whenPassedACause() throws Exception { //GIVEN Throwable cause = new Exception("Foo"); //WHEN IllegalBindingException exception = new IllegalBindingException(cause); //THEN assertThat(exception.getMessage(), is("java.lang.Exception: Foo")); assertThat(exception.getCause(), is(cause)); }
@Test public void testConstructor_shouldCreateMessage_whenPassedAMessage() throws Exception { //GIVEN //WHEN IllegalBindingException exception = new IllegalBindingException("Foo"); //THEN assertThat(exception.getMessage(), is("Foo")); }
if (annotationType.isAnnotationPresent(javax.inject.Scope.class)) { if (!scope.isBoundToScopeAnnotation(annotationType)) { throw new IllegalBindingException(format("Class %s cannot be bound." + " It has a scope annotation: %s that is not supported by current scope: %s", clazz.getName(), annotationType.getName(), scope.getName()));
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); } } }
@Test public void testConstructor_shouldCreateEmptyMessage_whenNotPassedAMessage() throws Exception { //GIVEN //WHEN IllegalBindingException exception = new IllegalBindingException(); //THEN assertThat(exception.getMessage(), nullValue()); }
@Test public void testConstructor_shouldCreateMessageAndCause_whenPassedAMessageAndCause() throws Exception { //GIVEN Throwable cause = new Exception(); //WHEN IllegalBindingException exception = new IllegalBindingException("Foo", cause); //THEN assertThat(exception.getMessage(), is("Foo")); assertThat(exception.getCause(), is(cause)); } }
if (annotationType.isAnnotationPresent(javax.inject.Scope.class)) { if (!scope.isBoundToScopeAnnotation(annotationType)) { throw new IllegalBindingException(format("Class %s cannot be bound." + " It has a scope annotation: %s that is not supported by current scope: %s", clazz.getName(), annotationType.getName(), scope.getName()));
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); } } }