void () { Repository repository = initRepository("foo"); LocalTask defaultTask = myTaskManager.getActiveTask(); assertNotNull(defaultTask); assertEquals(0, defaultTask.getBranches().size()); LocalTaskImpl foo = myTaskManager.createLocalTask("foo"); LocalTask localTask = myTaskManager.activateTask(foo, false); myTaskManager.createBranch(localTask, defaultTask, myTaskManager.suggestBranchName(localTask), null); assertEquals(2, localTask.getBranches().size()); assertEquals(1, defaultTask.getBranches().size()); // let's add non-existing branch BranchInfo info = new BranchInfo(); info.name = "non-existing"; info.repository = defaultTask.getBranches().get(0).repository; defaultTask.addBranch(info); repository.update(); assertEquals("foo", repository.getCurrentBranchName()); ApplicationManager.getApplication().invokeAndWait(() -> myTaskManager.activateTask(defaultTask, false)); repository.update(); assertEquals(getDefaultBranchName(), repository.getCurrentBranchName()); // do not re-create "non-existing" assertEquals(2, getNumberOfBranches(repository)); }