void () { Map<SearchEverywhereContributor<Object>, Integer> contributorsMap = new HashMap<>(); ReadActionContributor action1 = new ReadActionContributor("readAction1", 100, 150, Arrays.asList("ri11", "ri12", "ri13", "ri14", "ri15", "ri16")); ReadActionContributor action2 = new ReadActionContributor("readAction2", 500, 100, Arrays.asList("ri21", "ri22", "ri23", "ri24")); contributorsMap.put(action1, 10); contributorsMap.put(action2, 10); Collector collector = new Collector(); Alarm alarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, getTestRootDisposable()); SESearcher searcher = new GroupedResultsSearcher(collector, command -> alarm.addRequest(command, 0), ourEqualityProviders); ProgressIndicator progressIndicator = searcher.search(contributorsMap, "tst"); try { Application application = ApplicationManager.getApplication(); Thread.sleep(400); application.invokeLater(() -> WriteAction.run(() -> {})); Thread.sleep(900); application.invokeLater(() -> WriteAction.run(() -> {})); if (!collector.awaitFinish(4000)) { Assert.fail("Searching still haven't finished. Possible deadlock"); } Assert.assertEquals(Arrays.asList("ri11", "ri12", "ri13", "ri14", "ri15", "ri16"), collector.getFoundItems("readAction1")); Assert.assertEquals(Arrays.asList("ri21", "ri22", "ri23", "ri24"), collector.getFoundItems("readAction2")); Assert.assertEquals(3, action1.getAttemptsCount()); Assert.assertEquals(1, action2.getAttemptsCount()); } catch (InterruptedException ignored) { } finally { progressIndicator.cancel(); } }