ScopeNode implements Scope { @SuppressWarnings({"unused", "used by generated code"}) @Override public ScopeNode getRootScope() { if (parentScopes.isEmpty()) { return this; } return parentScopes.get(parentScopes.size() - 1); } 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 testGetRootScope_shouldReturnNodeItselfI_whenRoot() { Scope parentScope = Toothpick.openScope("root"); Scope scope = parentScope.getRootScope(); assertThat(scope, is(parentScope)); }
@Test public void testGetRootScope_shouldReturnRootScope_whenHasParent() { Scope parentScope = Toothpick.openScope("root"); Scope childScope = Toothpick.openScopes("root", "child"); Scope scope = childScope.getRootScope(); assertThat(scope, is(parentScope)); }