DefaultLdapUserRoleListService implements IUserRoleListService, InitializingBean { @Override public List<String> getAllUsers() { List<String> results = allUsernamesSearch.search( new Object[0] ); if ( null != usernameComparator ) { Collections.sort( results, usernameComparator ); } return results; } 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 testGetAllUsers_nonDefaultTenant() throws Exception { service.getAllUsers( tenant ); }
@Test public void testGetAllUsers_defaultTenant() throws Exception { DefaultLdapUserRoleListService spyService = spy( service ); doReturn( null ).when( spyService ).getAllUsers(); spyService.getAllUsers( JcrTenantUtils.getDefaultTenant() ); verify( spyService ).getAllUsers(); }
@Test public void testGetAllUsers() throws Exception { List<String> foundUsers = Arrays.asList( new String[] { "admin", "suzy" } ); when( usernameSearch.search( any( filterArgs.getClass() ) ) ).thenReturn( foundUsers ); service.setAllUsernamesSearch( usernameSearch ); service.setUsernameComparator( usernameComparator ); List<String> users = service.getAllUsers(); assertNotNull( users ); assertEquals( foundUsers.size(), users.size() ); for ( String user : foundUsers ) { assertTrue( users.contains( user ) ); } verify( usernameComparator ).compare( "suzy", "admin" ); }