DefaultLdapUserRoleListService implements IUserRoleListService, InitializingBean { @Override public List<String> getAllRoles() { List<GrantedAuthority> results = allAuthoritiesSearch.search( new Object[0] ); Set<String> roles = ( roleComparator != null ) ? new TreeSet<String>( roleComparator ) : new LinkedHashSet<String>( results.size() ); for ( GrantedAuthority role : results ) { String roleString = ( roleMapper != null ) ? roleMapper.toPentahoRole( role.getAuthority() ) : role.getAuthority(); if ( roleString != null && extraRoles != null && !extraRoles.contains( roleString ) ) { roles.add( roleString ); } } for ( String extraRole : extraRoles ) { roles.add( extraRole ); } return new ArrayList<String>( roles ); } DefaultLdapUserRoleListService();  DefaultLdapUserRoleListService( final Comparator<String> usernameComparator,
      final Comparator<String> roleComparator );  DefaultLdapUserRoleListService( final Comparator<String> usernameComparator,
      final Comparator<String> roleComparator, final IAuthenticationRoleMapper roleMapper ); @Override void afterPropertiesSet(); @Override List<String> getAllRoles(); @Override List<String> getAllUsers(); @Override List<String> getUsersInRole( final ITenant tenant, final String role ); @Override List<String> getRolesForUser( final ITenant tenant, final String username ); void setAllUsernamesSearch( final LdapSearch allUsernamesSearch ); void setAllAuthoritiesSearch( final LdapSearch allAuthoritiesSearch ); void setUsernamesInRoleSearch( final LdapSearch usernamesInRoleSearch ); void setUserDetailsService( final UserDetailsService userDetailsService ); void setRoleComparator( final Comparator<String> roleComparator ); void setUsernameComparator( final Comparator<String> usernameComparator ); ITenantedPrincipleNameResolver getUserNameUtils(); void setUserNameUtils( ITenantedPrincipleNameResolver userNameUtils ); ITenantedPrincipleNameResolver getRoleNameUtils(); void setRoleNameUtils( ITenantedPrincipleNameResolver roleNameUtils ); @Override List<String> getAllRoles( ITenant tenant ); @Override List<String> getAllUsers( ITenant tenant ); @Override List<String> getSystemRoles(); void setSystemRoles( List<String> systemRoles ); void setExtraRoles( List<String> extraRoles ); List<String> getExtraRoles();  }
@Test( expected = UnsupportedOperationException.class ) public void testGetAllRoles_nonDefaultTenant() throws Exception { service.getAllRoles( tenant ); }
@Test public void testGetAllRoles_defaultTenant() throws Exception { DefaultLdapUserRoleListService spyService = spy( service ); doReturn( extraRoles ).when( spyService ).getAllRoles(); spyService.getAllRoles( JcrTenantUtils.getDefaultTenant() ); verify( spyService ).getAllRoles(); }