void (String expectedEvents, VFileEvent... eventsToApply) { StringBuilder log = new StringBuilder(); MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(); try { connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() { @Override public void before(@NotNull List<? extends @NotNull VFileEvent> events) { log("Before:", events); } @Override public void after(@NotNull List<? extends @NotNull VFileEvent> events) { log("After:", events); } private void log(String prefix, List<? extends VFileEvent> events) { log.append(prefix); for (VFileEvent e : events) { log.append(' ').append(e.getClass().getSimpleName()).append("->").append(PathUtil.getFileName(e.getPath())); } log.append('\n'); } }); WriteCommandAction.runWriteCommandAction(null, () -> RefreshQueue.getInstance().processEvents(false, List.of(eventsToApply))); } finally { connection.disconnect(); } assertEquals(expectedEvents, log.toString()); }