@Test public void testToApacheSearchRequest() throws LdapException { QueryRequest search = mock(QueryRequest.class); Endpoint endpoint = mock(Endpoint.class); when(search.getTimeLimit()).thenReturn(1000); when(search.getSizeLimit()).thenReturn(1000); when(search.getSearchText()).thenReturn("(l=LTV)"); when(search.getReferralsHandling()).thenReturn(ReferralsHandling.FOLLOW); when(search.getRequestedFields()).thenReturn(null); SearchRequest searchRequest = new ApacheAPIConverter().toSearchRequest(search, endpoint.getBaseSearchPath()); assertTrue(searchRequest.getSizeLimit() == search.getSizeLimit()); assertTrue(searchRequest.getTimeLimit() == search.getTimeLimit()); assertTrue(searchRequest.getFilter().toString().equals(search.getSearchText())); assertTrue(searchRequest.isFollowReferrals()); }
SearchRequest toSearchRequest(QueryRequest queryRequest, String baseSearchPath) throws LdapException { SearchRequest search = new SearchRequestImpl(); search.setScope(SearchScope.SUBTREE); String[] translatedRequestedFieldsArray = toStringArray(queryRequest.getRequestedFields()); search.addAttributes(translatedRequestedFieldsArray); search.setTimeLimit(queryRequest.getTimeLimit()); search.setSizeLimit(queryRequest.getSizeLimit()); search.setBase(new Dn(baseSearchPath)); if (queryRequest.getReferralsHandling() == ReferralsHandling.FOLLOW) { search.followReferrals(); } else if (queryRequest.getReferralsHandling() == ReferralsHandling.IGNORE) { search.ignoreReferrals(); } String searchText = queryRequest.getSearchText() == null ? queryRequest.getSearchSentenceText() : queryRequest.getSearchText(); if (searchText != null && !searchText.trim().isEmpty()) search.setFilter(searchText); List<SortKey> sortKeys = queryRequest.getSortKeys(); if (!Objects.isNull(sortKeys) && !sortKeys.isEmpty()) { SortRequestControlImpl sortRequest = applySort(sortKeys); search.addControl(sortRequest); } return search; }
ApacheAPIConverter { SearchRequest toSearchRequest(QueryRequest queryRequest, String baseSearchPath) throws LdapException { SearchRequest search = new SearchRequestImpl(); search.setScope(SearchScope.SUBTREE); String[] translatedRequestedFieldsArray = toStringArray(queryRequest.getRequestedFields()); search.addAttributes(translatedRequestedFieldsArray); search.setTimeLimit(queryRequest.getTimeLimit()); search.setSizeLimit(queryRequest.getSizeLimit()); search.setBase(new Dn(baseSearchPath)); if (queryRequest.getReferralsHandling() == ReferralsHandling.FOLLOW) { search.followReferrals(); } else if (queryRequest.getReferralsHandling() == ReferralsHandling.IGNORE) { search.ignoreReferrals(); } String searchText = queryRequest.getSearchText() == null ? queryRequest.getSearchSentenceText() : queryRequest.getSearchText(); if (searchText != null && !searchText.trim().isEmpty()) search.setFilter(searchText); List<SortKey> sortKeys = queryRequest.getSortKeys(); if (!Objects.isNull(sortKeys) && !sortKeys.isEmpty()) { SortRequestControlImpl sortRequest = applySort(sortKeys); search.addControl(sortRequest); } return search; } }
ApacheAPIConverter { SearchRequest toSearchRequest(QueryRequest queryRequest, String baseSearchPath) throws LdapException { SearchRequest search = new SearchRequestImpl(); search.setScope(SearchScope.SUBTREE); String[] translatedRequestedFieldsArray = toStringArray(queryRequest.getRequestedFields()); search.addAttributes(translatedRequestedFieldsArray); search.setTimeLimit(queryRequest.getTimeLimit()); search.setSizeLimit(queryRequest.getSizeLimit()); search.setBase(new Dn(baseSearchPath)); if (queryRequest.getReferralsHandling() == ReferralsHandling.FOLLOW) { search.followReferrals(); } else if (queryRequest.getReferralsHandling() == ReferralsHandling.IGNORE) { search.ignoreReferrals(); } String searchText = queryRequest.getSearchText() == null ? queryRequest.getSearchSentenceText() : queryRequest.getSearchText(); if (searchText != null && !searchText.trim().isEmpty()) search.setFilter(searchText); List<SortKey> sortKeys = queryRequest.getSortKeys(); if (!Objects.isNull(sortKeys) && !sortKeys.isEmpty()) { SortRequestControlImpl sortRequest = applySort(sortKeys); search.addControl(sortRequest); } return search; }  }
ApacheAPIConverter { SearchRequest toSearchRequest(QueryRequest queryRequest, String baseSearchPath) throws LdapException { SearchRequest search = new SearchRequestImpl(); search.setScope(SearchScope.SUBTREE); String[] translatedRequestedFieldsArray = toStringArray(queryRequest.getRequestedFields()); search.addAttributes(translatedRequestedFieldsArray); search.setTimeLimit(queryRequest.getTimeLimit()); search.setSizeLimit(queryRequest.getSizeLimit()); search.setBase(new Dn(baseSearchPath)); if (queryRequest.getReferralsHandling() == ReferralsHandling.FOLLOW) { search.followReferrals(); } else if (queryRequest.getReferralsHandling() == ReferralsHandling.IGNORE) { search.ignoreReferrals(); } String searchText = queryRequest.getSearchText() == null ? queryRequest.getSearchSentenceText() : queryRequest.getSearchText(); if (searchText != null && !searchText.trim().isEmpty()) search.setFilter(searchText); List<SortKey> sortKeys = queryRequest.getSortKeys(); if (!Objects.isNull(sortKeys) && !sortKeys.isEmpty()) { SortRequestControlImpl sortRequest = applySort(sortKeys); search.addControl(sortRequest); } return search; }  Modification toModification(ModificationDetails modificationDetails); }
ApacheAPIConverter { SearchRequest toSearchRequest(QueryRequest queryRequest, String baseSearchPath) throws LdapException { SearchRequest search = new SearchRequestImpl(); search.setScope(SearchScope.SUBTREE); String[] translatedRequestedFieldsArray = toStringArray(queryRequest.getRequestedFields()); search.addAttributes(translatedRequestedFieldsArray); search.setTimeLimit(queryRequest.getTimeLimit()); search.setSizeLimit(queryRequest.getSizeLimit()); search.setBase(new Dn(baseSearchPath)); if (queryRequest.getReferralsHandling() == ReferralsHandling.FOLLOW) { search.followReferrals(); } else if (queryRequest.getReferralsHandling() == ReferralsHandling.IGNORE) { search.ignoreReferrals(); } String searchText = queryRequest.getSearchText() == null ? queryRequest.getSearchSentenceText() : queryRequest.getSearchText(); if (searchText != null && !searchText.trim().isEmpty()) search.setFilter(searchText); List<SortKey> sortKeys = queryRequest.getSortKeys(); if (!Objects.isNull(sortKeys) && !sortKeys.isEmpty()) { SortRequestControlImpl sortRequest = applySort(sortKeys); search.addControl(sortRequest); } return search; }  Modification toModification(ModificationDetails modificationDetails);  }