ScopeNode implements Scope { @Override public boolean isScopeAnnotationSupported(Class<? extends Annotation> scopeAnnotationClass) { if (scopeAnnotationClass == Singleton.class) { return parentScopes.isEmpty(); } return scopeAnnotationClasses.contains(scopeAnnotationClass); } 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 public void testCreateScope_shouldBindToScopeAnnotation_whenNameIsAScopeAnnotation() { Scope scope = new ScopeImpl(CustomScope.class); boolean isSupportingToScopeAnnotation = scope.isScopeAnnotationSupported(CustomScope.class); assertThat(isSupportingToScopeAnnotation, is(true)); }
@Test public void testCreateScope_shouldNotBindToScopeAnnotation_whenNameIsNotAScopeAnnotation() { Scope scope = new ScopeImpl(NotAScope.class); boolean isSupportingToScopeAnnotation = scope.isScopeAnnotationSupported(CustomScope.class); assertThat(isSupportingToScopeAnnotation, is(false)); }
@Test public void testSupportScopeAnnotation_shouldReturnFalse_whenNotSupported() { Scope scope = Toothpick.openScope("root"); boolean isSupportingToScopeAnnotation = scope.isScopeAnnotationSupported(CustomScope.class); assertThat(isSupportingToScopeAnnotation, is(false)); }
@Test public void testSupportScopeAnnotation_shouldReturnTrue_whenRootScopeAskedForSingleton() { Scope parentScope = Toothpick.openScope("root"); boolean isSupportingSingleton = parentScope.isScopeAnnotationSupported(Singleton.class); assertThat(isSupportingSingleton, is(true)); }
@Test public void testSupportScopeAnnotation_shouldReturnFalse_whenNonRootScopeAskedForSingleton() { Scope childScope = Toothpick.openScopes("root", "child"); boolean isSupportingSingleton = childScope.isScopeAnnotationSupported(Singleton.class); assertThat(isSupportingSingleton, is(false)); }