Skip to content

Commit

Permalink
More connector paging fixes and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jun 15, 2018
1 parent 4b6c308 commit c2c88f8
Show file tree
Hide file tree
Showing 14 changed files with 459 additions and 270 deletions.
Expand Up @@ -565,6 +565,10 @@ public <T extends ObjectType> Integer countObjects(Class<T> type, ObjectQuery qu
query = query.cloneEmpty();
query.setFilter(filter);
}

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Start of counting objects. Query:\n{}", query != null ? query.debugDump(1) : " (null)");
}

if (filter != null && filter instanceof NoneFilter) {
result.recordSuccessIfUnknown();
Expand Down Expand Up @@ -597,6 +601,10 @@ public <T extends ObjectType> Integer countObjects(Class<T> type, ObjectQuery qu
result.cleanupResult();
}

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Finished counting objects: {}", count);
}

return count;
}

Expand Down Expand Up @@ -956,7 +964,7 @@ public <T extends ObjectType> SearchResultMetadata searchObjectsIterative(final
Validate.notNull(handler, "Handler must not be null.");

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Start of search objects. Query:\n{}", query != null ? query.debugDump(1) : " (null)");
LOGGER.trace("Start of (iterative) search objects. Query:\n{}", query != null ? query.debugDump(1) : " (null)");
}

final OperationResult result = parentResult.createSubresult(ProvisioningService.class.getName()
Expand Down
Expand Up @@ -2000,10 +2000,21 @@ public boolean handle(PrismObject<ShadowType> shadow, OperationResult objResult)
countHolder.setValue(count);
return true;
}

@Override
public String toString() {
return "(ShadowCache simulated counting handler)";
}
};

query = query.clone();
ObjectPaging paging = ObjectPaging.createEmptyPaging();
// Explicitly set offset. This makes a difference for some resources.
// E.g. LDAP connector will detect presence of an offset and it will initiate VLV search which
// can estimate number of results. If no offset is specified then continuous/linear search is
// assumed (e.g. Simple Paged Results search). Such search does not have ability to estimate
// number of results.
paging.setOffset(0);
paging.setMaxSize(1);
query.setPaging(paging);
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(
Expand Down
Expand Up @@ -2124,17 +2124,6 @@ protected ObjectOrdering createAttributeOrdering(QName attrQname, OrderDirection
return ObjectOrdering.createOrdering(new ItemPath(ShadowType.F_ATTRIBUTES, attrQname), direction);
}

protected void assertApproxNumberOfAllResults(SearchResultMetadata searchMetadata, Integer expectedNumber) {
if (expectedNumber == null) {
if (searchMetadata == null) {
return;
}
assertNull("Unexpected approximate number of search results in search metadata, expected null but was "+searchMetadata.getApproxNumberOfAllResults(), searchMetadata.getApproxNumberOfAllResults());
} else {
assertEquals("Wrong approximate number of search results in search metadata", expectedNumber, searchMetadata.getApproxNumberOfAllResults());
}
}

@Test
public void test194SearchIcfNameRepoizedNoFetch() throws Exception {
final String TEST_NAME = "test194SearchIcfNameRepoizedNoFetch";
Expand Down

0 comments on commit c2c88f8

Please sign in to comment.