LdapSearcher { public SearchResult getSingleSearchResult() { return searchResults.isEmpty() ? null : searchResults.get(0); } LdapSearcher(Properties config); LdapSearcher search(String context, String filterExpr, Object... filterArgs); SearchResult getSingleSearchResult(); List<SearchResult> getSearchResults(); String getSingleAttributeResult(String attributeId); List<String> getAttributeResults(String attributeId); static final String SEARCH_SCOPE; }
@Test public void testGetSingleSearchResult() throws NamingException { LdapSearcher ldapSearcher = new LdapSearcher(config); SearchResult searchResult = ldapSearcher.search(CONTEXT, "(uid=john)").getSingleSearchResult(); assertThat(searchResult).isNotNull(); assertThat(searchResult.getAttributes().get("uid").get()).isEqualTo("john"); }