void () { Collection<Scenario> scenarios = createMultithreadScenarios(); SearchResultsCollector collector = new SearchResultsCollector(); Alarm alarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, getTestRootDisposable()); SESearcher searcher = new GroupedResultsSearcher(collector, command -> alarm.addRequest(command, 0), ourEqualityProviders); scenarios.forEach(scenario -> { ProgressIndicator indicator = searcher.search(scenario.contributorsAndLimits, "tst"); try { collector.awaitFinish(1000); } catch (TimeoutException e) { Assert.fail("Search timeout exceeded"); } catch (InterruptedException ignored) { } finally { indicator.cancel(); } scenario.results.forEach((contributorId, results) -> { List<String> values = collector.getContributorValues(contributorId); Assert.assertEquals(String.format("Scenario '%s'. found elements by contributor %s", scenario.description, contributorId), results, values); }); collector.clear(); }); }