List<OrganizationDocument> documents = new ArrayList<>();
for (UniqueId uniqueId : pair.getSecond()) {
documents.add(get(uniqueId));
}
OrganizationSearchResult result = new OrganizationSearchResult(documents);
result.setPaging(Paging.of(request.getPagingRequest(), pair.getFirst()));
final VersionCorrection vc = request.getVersionCorrection().withLatestFixed(Instant.now());
result.setVersionCorrection(vc);
// Debug: check result against underlying
if (EHCachingSearchCache.TEST_AGAINST_UNDERLYING) {
OrganizationSearchResult check = ((OrganizationMaster) getUnderlying()).search(request);
if (!result.getPaging().equals(check.getPaging())) {
s_logger.error(_documentSearchCache.getCache().getName()
+ "\n\tCache:\t" + result.getPaging()
+ "\n\tUnderlying:\t" + check.getPaging());
}
if (!result.getDocuments().equals(check.getDocuments())) {
System.out.println(_documentSearchCache.getCache().getName() + ": ");
if (check.getDocuments().size() != result.getDocuments().size()) {
System.out.println("\tSizes differ (Underlying " + check.getDocuments().size()
+ "; Cache " + result.getDocuments().size() + ")");
} else {
for (int i = 0; i < check.getDocuments().size(); i++) {
if (!check.getDocuments().get(i).equals(result.getDocuments().get(i))) {
System.out.println("\tUnderlying\t" + i + ":\t" + check.getDocuments().get(i).getUniqueId());
System.out.println("\tCache \t" + i + ":\t" + result.getDocuments().get(i).getUniqueId());
}
}
}
}