use of com.evolveum.midpoint.schema.ResultHandler in project midpoint by Evolveum.
the class SearchIterativeTest method test104SimpleSequentialIterationWithCustomPagingSmall.
@Test
public void test104SimpleSequentialIterationWithCustomPagingSmall() throws Exception {
OperationResult result = new OperationResult("test104SimpleSequentialIterationWithCustomPagingSmall");
final List<PrismObject<UserType>> objects = new ArrayList<>();
ResultHandler<UserType> handler = (object, parentResult) -> {
objects.add(object);
return true;
};
SearchOpAsserter asserter = new SearchOpAsserter();
ObjectQuery query = prismContext.queryFactory().createQuery(prismContext.queryFactory().createPaging(1, 200));
repositoryService.searchObjectsIterative(UserType.class, query, handler, null, true, result);
result.recomputeStatus();
// if we are under limit of FETCH_ALL
asserter.assertIncrement(1);
assertTrue(result.isSuccess());
assertObjects(objects, 200);
}
use of com.evolveum.midpoint.schema.ResultHandler in project midpoint by Evolveum.
the class SearchIterativeTest method test110DeleteAll.
@Test
public void test110DeleteAll() throws Exception {
OperationResult result = new OperationResult("test110DeleteAll");
final List<PrismObject<UserType>> objects = new ArrayList<>();
ResultHandler<UserType> handler = (object, parentResult) -> {
objects.add(object);
try {
repositoryService.deleteObject(UserType.class, object.getOid(), parentResult);
} catch (ObjectNotFoundException e) {
throw new SystemException(e);
}
return true;
};
repositoryService.searchObjectsIterative(UserType.class, null, handler, null, true, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertObjects(objects, COUNT);
int count = repositoryService.countObjects(UserType.class, null, null, result);
assertEquals("Wrong # of objects after operation", 0, count);
}
use of com.evolveum.midpoint.schema.ResultHandler in project midpoint by Evolveum.
the class SearchTest method test100IterateEmptySet.
@Test
public void test100IterateEmptySet() throws Exception {
OperationResult result = new OperationResult("search empty");
ResultHandler<UserType> handler = (object, parentResult) -> {
fail();
return false;
};
ObjectQuery query = prismContext.queryFor(UserType.class).item(UserType.F_NAME).eqPoly("asdf", "asdf").matchingStrict().build();
repositoryService.searchObjectsIterative(UserType.class, query, handler, null, false, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
}
use of com.evolveum.midpoint.schema.ResultHandler in project midpoint by Evolveum.
the class AbstractLdapConnTest method singleInfernoSearch.
private void singleInfernoSearch(ObjectQuery query, int expectedNumberOfResults, Integer offset, Integer maxSize, String sortAttrName, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
ObjectPaging paging = prismContext.queryFactory().createPaging(offset, maxSize);
paging.setOrdering(getAttributePath(resource, sortAttrName), OrderDirection.ASCENDING);
query.setPaging(paging);
final MutableInt count = new MutableInt();
ResultHandler<ShadowType> handler = (object, parentResult) -> {
count.increment();
return true;
};
modelService.searchObjectsIterative(ShadowType.class, query, handler, null, task, result);
assertEquals("Unexpected number of search results", expectedNumberOfResults, count.intValue());
}
use of com.evolveum.midpoint.schema.ResultHandler in project midpoint by Evolveum.
the class AbstractLdapHierarchyTest method reconcileAllUsers.
protected void reconcileAllUsers() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
final Task task = getTestTask();
OperationResult result = task.getResult();
ResultHandler<UserType> handler = (object, parentResult) -> {
try {
display("reconciling " + object);
reconcileUser(object.getOid(), task, parentResult);
} catch (SchemaException | PolicyViolationException | ExpressionEvaluationException | ObjectNotFoundException | ObjectAlreadyExistsException | CommunicationException | ConfigurationException | SecurityViolationException e) {
throw new SystemException(e.getMessage(), e);
}
return true;
};
display("Reconciling all users");
modelService.searchObjectsIterative(UserType.class, null, handler, null, task, result);
}
Aggregations