use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.
the class TestOpenDj method test230SearchObjectsPagedNoOffset.
@Test
public void test230SearchObjectsPagedNoOffset() throws Exception {
final String TEST_NAME = "test230SearchObjectsPagedNoOffset";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE);
ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);
ObjectPaging paging = ObjectPaging.createPaging(null, 3);
query.setPaging(paging);
rememberConnectorOperationCount();
rememberConnectorSimulatedPagingSearchCount();
// WHEN
TestUtil.displayWhen(TEST_NAME);
List<PrismObject<ShadowType>> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
assertSuccess(result);
display("Search resutls", searchResults);
assertSearchResults(searchResults, "cook", "drake", "hbarbossa");
assertConnectorOperationIncrement(1, 7);
assertConnectorSimulatedPagingSearchIncrement(0);
}
use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.
the class TestOpenDj method test232SearchObjectsPagedOffset.
@Test
public void test232SearchObjectsPagedOffset() throws Exception {
final String TEST_NAME = "test232SearchObjectsPagedOffset";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE);
ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);
ObjectPaging paging = ObjectPaging.createPaging(2, 5);
query.setPaging(paging);
rememberConnectorOperationCount();
rememberConnectorSimulatedPagingSearchCount();
// WHEN
TestUtil.displayWhen(TEST_NAME);
SearchResultList<PrismObject<ShadowType>> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
assertSuccess(result);
display("Search resutls", searchResults);
// The results should be this:
assertSearchResults(searchResults, "hbarbossa", "idm", "jbeckett", "jbond", "jgibbs");
assertConnectorOperationIncrement(1, 11);
assertConnectorSimulatedPagingSearchIncrement(0);
}
use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.
the class TestOpenDj method test233SearchObjectsPagedNoOffsetSortSn.
@Test
public void test233SearchObjectsPagedNoOffsetSortSn() throws Exception {
final String TEST_NAME = "test233SearchObjectsPagedNoOffsetSortSn";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE);
ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);
ObjectPaging paging = ObjectPaging.createPaging(null, 4);
paging.setOrdering(ObjectOrdering.createOrdering(new ItemPath(ShadowType.F_ATTRIBUTES, new QName(RESOURCE_NS, "sn")), OrderDirection.ASCENDING));
query.setPaging(paging);
rememberConnectorOperationCount();
rememberConnectorSimulatedPagingSearchCount();
// WHEN
TestUtil.displayWhen(TEST_NAME);
List<PrismObject<ShadowType>> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
assertSuccess(result);
display("Search resutls", searchResults);
assertSearchResults(searchResults, "monk", "hbarbossa", "jbeckett", "jbond");
assertConnectorOperationIncrement(1, 9);
assertConnectorSimulatedPagingSearchIncrement(0);
}
use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.
the class ObjectRetriever method searchObjectsIterativeByPaging.
public <T extends ObjectType> void searchObjectsIterativeByPaging(Class<T> type, ObjectQuery query, ResultHandler<T> handler, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException {
try {
ObjectQuery pagedQuery = query != null ? query.clone() : new ObjectQuery();
int offset;
int remaining;
final int batchSize = getConfiguration().getIterativeSearchByPagingBatchSize();
ObjectPaging paging = pagedQuery.getPaging();
if (paging == null) {
// counts will be filled-in later
paging = ObjectPaging.createPaging(0, 0);
pagedQuery.setPaging(paging);
offset = 0;
remaining = repositoryService.countObjects(type, query, result);
} else {
offset = paging.getOffset() != null ? paging.getOffset() : 0;
remaining = paging.getMaxSize() != null ? paging.getMaxSize() : repositoryService.countObjects(type, query, result) - offset;
}
main: while (remaining > 0) {
paging.setOffset(offset);
paging.setMaxSize(remaining < batchSize ? remaining : batchSize);
List<PrismObject<T>> objects = repositoryService.searchObjects(type, pagedQuery, options, result);
for (PrismObject<T> object : objects) {
if (!handler.handle(object, result)) {
break main;
}
}
if (objects.size() == 0) {
// should not occur, but let's check for this to avoid endless loops
break;
}
offset += objects.size();
remaining -= objects.size();
}
} finally {
if (result != null && result.isUnknown()) {
result.computeStatus();
}
result.setSummarizeSuccesses(true);
result.summarize();
}
}
use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.
the class AbstractLdapConnTest method test158SeachBeyondEnd.
/**
* Make a search that goes beyond the end of the list of all accounts.
*/
@Test
public void test158SeachBeyondEnd() throws Exception {
final String TEST_NAME = "test158SeachBeyondEnd";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext);
ObjectPaging paging = ObjectPaging.createEmptyPaging();
paging.setOffset(getNumberOfAllAccounts() + 50);
paging.setMaxSize(123);
query.setPaging(paging);
int expectedEntries = 0;
if (isVlvSearchBeyondEndResurnsLastEntry()) {
expectedEntries = 1;
}
SearchResultList<PrismObject<ShadowType>> searchResultList = doSearch(TEST_NAME, query, expectedEntries, task, result);
// Fails for 389ds tests. For some unknown reason. And this is not that important. There are similar asserts in other tests that are passing.
// assertConnectorOperationIncrement(1);
assertConnectorSimulatedPagingSearchIncrement(0);
SearchResultMetadata metadata = searchResultList.getMetadata();
if (metadata != null) {
assertFalse(metadata.isPartialResults());
}
assertLdapConnectorInstances(1, 2);
}
Aggregations