@Test public void test() { PersonLookupViaMembership sut = new PersonLookupViaMembership(groupMapper, subGroupMapper, directGroupMemberMapper, baseLdapPath); final List<LdapGroup> topLevelGroups = new ArrayList<LdapGroup>(Arrays.asList(group)); final List<LdapGroup> subGroups = new ArrayList<LdapGroup>(); final List<Person> directMembers = new ArrayList<Person>(Arrays.asList(person)); context.checking(new Expectations() { { allowing(groupMapper).execute(with(any(LdapLookupRequest.class))); will(returnValue(topLevelGroups)); allowing(subGroupMapper).execute(with(any(LdapLookupRequest.class))); will(returnValue(subGroups)); allowing(group).getDistinguishedName(); will(returnValue(dn)); allowing(group).setSourceList(with(any(ArrayList.class))); allowing(group).getSourceList(); allowing(person).setSourceList(with(any(ArrayList.class))); allowing(directGroupMemberMapper).execute(with(any(LdapLookupRequest.class))); will(returnValue(directMembers)); allowing(person).getAccountId(); will(returnValue("acctId")); } }); sut.findPeople("foo", 5); context.assertIsSatisfied(); }
@Override public List<Person> findPeople(final String inSearchString, final int inResultsUpperBound) { Collection<LdapGroup> allGroups = getGroups(inSearchString); HashMap<String, Person> personBucket = new HashMap<String, Person>(); for (LdapGroup lg : allGroups) { String groupDn = lg.getDistinguishedName().toCompactString(); if (log.isInfoEnabled()) { log.info("Retrieving people for group full DN: " + groupDn); } List<Person> people = directGroupMemberMapper.execute(new LdapLookupRequest( groupDn)); for (Person p : people) { p.setSourceList(lg.getSourceList()); personBucket.put(p.getAccountId(), p); } } if (log.isInfoEnabled()) { log.info("Found " + personBucket.size() + " unique people from searching " + allGroups.size() + " groups."); } return new ArrayList<Person>(personBucket.values()); }
PersonLookupViaMembership implements PersonLookupStrategy { @Override public List<Person> findPeople(final String inSearchString, final int inResultsUpperBound) { Collection<LdapGroup> allGroups = getGroups(inSearchString); HashMap<String, Person> personBucket = new HashMap<String, Person>(); for (LdapGroup lg : allGroups) { String groupDn = lg.getDistinguishedName().toCompactString(); if (log.isInfoEnabled()) { log.info("Retrieving people for group full DN: " + groupDn); } List<Person> people = directGroupMemberMapper.execute(new LdapLookupRequest( groupDn)); for (Person p : people) { p.setSourceList(lg.getSourceList()); personBucket.put(p.getAccountId(), p); } } if (log.isInfoEnabled()) { log.info("Found " + personBucket.size() + " unique people from searching " + allGroups.size() + " groups."); } return new ArrayList<Person>(personBucket.values()); } }
PersonLookupViaMembership implements PersonLookupStrategy { @Override public List<Person> findPeople(final String inSearchString, final int inResultsUpperBound) { Collection<LdapGroup> allGroups = getGroups(inSearchString); HashMap<String, Person> personBucket = new HashMap<String, Person>(); for (LdapGroup lg : allGroups) { String groupDn = lg.getDistinguishedName().toCompactString(); if (log.isInfoEnabled()) { log.info("Retrieving people for group full DN: " + groupDn); } List<Person> people = directGroupMemberMapper.execute(new LdapLookupRequest( groupDn)); for (Person p : people) { p.setSourceList(lg.getSourceList()); personBucket.put(p.getAccountId(), p); } } if (log.isInfoEnabled()) { log.info("Found " + personBucket.size() + " unique people from searching " + allGroups.size() + " groups."); } return new ArrayList<Person>(personBucket.values()); } PersonLookupViaMembership(final LdapLookup<LdapGroup> inGroupMapper,
            final LdapLookup<LdapGroup> inSubGroupMapper, final LdapLookup<Person> inDirectGroupMemberMapper,
            final String inBaseLdapPath); }
PersonLookupViaMembership implements PersonLookupStrategy { @Override public List<Person> findPeople(final String inSearchString, final int inResultsUpperBound) { Collection<LdapGroup> allGroups = getGroups(inSearchString); HashMap<String, Person> personBucket = new HashMap<String, Person>(); for (LdapGroup lg : allGroups) { String groupDn = lg.getDistinguishedName().toCompactString(); if (log.isInfoEnabled()) { log.info("Retrieving people for group full DN: " + groupDn); } List<Person> people = directGroupMemberMapper.execute(new LdapLookupRequest( groupDn)); for (Person p : people) { p.setSourceList(lg.getSourceList()); personBucket.put(p.getAccountId(), p); } } if (log.isInfoEnabled()) { log.info("Found " + personBucket.size() + " unique people from searching " + allGroups.size() + " groups."); } return new ArrayList<Person>(personBucket.values()); } PersonLookupViaMembership(final LdapLookup<LdapGroup> inGroupMapper,
            final LdapLookup<LdapGroup> inSubGroupMapper, final LdapLookup<Person> inDirectGroupMemberMapper,
            final String inBaseLdapPath); @Override List<Person> findPeople(final String inSearchString, final int inResultsUpperBound); }
PersonLookupViaMembership implements PersonLookupStrategy { @Override public List<Person> findPeople(final String inSearchString, final int inResultsUpperBound) { Collection<LdapGroup> allGroups = getGroups(inSearchString); HashMap<String, Person> personBucket = new HashMap<String, Person>(); for (LdapGroup lg : allGroups) { String groupDn = lg.getDistinguishedName().toCompactString(); if (log.isInfoEnabled()) { log.info("Retrieving people for group full DN: " + groupDn); } List<Person> people = directGroupMemberMapper.execute(new LdapLookupRequest( groupDn)); for (Person p : people) { p.setSourceList(lg.getSourceList()); personBucket.put(p.getAccountId(), p); } } if (log.isInfoEnabled()) { log.info("Found " + personBucket.size() + " unique people from searching " + allGroups.size() + " groups."); } return new ArrayList<Person>(personBucket.values()); } PersonLookupViaMembership(final LdapLookup<LdapGroup> inGroupMapper,
            final LdapLookup<LdapGroup> inSubGroupMapper, final LdapLookup<Person> inDirectGroupMemberMapper,
            final String inBaseLdapPath); @Override List<Person> findPeople(final String inSearchString, final int inResultsUpperBound);  }