DisjunctAuthScopeExpression extends AbstractAuthScopeExpression { @Override public String[] getAllScopes() { Set<String> allScopes = Sets.newLinkedHashSet(); for (AuthScopeExpression innerExpression : innerExpressions) { allScopes.addAll(Arrays.asList(innerExpression.getAllScopes())); } return allScopes.toArray(new String[allScopes.size()]); } DisjunctAuthScopeExpression(List<AbstractAuthScopeExpression> innerExpressions); @Override String[] getAllScopes(); @Override boolean isAuthorized(Set<String> userScopes); @Override String toLoggingForm(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void testGetAllScopes() { AbstractAuthScopeExpression expression1 = mock(AbstractAuthScopeExpression.class); when(expression1.getAllScopes()).thenReturn(new String[] { "scope0" }); AbstractAuthScopeExpression expression2 = mock(AbstractAuthScopeExpression.class); when(expression2.getAllScopes()).thenReturn(new String[] { "scope1" }); AbstractAuthScopeExpression expression3 = mock(AbstractAuthScopeExpression.class); when(expression3.getAllScopes()).thenReturn(new String[] { "scope0", "scope2" }); DisjunctAuthScopeExpression expression = new DisjunctAuthScopeExpression( ImmutableList.<AbstractAuthScopeExpression>of(expression1, expression2, expression3)); assertThat(ImmutableList.copyOf(expression.getAllScopes())) .containsExactly("scope0", "scope1", "scope2"); }