ScopeNode implements Scope { @Override public Scope supportScopeAnnotation(Class<? extends Annotation> scopeAnnotationClass) { checkIsAnnotationScope(scopeAnnotationClass); if (scopeAnnotationClass == Singleton.class) { throw new IllegalArgumentException( format( "The annotation @Singleton is already supported " + "by root scopes. It can't be supported programmatically.")); } scopeAnnotationClasses.add(scopeAnnotationClass); return this; } ScopeNode(Object name); @Override Object getName(); @Override boolean equals(Object o); @Override int hashCode(); @Override ScopeNode getParentScope(); @SuppressWarnings({"unused", "used by generated code"}) @Override ScopeNode getParentScope(Class<A> scopeAnnotationClass); @SuppressWarnings({"unused", "used by generated code"}) @Override ScopeNode getRootScope(); @Override Scope supportScopeAnnotation(Class<? extends Annotation> scopeAnnotationClass); @Override boolean isScopeAnnotationSupported(Class<? extends Annotation> scopeAnnotationClass);  }
@Test(expected = IllegalArgumentException.class) public void testBindScopeAnnotation_shouldFail_whenSingleton() { Scope scope = Toothpick.openScope("root"); scope.supportScopeAnnotation(Singleton.class); fail("Should throw an exception"); }
@Test(expected = IllegalArgumentException.class) public void testBindScopeAnnotation_shouldFail_whenAnnotationIsNotAScope() { Scope scope = Toothpick.openScope("root"); scope.supportScopeAnnotation(NotAScope.class); fail("Should throw an exception"); }