use of com.intellij.openapi.vcs.VcsTaskHandler in project intellij-community by JetBrains.
the class TaskBranchesTest method testVcsTaskHandler.
public void testVcsTaskHandler() throws Exception {
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());
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());
handler.switchToTask(firstInfo, null);
createAndCommitChanges(repository);
handler.closeTask(secondInfo, firstInfo);
repository.update();
assertEquals(2, getNumberOfBranches(repository));
}
Aggregations