use of org.forgerock.openam.utils.CrestQuery in project OpenAM by OpenRock.
the class IdentityServicesImpl method fetchAMIdentity.
private AMIdentity fetchAMIdentity(AMIdentityRepository repo, IdType type, String identity, boolean fetchAllAttrs) throws IdRepoException, ObjectNotFound, SSOException {
AMIdentity rv = null;
List<AMIdentity> identities = fetchAMIdentities(type, new CrestQuery(identity), fetchAllAttrs, repo, null);
if (identities != null && !identities.isEmpty()) {
rv = identities.get(0);
}
return rv;
}
use of org.forgerock.openam.utils.CrestQuery in project OpenAM by OpenRock.
the class GenericRepoTest method searchReturnsEarlyIfMaxResultsReached.
@Test(enabled = false)
public void searchReturnsEarlyIfMaxResultsReached() throws Exception {
CrestQuery crestQuery = new CrestQuery("*");
RepoSearchResults results = idrepo.search(null, IdType.USER, crestQuery, 0, 2, null, true, IdRepo.AND_MOD, null, true);
assertThat(results.getErrorCode()).isEqualTo(RepoSearchResults.SIZE_LIMIT_EXCEEDED);
assertThat(results.getSearchResults()).hasSize(2);
}
use of org.forgerock.openam.utils.CrestQuery in project OpenAM by OpenRock.
the class GenericRepoTest method searchReturnsRequestedAttributes.
@Test
public void searchReturnsRequestedAttributes() throws Exception {
CrestQuery crestQuery = new CrestQuery("searchTester1");
RepoSearchResults results = idrepo.search(null, IdType.USER, crestQuery, 0, 0, asSet("sn"), false, IdRepo.AND_MOD, null, true);
assertThat(results.getErrorCode()).isEqualTo(ResultCode.SUCCESS.intValue());
assertThat(results.getType()).isEqualTo(IdType.USER);
assertThat(results.getSearchResults()).hasSize(1).containsOnly("searchTester1");
Map<String, Map<String, Set<String>>> resultAttrs = results.getResultAttributes();
assertThat(resultAttrs).hasSize(1);
assertThat(resultAttrs.get("searchTester1")).hasSize(2);
assertThat(resultAttrs.get("searchTester1").get("sn")).containsOnly("hello");
assertThat(resultAttrs.get("searchTester1").get("uid")).containsOnly("searchTester1");
}
use of org.forgerock.openam.utils.CrestQuery in project OpenAM by OpenRock.
the class GenericRepoTest method searchReturnsMatchesForSearchAttribute.
@Test
public void searchReturnsMatchesForSearchAttribute() throws Exception {
CrestQuery crestQuery = new CrestQuery("searchTester*");
RepoSearchResults results = idrepo.search(null, IdType.USER, crestQuery, 0, 0, null, true, IdRepo.AND_MOD, null, true);
assertThat(results.getErrorCode()).isEqualTo(ResultCode.SUCCESS.intValue());
assertThat(results.getType()).isEqualTo(IdType.USER);
assertThat(results.getSearchResults()).hasSize(4).containsOnly("searchTester1", "searchTester2", "searchTester3", "searchTester4");
}
use of org.forgerock.openam.utils.CrestQuery in project OpenAM by OpenRock.
the class GenericRepoTest method searchReturnsMatchesForComplexFilters.
//need to depend on deleteSuccessful, otherwise testuser1 would ruin the day :)
@Test(dependsOnMethods = "deleteSuccessful")
public void searchReturnsMatchesForComplexFilters() throws Exception {
Map<String, Set<String>> avPairs = new HashMap<String, Set<String>>();
avPairs.put("objectclass", asSet("inetorgperson"));
avPairs.put("sn", asSet("hellNo"));
CrestQuery crestQuery = new CrestQuery("*");
RepoSearchResults results = idrepo.search(null, IdType.USER, crestQuery, 0, 0, null, true, IdRepo.AND_MOD, avPairs, true);
assertThat(results.getErrorCode()).isEqualTo(ResultCode.SUCCESS.intValue());
assertThat(results.getType()).isEqualTo(IdType.USER);
assertThat(results.getSearchResults()).containsOnly("searchTester3");
results = idrepo.search(null, IdType.USER, crestQuery, 0, 0, null, true, IdRepo.OR_MOD, avPairs, true);
assertThat(results.getErrorCode()).isEqualTo(ResultCode.SUCCESS.intValue());
assertThat(results.getType()).isEqualTo(IdType.USER);
assertThat(results.getSearchResults()).containsOnly(DEMO, "searchTester1", "searchTester2", "searchTester3", "searchTester4");
}
Aggregations