void () { List<Repository> repositories = initRepositories("community", "idea"); Repository repository = repositories.get(0); String defaultBranchName = getDefaultBranchName(); assertEquals(defaultBranchName, repository.getCurrentBranchName()); VcsTaskHandler[] handlers = VcsTaskHandler.getAllHandlers(getProject()); assertEquals(1, handlers.length); VcsTaskHandler handler = handlers[0]; VcsTaskHandler.TaskInfo defaultInfo = handler.getAllExistingTasks()[0]; assertEquals(defaultBranchName, defaultInfo.getName()); assertEquals(2, defaultInfo.getRepositories().size()); final String first = "first"; VcsTaskHandler.TaskInfo firstInfo = handler.startNewTask(first); repository.update(); assertEquals(first, firstInfo.getName()); assertEquals(2, firstInfo.getRepositories().size()); assertEquals(2, getNumberOfBranches(repository)); assertEquals(first, repository.getCurrentBranchName()); ApplicationManager.getApplication().invokeAndWait(() -> handler.switchToTask(defaultInfo, null)); repository.update(); assertEquals(defaultBranchName, repository.getCurrentBranchName()); final String second = "second"; VcsTaskHandler.TaskInfo secondInfo = handler.startNewTask(second); repository.update(); assertEquals(3, getNumberOfBranches(repository)); assertEquals(second, repository.getCurrentBranchName()); ApplicationManager.getApplication().invokeAndWait(() -> handler.switchToTask(firstInfo, null)); createAndCommitChanges(repository); ApplicationManager.getApplication().invokeAndWait(() -> handler.closeTask(secondInfo, firstInfo)); repository.update(); assertEquals(2, getNumberOfBranches(repository)); }