@Test public void test() { final ArrayList<Object> rawResults = new ArrayList<Object>(Arrays.asList(new Object(), null, new Object())); context.checking(new Expectations() { { allowing(ldapLookupRequest).getSearchUpperBound(); will(returnValue(Integer.MAX_VALUE)); allowing(ldapLookupRequest).getQueryString(); will(returnValue(queryString)); allowing(ldapTemplateRetriever).getLdapTemplate(ldapLookupRequest); will(returnValue(template)); allowing(filterCreator).getFilter(queryString); will(returnValue(filter)); allowing(handlerFactory).getCallbackHandler(); will(returnValue(handler)); allowing(filter).encode(); will(returnValue("filter")); allowing(ldapSearchStrategy).searchLdap(with(any(LdapTemplate.class)), with(any(String.class)), with(any(SearchControls.class)), with(any(CollectingNameClassPairCallbackHandler.class))); allowing(handler).getList(); will(returnValue(rawResults)); } }); assertEquals(3, rawResults.size()); List<Object> results = sut.execute(ldapLookupRequest); assertEquals(2, results.size()); context.assertIsSatisfied(); }
@Override public List<Type> execute(final LdapLookupRequest inRequest) { LdapTemplate template = ldapTemplateRetriever.getLdapTemplate(inRequest); SearchControls searchControls = new SearchControls(); searchControls.setCountLimit(inRequest.getSearchUpperBound()); searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE); AbstractFilter abstractFilter = filterCreator.getFilter(inRequest.getQueryString()); CollectingNameClassPairCallbackHandler collectingHandler = handlerFactory.getCallbackHandler(); ldapSearchStrategy.searchLdap(template, abstractFilter.encode(), searchControls, collectingHandler); List<Type> rawResults = collectingHandler.getList(); List<Type> results = new ArrayList<Type>(); for (Type t : rawResults) { if (t != null) { results.add(t); } } return results; }
LdapLookup implements DomainMapper<LdapLookupRequest, List<Type>> { @Override public List<Type> execute(final LdapLookupRequest inRequest) { LdapTemplate template = ldapTemplateRetriever.getLdapTemplate(inRequest); SearchControls searchControls = new SearchControls(); searchControls.setCountLimit(inRequest.getSearchUpperBound()); searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE); AbstractFilter abstractFilter = filterCreator.getFilter(inRequest.getQueryString()); CollectingNameClassPairCallbackHandler collectingHandler = handlerFactory.getCallbackHandler(); ldapSearchStrategy.searchLdap(template, abstractFilter.encode(), searchControls, collectingHandler); List<Type> rawResults = collectingHandler.getList(); List<Type> results = new ArrayList<Type>(); for (Type t : rawResults) { if (t != null) { results.add(t); } } return results; } }
LdapLookup implements DomainMapper<LdapLookupRequest, List<Type>> { @Override public List<Type> execute(final LdapLookupRequest inRequest) { LdapTemplate template = ldapTemplateRetriever.getLdapTemplate(inRequest); SearchControls searchControls = new SearchControls(); searchControls.setCountLimit(inRequest.getSearchUpperBound()); searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE); AbstractFilter abstractFilter = filterCreator.getFilter(inRequest.getQueryString()); CollectingNameClassPairCallbackHandler collectingHandler = handlerFactory.getCallbackHandler(); ldapSearchStrategy.searchLdap(template, abstractFilter.encode(), searchControls, collectingHandler); List<Type> rawResults = collectingHandler.getList(); List<Type> results = new ArrayList<Type>(); for (Type t : rawResults) { if (t != null) { results.add(t); } } return results; } LdapLookup(final LdapTemplateRetriever inLdapTemplateRetriever, final FilterCreator inFilterCreator,
            final CallbackHandlerFactory inHandlerFactory, final LdapSearchStrategy inLdapSearchStrategy); }
LdapLookup implements DomainMapper<LdapLookupRequest, List<Type>> { @Override public List<Type> execute(final LdapLookupRequest inRequest) { LdapTemplate template = ldapTemplateRetriever.getLdapTemplate(inRequest); SearchControls searchControls = new SearchControls(); searchControls.setCountLimit(inRequest.getSearchUpperBound()); searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE); AbstractFilter abstractFilter = filterCreator.getFilter(inRequest.getQueryString()); CollectingNameClassPairCallbackHandler collectingHandler = handlerFactory.getCallbackHandler(); ldapSearchStrategy.searchLdap(template, abstractFilter.encode(), searchControls, collectingHandler); List<Type> rawResults = collectingHandler.getList(); List<Type> results = new ArrayList<Type>(); for (Type t : rawResults) { if (t != null) { results.add(t); } } return results; } LdapLookup(final LdapTemplateRetriever inLdapTemplateRetriever, final FilterCreator inFilterCreator,
            final CallbackHandlerFactory inHandlerFactory, final LdapSearchStrategy inLdapSearchStrategy); @Override List<Type> execute(final LdapLookupRequest inRequest); }
LdapLookup implements DomainMapper<LdapLookupRequest, List<Type>> { @Override public List<Type> execute(final LdapLookupRequest inRequest) { LdapTemplate template = ldapTemplateRetriever.getLdapTemplate(inRequest); SearchControls searchControls = new SearchControls(); searchControls.setCountLimit(inRequest.getSearchUpperBound()); searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE); AbstractFilter abstractFilter = filterCreator.getFilter(inRequest.getQueryString()); CollectingNameClassPairCallbackHandler collectingHandler = handlerFactory.getCallbackHandler(); ldapSearchStrategy.searchLdap(template, abstractFilter.encode(), searchControls, collectingHandler); List<Type> rawResults = collectingHandler.getList(); List<Type> results = new ArrayList<Type>(); for (Type t : rawResults) { if (t != null) { results.add(t); } } return results; } LdapLookup(final LdapTemplateRetriever inLdapTemplateRetriever, final FilterCreator inFilterCreator,
            final CallbackHandlerFactory inHandlerFactory, final LdapSearchStrategy inLdapSearchStrategy); @Override List<Type> execute(final LdapLookupRequest inRequest);  }