use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.
the class SqaleRepoSearchIterativeTest method test112SearchIterativeWithLastPageNotFullWithAndFilter.
@Test
public void test112SearchIterativeWithLastPageNotFullWithAndFilter() throws Exception {
// Like test111 but detects error when conditions are accumulating in provided AND filter with each page.
OperationResult operationResult = createOperationResult();
SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
pm.clearGlobalPerformanceInformation();
given("total result count not multiple of the page size");
long totalCount = count(QUser.class);
int iterativePageSize = 47;
repositoryConfiguration.setIterativeSearchByPagingBatchSize(iterativePageSize);
assertThat(totalCount % repositoryConfiguration.getIterativeSearchByPagingBatchSize()).isNotZero();
queryRecorder.clearBufferAndStartRecording();
when("calling search iterative with query containing condition");
SearchResultMetadata metadata = searchObjectsIterative(prismContext.queryFor(UserType.class).not().item(UserType.F_NAME).isNull().and().item(UserType.F_GIVEN_NAME).isNull().build(), operationResult);
then("result metadata is not null and reports the handled objects");
assertThatOperationResult(operationResult).isSuccess();
assertThat(metadata).isNotNull();
assertThat(metadata.getApproxNumberOfAllResults()).isEqualTo(testHandler.getCounter());
assertThat(metadata.isPartialResults()).isFalse();
// page cookie is not null and it's OID in UUID format
assertThat(UUID.fromString(metadata.getPagingCookie())).isNotNull();
and("search operations were called");
assertOperationRecordedCount(REPO_OP_PREFIX + RepositoryService.OP_SEARCH_OBJECTS_ITERATIVE, 1);
assertTypicalPageOperationCount(metadata);
and("all objects of the specified type were processed");
assertThat(testHandler.getCounter()).isEqualTo(count(QUser.class));
and("last iteration query has proper conditions");
List<SqlRecorder.QueryEntry> iterativeSelects = queryRecorder.getQueryBuffer().stream().filter(e -> e.sql.contains("order by u.oid asc")).collect(Collectors.toList());
// +1 for the last page
assertThat(iterativeSelects).hasSize((int) totalCount / iterativePageSize + 1);
SqlRecorder.QueryEntry lastEntry = iterativeSelects.get(iterativeSelects.size() - 1);
// We want to be sure no accidental filter accumulation happens, see ObjectQueryUtil.filterAnd() vs createAnd().
assertThat(lastEntry.sql).contains("where not (u.nameNorm is null and u.nameOrig is null)" + " and (u.givenNameNorm is null and u.givenNameOrig is null) and u.oid > ?\norder");
}
use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.
the class SqaleAuditSearchIterativeTest method test120SearchIterativeWithMaxSize.
@Test
public void test120SearchIterativeWithMaxSize() throws Exception {
OperationResult operationResult = createOperationResult();
SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
pm.clearGlobalPerformanceInformation();
given("query with maxSize specified");
ObjectQuery query = prismContext.queryFor(UserType.class).maxSize(101).build();
when("calling search iterative");
SearchResultMetadata metadata = searchObjectsIterative(query, operationResult);
then("result metadata is not null and reports partial result (because of the break)");
assertThat(metadata).isNotNull();
assertThat(metadata.getApproxNumberOfAllResults()).isEqualTo(testHandler.processedCount());
assertThat(metadata.isPartialResults()).isFalse();
and("search operations were called");
assertOperationRecordedCount(AUDIT_OP_PREFIX + AuditService.OP_SEARCH_OBJECTS_ITERATIVE, 1);
assertTypicalPageOperationCount(metadata);
and("specified amount of objects was processed");
assertThat(testHandler.processedCount()).isEqualTo(101);
}
use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.
the class SqaleAuditSearchIterativeTest method test110SearchIterativeWithEmptyFilter.
@Test
public void test110SearchIterativeWithEmptyFilter() throws Exception {
OperationResult operationResult = createOperationResult();
SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
pm.clearGlobalPerformanceInformation();
when("calling search iterative with null query");
SearchResultMetadata metadata = searchObjectsIterative(null, operationResult);
then("result metadata is not null and reports the handled objects");
assertThatOperationResult(operationResult).isSuccess();
assertThat(metadata).isNotNull();
assertThat(metadata.getApproxNumberOfAllResults()).isEqualTo(testHandler.processedCount());
assertThat(metadata.isPartialResults()).isFalse();
assertThat(metadata.getPagingCookie()).isNotNull();
and("search operations were called");
assertOperationRecordedCount(AUDIT_OP_PREFIX + AuditService.OP_SEARCH_OBJECTS_ITERATIVE, 1);
assertTypicalPageOperationCount(metadata);
and("all objects of the specified type (here User) were processed");
assertThat(testHandler.processedCount()).isEqualTo(count(aer));
}
use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.
the class AbstractAdLdapMultidomainTest method test174SearchFirst5AccountsOffset2.
/**
* There is offset, so VLV should be used.
* No explicit sorting.
*/
@Test
public void test174SearchFirst5AccountsOffset2() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext);
ObjectPaging paging = prismContext.queryFactory().createPaging(2, 5);
query.setPaging(paging);
allowDuplicateSearchResults = true;
// WHEN
SearchResultList<PrismObject<ShadowType>> searchResultList = doSearch(query, 5, task, result);
// THEN
allowDuplicateSearchResults = false;
// TODO: Why 2? Why not 1?
assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 2);
assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0);
SearchResultMetadata metadata = searchResultList.getMetadata();
if (metadata != null) {
assertFalse(metadata.isPartialResults());
}
assertLdapConnectorReasonableInstances();
}
use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.
the class AbstractLdapConnTest method test152SearchFirst50Accounts.
/**
* Blocksize is 100, so this is in one block.
*/
@Test
public void test152SearchFirst50Accounts() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext);
ObjectPaging paging = prismContext.queryFactory().createPaging();
paging.setMaxSize(50);
query.setPaging(paging);
SearchResultList<PrismObject<ShadowType>> searchResultList = doSearch(query, 50, task, result);
assertConnectorOperationIncrement(1, 51);
assertCounterIncrement(InternalCounters.CONNECTOR_SIMULATED_PAGING_SEARCH_COUNT, 0);
SearchResultMetadata metadata = searchResultList.getMetadata();
if (metadata != null) {
assertFalse(metadata.isPartialResults());
}
// Uknown number of results. This is SPR search.
assertApproxNumberOfAllResults(metadata, null);
assertLdapConnectorReasonableInstances();
}
Aggregations