### Question:
LdapServiceImpl implements LdapService { @Override public Collection<User> findUsersByGroups(String realm, final Collection<String> allowedGroupNames, final Collection<String> disallowedGroupNames, String tenant, Collection<String> edorgs) { Collection<String> allowed = allowedGroupNames; Collection<String> disallowed = disallowedGroupNames; if (allowed == null) { allowed = new LinkedList<String>(); } if (disallowed == null) { disallowed = new LinkedList<String>(); } Set<String> allowedUsers = new HashSet<String>(); Map<String, List<String>> uidToGroupsMap = new HashMap<String, List<String>>(); for (String groupName : allowed) { Group group = getGroup(realm, groupName); if (group != null) { List<String> memberUids = group.getMemberUids(); if (memberUids != null && memberUids.size() > 0) { for (String memberUid : memberUids) { if (uidToGroupsMap.containsKey(memberUid)) { uidToGroupsMap.get(memberUid).add(groupName); } else { List<String> uidGroupNames = new ArrayList<String>(); uidGroupNames.add(groupName); uidToGroupsMap.put(memberUid, uidGroupNames); } allowedUsers.add(memberUid); } } } } for (String groupName : disallowed) { Group group = getGroup(realm, groupName); if (group != null) { allowedUsers.removeAll(group.getMemberUids()); } } AndFilter filter = new AndFilter(); filter.and(new EqualsFilter(OBJECTCLASS, userObjectClass)); OrFilter orFilter = new OrFilter(); for (String uid : allowedUsers) { orFilter.or(new EqualsFilter(userSearchAttribute, uid)); } filter.and(orFilter); DistinguishedName dn = new DistinguishedName("ou=" + realm); @SuppressWarnings("unchecked") Collection<User> users = (ldapTemplate.search(dn, filter.toString(), SearchControls.SUBTREE_SCOPE, new String[] { "*", CREATE_TIMESTAMP, MODIFY_TIMESTAMP }, new UserContextMapper())); for (User user : users) { user.setGroups(uidToGroupsMap.get(user.getUid())); } if (tenant != null) { users = filterByTenant(users, tenant); } if (edorgs != null) { users = filterByEdorgs(users, edorgs); } return users; }  @SuppressWarnings("rawtypes") @Override User getUser(String realm, String uid); @SuppressWarnings("unchecked") @Override Collection<Group> getUserGroups(String realm, String uid); @Override void removeUser(String realm, String uid); @Override String createUser(String realm, User user); @Override boolean updateUser(String realm, User user); @Override Collection<User> findUsersByGroups(String realm, final Collection<String> allowedGroupNames,
                                              final Collection<String> disallowedGroupNames, String tenant, Collection<String> edorgs); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant); @Override Collection<User> findUsersByAttributes(String realm, Collection<String> attributes); @Override Group getGroup(String realm, String groupName); @Override Collection<User> findUsersByGroups(String realm, Collection<String> groupNames, String tenant,
                                              Collection<String> edorgs); @Override boolean addUserToGroup(String realm, Group group, User user); @Override boolean removeUserFromGroup(String realm, Group group, User user); @Override boolean updateGroup(String realm, Group group); @Override void setLdapTemplate(LdapTemplate ldapTemplate); static final String OBJECTCLASS; }### Answer:
@Test public void testFindUserByGroups() { String[] groups = new String[] { "SEA Administrator" }; Collection<User> users = ldapService.findUsersByGroups("LocalNew", Arrays.asList(groups)); assertNotNull(users); }