LdapSearcher { public String getSingleAttributeResult(String attributeId) { List<String> attributeResults = getAttributeResults(attributeId); return attributeResults.isEmpty() ? null : attributeResults.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 testGetSingleAttributeResult() { LdapSearcher ldapSearcher = new LdapSearcher(config); String attributeResult = ldapSearcher.search(CONTEXT, "(uid=john)").getSingleAttributeResult("uid"); assertThat(attributeResult).isNotNull().isEqualTo("john"); }